-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterator-impl.win.cpp
More file actions
61 lines (51 loc) · 1.84 KB
/
Copy pathiterator-impl.win.cpp
File metadata and controls
61 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "stdafx.h"
#include "iterator-impl.win.h"
#include "winconstants.hpp"
#include "winhelpers.h"
#define HR_CHECK(hr) winhelpers::HR_CHECK(hr)
#define SAFE_RELEASE(pUnk) winhelpers::SAFE_RELEASE(pUnk)
/* DeviceIteratorProfile */
iteratorprofiles_win::MMDeviceIteratorProfile::MMDeviceIteratorProfile(IMMDeviceEnumerator *pEnumerator)
{
HR_CHECK(pEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDevices));
}
iteratorprofiles_win::MMDeviceIteratorProfile::~MMDeviceIteratorProfile()
{
SAFE_RELEASE(&pDevices);
}
void iteratorprofiles_win::MMDeviceIteratorProfile::get(unsigned int index, IMMDevice **ppDevice)
{
IMMDevice *pMMDevice;
HR_CHECK(pDevices->Item(index, &pMMDevice));
*ppDevice = pMMDevice;
}
unsigned int iteratorprofiles_win::MMDeviceIteratorProfile::count()
{
unsigned int count;
HR_CHECK(pDevices->GetCount(&count));
return count;
}
/* SessionIteratorProfile */
iteratorprofiles_win::AudioSessionControlIteratorProfile::AudioSessionControlIteratorProfile(IMMDevice *pDevice)
{
IAudioSessionManager2 *pSessionManager;
HR_CHECK(pDevice->Activate(winconstants::IID_IAudioSessionManager2, CLSCTX_ALL, NULL, (void **)&pSessionManager));
HR_CHECK(pSessionManager->GetSessionEnumerator(&pSessionEnumerator));
SAFE_RELEASE(&pSessionManager);
}
iteratorprofiles_win::AudioSessionControlIteratorProfile::~AudioSessionControlIteratorProfile()
{
SAFE_RELEASE(&pSessionEnumerator);
}
void iteratorprofiles_win::AudioSessionControlIteratorProfile::get(unsigned int index, IAudioSessionControl **ppSession)
{
IAudioSessionControl *pSessionControl;
HR_CHECK(pSessionEnumerator->GetSession((int)index, &pSessionControl));
*ppSession = pSessionControl;
}
unsigned int iteratorprofiles_win::AudioSessionControlIteratorProfile::count()
{
int count;
HR_CHECK(pSessionEnumerator->GetCount(&count));
return static_cast<unsigned int>(count);
}