Commit e87cb774 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

mmdevapi: Use device GUIDs as unique identifiers.

parent 98815f39
...@@ -261,67 +261,58 @@ static HRESULT MMDevice_SetPropValue(const GUID *devguid, DWORD flow, REFPROPERT ...@@ -261,67 +261,58 @@ static HRESULT MMDevice_SetPropValue(const GUID *devguid, DWORD flow, REFPROPERT
* If GUID is null, a random guid will be assigned * If GUID is null, a random guid will be assigned
* and the device will be created * and the device will be created
*/ */
static MMDevice *MMDevice_Create(WCHAR *name, void *devkey, GUID *id, EDataFlow flow, DWORD state, BOOL setdefault) static MMDevice *MMDevice_Create(WCHAR *name, GUID *id, EDataFlow flow, DWORD state, BOOL setdefault)
{ {
HKEY key, root; HKEY key, root;
MMDevice *cur; MMDevice *cur = NULL;
WCHAR guidstr[39]; WCHAR guidstr[39];
DWORD i; DWORD i;
for (i = 0; i < MMDevice_count; ++i) for (i = 0; i < MMDevice_count; ++i)
{ {
cur = MMDevice_head[i]; MMDevice *device = MMDevice_head[i];
if (cur->flow == flow && !lstrcmpW(cur->drv_id, name)) if (device->flow == flow && IsEqualGUID(&device->devguid, id)){
{ cur = device;
LONG ret; break;
/* Same device, update state */
cur->state = state;
cur->key = devkey;
StringFromGUID2(&cur->devguid, guidstr, sizeof(guidstr)/sizeof(*guidstr));
ret = RegOpenKeyExW(flow == eRender ? key_render : key_capture, guidstr, 0, KEY_WRITE, &key);
if (ret == ERROR_SUCCESS)
{
RegSetValueExW(key, reg_devicestate, 0, REG_DWORD, (const BYTE*)&state, sizeof(DWORD));
RegCloseKey(key);
}
goto done;
} }
} }
/* No device found, allocate new one */ if(!cur){
cur = HeapAlloc(GetProcessHeap(), 0, sizeof(*cur)); /* No device found, allocate new one */
if (!cur){ cur = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*cur));
HeapFree(GetProcessHeap(), 0, devkey); if (!cur)
return NULL; return NULL;
}
cur->drv_id = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name)+1)*sizeof(WCHAR)); cur->IMMDevice_iface.lpVtbl = &MMDeviceVtbl;
if (!cur->drv_id) cur->IMMEndpoint_iface.lpVtbl = &MMEndpointVtbl;
{
HeapFree(GetProcessHeap(), 0, cur); InitializeCriticalSection(&cur->crst);
HeapFree(GetProcessHeap(), 0, devkey); cur->crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": MMDevice.crst");
return NULL;
} if (!MMDevice_head)
lstrcpyW(cur->drv_id, name); MMDevice_head = HeapAlloc(GetProcessHeap(), 0, sizeof(*MMDevice_head));
cur->key = devkey; else
cur->IMMDevice_iface.lpVtbl = &MMDeviceVtbl; MMDevice_head = HeapReAlloc(GetProcessHeap(), 0, MMDevice_head, sizeof(*MMDevice_head)*(1+MMDevice_count));
cur->IMMEndpoint_iface.lpVtbl = &MMEndpointVtbl; MMDevice_head[MMDevice_count++] = cur;
cur->ref = 0; }else if(cur->ref > 0)
InitializeCriticalSection(&cur->crst); WARN("Modifying an MMDevice with postitive reference count!\n");
cur->crst.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": MMDevice.crst");
if(cur->drv_id)
HeapFree(GetProcessHeap(), 0, cur->drv_id);
cur->drv_id = name;
cur->flow = flow; cur->flow = flow;
cur->state = state; cur->state = state;
if (!id)
{
id = &cur->devguid;
CoCreateGuid(id);
}
cur->devguid = *id; cur->devguid = *id;
StringFromGUID2(id, guidstr, sizeof(guidstr)/sizeof(*guidstr));
StringFromGUID2(&cur->devguid, guidstr, sizeof(guidstr)/sizeof(*guidstr));
if (flow == eRender) if (flow == eRender)
root = key_render; root = key_render;
else else
root = key_capture; root = key_capture;
if (!RegCreateKeyExW(root, guidstr, 0, NULL, 0, KEY_WRITE|KEY_READ, NULL, &key, NULL))
if (RegCreateKeyExW(root, guidstr, 0, NULL, 0, KEY_WRITE|KEY_READ, NULL, &key, NULL) == ERROR_SUCCESS)
{ {
HKEY keyprop; HKEY keyprop;
RegSetValueExW(key, reg_devicestate, 0, REG_DWORD, (const BYTE*)&state, sizeof(DWORD)); RegSetValueExW(key, reg_devicestate, 0, REG_DWORD, (const BYTE*)&state, sizeof(DWORD));
...@@ -336,13 +327,7 @@ static MMDevice *MMDevice_Create(WCHAR *name, void *devkey, GUID *id, EDataFlow ...@@ -336,13 +327,7 @@ static MMDevice *MMDevice_Create(WCHAR *name, void *devkey, GUID *id, EDataFlow
} }
RegCloseKey(key); RegCloseKey(key);
} }
if (!MMDevice_head)
MMDevice_head = HeapAlloc(GetProcessHeap(), 0, sizeof(*MMDevice_head));
else
MMDevice_head = HeapReAlloc(GetProcessHeap(), 0, MMDevice_head, sizeof(*MMDevice_head)*(1+MMDevice_count));
MMDevice_head[MMDevice_count++] = cur;
done:
if (setdefault) if (setdefault)
{ {
if (flow == eRender) if (flow == eRender)
...@@ -401,7 +386,10 @@ static HRESULT load_devices_from_reg(void) ...@@ -401,7 +386,10 @@ static HRESULT load_devices_from_reg(void)
&& SUCCEEDED(MMDevice_GetPropValue(&guid, curflow, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv)) && SUCCEEDED(MMDevice_GetPropValue(&guid, curflow, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pv))
&& pv.vt == VT_LPWSTR) && pv.vt == VT_LPWSTR)
{ {
MMDevice_Create(pv.u.pwszVal, NULL, &guid, curflow, DWORD size_bytes = (strlenW(pv.u.pwszVal) + 1) * sizeof(WCHAR);
WCHAR *name = HeapAlloc(GetProcessHeap(), 0, size_bytes);
memcpy(name, pv.u.pwszVal, size_bytes);
MMDevice_Create(name, &guid, curflow,
DEVICE_STATE_NOTPRESENT, FALSE); DEVICE_STATE_NOTPRESENT, FALSE);
CoTaskMemFree(pv.u.pwszVal); CoTaskMemFree(pv.u.pwszVal);
} }
...@@ -417,7 +405,7 @@ static HRESULT set_format(MMDevice *dev) ...@@ -417,7 +405,7 @@ static HRESULT set_format(MMDevice *dev)
WAVEFORMATEX *fmt; WAVEFORMATEX *fmt;
PROPVARIANT pv = { VT_EMPTY }; PROPVARIANT pv = { VT_EMPTY };
hr = drvs.pGetAudioEndpoint(dev->key, &dev->IMMDevice_iface, dev->flow, &client); hr = drvs.pGetAudioEndpoint(&dev->devguid, &dev->IMMDevice_iface, &client);
if(FAILED(hr)) if(FAILED(hr))
return hr; return hr;
...@@ -443,26 +431,25 @@ static HRESULT set_format(MMDevice *dev) ...@@ -443,26 +431,25 @@ static HRESULT set_format(MMDevice *dev)
static HRESULT load_driver_devices(EDataFlow flow) static HRESULT load_driver_devices(EDataFlow flow)
{ {
WCHAR **ids; WCHAR **ids;
void **keys; GUID *guids;
UINT num, def, i; UINT num, def, i;
HRESULT hr; HRESULT hr;
if(!drvs.pGetEndpointIDs) if(!drvs.pGetEndpointIDs)
return S_OK; return S_OK;
hr = drvs.pGetEndpointIDs(flow, &ids, &keys, &num, &def); hr = drvs.pGetEndpointIDs(flow, &ids, &guids, &num, &def);
if(FAILED(hr)) if(FAILED(hr))
return hr; return hr;
for(i = 0; i < num; ++i){ for(i = 0; i < num; ++i){
MMDevice *dev; MMDevice *dev;
dev = MMDevice_Create(ids[i], keys[i], NULL, flow, DEVICE_STATE_ACTIVE, dev = MMDevice_Create(ids[i], &guids[i], flow, DEVICE_STATE_ACTIVE,
def == i); def == i);
set_format(dev); set_format(dev);
HeapFree(GetProcessHeap(), 0, ids[i]);
} }
HeapFree(GetProcessHeap(), 0, keys); HeapFree(GetProcessHeap(), 0, guids);
HeapFree(GetProcessHeap(), 0, ids); HeapFree(GetProcessHeap(), 0, ids);
return S_OK; return S_OK;
...@@ -484,7 +471,6 @@ static void MMDevice_Destroy(MMDevice *This) ...@@ -484,7 +471,6 @@ static void MMDevice_Destroy(MMDevice *This)
This->crst.DebugInfo->Spare[0] = 0; This->crst.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&This->crst); DeleteCriticalSection(&This->crst);
HeapFree(GetProcessHeap(), 0, This->drv_id); HeapFree(GetProcessHeap(), 0, This->drv_id);
HeapFree(GetProcessHeap(), 0, This->key);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
} }
...@@ -546,7 +532,7 @@ static HRESULT WINAPI MMDevice_Activate(IMMDevice *iface, REFIID riid, DWORD cls ...@@ -546,7 +532,7 @@ static HRESULT WINAPI MMDevice_Activate(IMMDevice *iface, REFIID riid, DWORD cls
return E_POINTER; return E_POINTER;
if (IsEqualIID(riid, &IID_IAudioClient)){ if (IsEqualIID(riid, &IID_IAudioClient)){
hr = drvs.pGetAudioEndpoint(This->key, iface, This->flow, (IAudioClient**)ppv); hr = drvs.pGetAudioEndpoint(&This->devguid, iface, (IAudioClient**)ppv);
}else if (IsEqualIID(riid, &IID_IAudioEndpointVolume)) }else if (IsEqualIID(riid, &IID_IAudioEndpointVolume))
hr = AudioEndpointVolume_Create(This, (IAudioEndpointVolume**)ppv); hr = AudioEndpointVolume_Create(This, (IAudioEndpointVolume**)ppv);
else if (IsEqualIID(riid, &IID_IAudioSessionManager) else if (IsEqualIID(riid, &IID_IAudioSessionManager)
......
...@@ -50,9 +50,9 @@ typedef struct _DriverFuncs { ...@@ -50,9 +50,9 @@ typedef struct _DriverFuncs {
* it is the caller's responsibility to free both arrays, and * it is the caller's responsibility to free both arrays, and
* all of the elements in both arrays with HeapFree() */ * all of the elements in both arrays with HeapFree() */
HRESULT WINAPI (*pGetEndpointIDs)(EDataFlow flow, WCHAR ***ids, HRESULT WINAPI (*pGetEndpointIDs)(EDataFlow flow, WCHAR ***ids,
void ***keys, UINT *num, UINT *default_index); GUID **guids, UINT *num, UINT *default_index);
HRESULT WINAPI (*pGetAudioEndpoint)(void *key, IMMDevice *dev, HRESULT WINAPI (*pGetAudioEndpoint)(void *key, IMMDevice *dev,
EDataFlow dataflow, IAudioClient **out); IAudioClient **out);
HRESULT WINAPI (*pGetAudioSessionManager)(IMMDevice *device, HRESULT WINAPI (*pGetAudioSessionManager)(IMMDevice *device,
IAudioSessionManager2 **out); IAudioSessionManager2 **out);
} DriverFuncs; } DriverFuncs;
...@@ -70,7 +70,6 @@ typedef struct MMDevice { ...@@ -70,7 +70,6 @@ typedef struct MMDevice {
DWORD state; DWORD state;
GUID devguid; GUID devguid;
WCHAR *drv_id; WCHAR *drv_id;
void *key;
} MMDevice; } MMDevice;
extern HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv) DECLSPEC_HIDDEN; extern HRESULT AudioClient_Create(MMDevice *parent, IAudioClient **ppv) DECLSPEC_HIDDEN;
......
...@@ -340,7 +340,7 @@ static BOOL alsa_try_open(const char *devnode, snd_pcm_stream_t stream) ...@@ -340,7 +340,7 @@ static BOOL alsa_try_open(const char *devnode, snd_pcm_stream_t stream)
} }
static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream, static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream,
WCHAR **ids, GUID **guids, UINT *num, snd_ctl_t *ctl, int card, WCHAR **ids, GUID *guids, UINT *num, snd_ctl_t *ctl, int card,
const WCHAR *cardnameW) const WCHAR *cardnameW)
{ {
static const WCHAR dashW[] = {' ','-',' ',0}; static const WCHAR dashW[] = {' ','-',' ',0};
...@@ -401,13 +401,7 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream, ...@@ -401,13 +401,7 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream,
MultiByteToWideChar(CP_UNIXCP, 0, devname, -1, ids[*num] + cardlen, MultiByteToWideChar(CP_UNIXCP, 0, devname, -1, ids[*num] + cardlen,
len - cardlen); len - cardlen);
guids[*num] = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID)); get_device_guid(flow, devnode, &guids[*num]);
if(!guids[*num]){
HeapFree(GetProcessHeap(), 0, info);
HeapFree(GetProcessHeap(), 0, ids[*num]);
return E_OUTOFMEMORY;
}
get_device_guid(flow, devnode, guids[*num]);
} }
++(*num); ++(*num);
...@@ -423,7 +417,7 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream, ...@@ -423,7 +417,7 @@ static HRESULT alsa_get_card_devices(EDataFlow flow, snd_pcm_stream_t stream,
} }
static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids, static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids,
GUID **guids, UINT *num) GUID *guids, UINT *num)
{ {
static const WCHAR ALSAOutputDevices[] = {'A','L','S','A','O','u','t','p','u','t','D','e','v','i','c','e','s',0}; static const WCHAR ALSAOutputDevices[] = {'A','L','S','A','O','u','t','p','u','t','D','e','v','i','c','e','s',0};
static const WCHAR ALSAInputDevices[] = {'A','L','S','A','I','n','p','u','t','D','e','v','i','c','e','s',0}; static const WCHAR ALSAInputDevices[] = {'A','L','S','A','I','n','p','u','t','D','e','v','i','c','e','s',0};
...@@ -455,8 +449,7 @@ static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids ...@@ -455,8 +449,7 @@ static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids
ids[*num] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); ids[*num] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
memcpy(ids[*num], p, len * sizeof(WCHAR)); memcpy(ids[*num], p, len * sizeof(WCHAR));
guids[*num] = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID)); get_device_guid(flow, devname, &guids[*num]);
get_device_guid(flow, devname, guids[*num]);
} }
++*num; ++*num;
} }
...@@ -469,7 +462,7 @@ static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids ...@@ -469,7 +462,7 @@ static void get_reg_devices(EDataFlow flow, snd_pcm_stream_t stream, WCHAR **ids
} }
} }
static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, GUID **guids, static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, GUID *guids,
UINT *num) UINT *num)
{ {
snd_pcm_stream_t stream = (flow == eRender ? SND_PCM_STREAM_PLAYBACK : snd_pcm_stream_t stream = (flow == eRender ? SND_PCM_STREAM_PLAYBACK :
...@@ -483,8 +476,7 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, GUID **guids, ...@@ -483,8 +476,7 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, GUID **guids,
if(ids && guids){ if(ids && guids){
*ids = HeapAlloc(GetProcessHeap(), 0, sizeof(defaultW)); *ids = HeapAlloc(GetProcessHeap(), 0, sizeof(defaultW));
memcpy(*ids, defaultW, sizeof(defaultW)); memcpy(*ids, defaultW, sizeof(defaultW));
*guids = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID)); get_device_guid(flow, defname, guids);
get_device_guid(flow, defname, *guids);
} }
++*num; ++*num;
} }
...@@ -540,7 +532,7 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, GUID **guids, ...@@ -540,7 +532,7 @@ static HRESULT alsa_enum_devices(EDataFlow flow, WCHAR **ids, GUID **guids,
return S_OK; return S_OK;
} }
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids, HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID **guids,
UINT *num, UINT *def_index) UINT *num, UINT *def_index)
{ {
HRESULT hr; HRESULT hr;
...@@ -559,7 +551,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids ...@@ -559,7 +551,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids
} }
*ids = HeapAlloc(GetProcessHeap(), 0, *num * sizeof(WCHAR *)); *ids = HeapAlloc(GetProcessHeap(), 0, *num * sizeof(WCHAR *));
*guids = HeapAlloc(GetProcessHeap(), 0, *num * sizeof(GUID *)); *guids = HeapAlloc(GetProcessHeap(), 0, *num * sizeof(GUID));
if(!*ids || !*guids){ if(!*ids || !*guids){
HeapFree(GetProcessHeap(), 0, *ids); HeapFree(GetProcessHeap(), 0, *ids);
HeapFree(GetProcessHeap(), 0, *guids); HeapFree(GetProcessHeap(), 0, *guids);
...@@ -571,10 +563,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids ...@@ -571,10 +563,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids
hr = alsa_enum_devices(flow, *ids, *guids, num); hr = alsa_enum_devices(flow, *ids, *guids, num);
if(FAILED(hr)){ if(FAILED(hr)){
int i; int i;
for(i = 0; i < *num; ++i){ for(i = 0; i < *num; ++i)
HeapFree(GetProcessHeap(), 0, (*ids)[i]); HeapFree(GetProcessHeap(), 0, (*ids)[i]);
HeapFree(GetProcessHeap(), 0, (*guids)[i]);
}
HeapFree(GetProcessHeap(), 0, *ids); HeapFree(GetProcessHeap(), 0, *ids);
HeapFree(GetProcessHeap(), 0, *guids); HeapFree(GetProcessHeap(), 0, *guids);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -729,8 +719,7 @@ static BOOL get_alsa_name_by_guid(GUID *guid, char *name, DWORD name_size, EData ...@@ -729,8 +719,7 @@ static BOOL get_alsa_name_by_guid(GUID *guid, char *name, DWORD name_size, EData
return FALSE; return FALSE;
} }
HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, EDataFlow unused_flow, HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient **out)
IAudioClient **out)
{ {
ACImpl *This; ACImpl *This;
int err; int err;
......
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
# MMDevAPI driver functions # MMDevAPI driver functions
@ stdcall -private GetPriority() AUDDRV_GetPriority @ stdcall -private GetPriority() AUDDRV_GetPriority
@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
@ stdcall -private GetAudioEndpoint(ptr ptr long ptr) AUDDRV_GetAudioEndpoint @ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint
@ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager @ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager
...@@ -357,7 +357,7 @@ static void get_device_guid(EDataFlow flow, AudioDeviceID device, GUID *guid) ...@@ -357,7 +357,7 @@ static void get_device_guid(EDataFlow flow, AudioDeviceID device, GUID *guid)
} }
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
GUID ***guids, UINT *num, UINT *def_index) GUID **guids, UINT *num, UINT *def_index)
{ {
UInt32 devsize, size; UInt32 devsize, size;
AudioDeviceID *devices; AudioDeviceID *devices;
...@@ -413,7 +413,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, ...@@ -413,7 +413,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
*guids = HeapAlloc(GetProcessHeap(), 0, ndevices * sizeof(GUID *)); *guids = HeapAlloc(GetProcessHeap(), 0, ndevices * sizeof(GUID));
if(!*ids){ if(!*ids){
HeapFree(GetProcessHeap(), 0, *ids); HeapFree(GetProcessHeap(), 0, *ids);
HeapFree(GetProcessHeap(), 0, devices); HeapFree(GetProcessHeap(), 0, devices);
...@@ -444,10 +444,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, ...@@ -444,10 +444,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
buffers = HeapAlloc(GetProcessHeap(), 0, size); buffers = HeapAlloc(GetProcessHeap(), 0, size);
if(!buffers){ if(!buffers){
HeapFree(GetProcessHeap(), 0, devices); HeapFree(GetProcessHeap(), 0, devices);
for(j = 0; j < *num; ++j){ for(j = 0; j < *num; ++j)
HeapFree(GetProcessHeap(), 0, (*ids)[j]); HeapFree(GetProcessHeap(), 0, (*ids)[j]);
HeapFree(GetProcessHeap(), 0, (*guids)[j]);
}
HeapFree(GetProcessHeap(), 0, *guids); HeapFree(GetProcessHeap(), 0, *guids);
HeapFree(GetProcessHeap(), 0, *ids); HeapFree(GetProcessHeap(), 0, *ids);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -489,10 +487,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, ...@@ -489,10 +487,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
if(!(*ids)[*num]){ if(!(*ids)[*num]){
CFRelease(name); CFRelease(name);
HeapFree(GetProcessHeap(), 0, devices); HeapFree(GetProcessHeap(), 0, devices);
for(j = 0; j < *num; ++j){ for(j = 0; j < *num; ++j)
HeapFree(GetProcessHeap(), 0, (*ids)[j]); HeapFree(GetProcessHeap(), 0, (*ids)[j]);
HeapFree(GetProcessHeap(), 0, (*guids)[j]);
}
HeapFree(GetProcessHeap(), 0, *ids); HeapFree(GetProcessHeap(), 0, *ids);
HeapFree(GetProcessHeap(), 0, *guids); HeapFree(GetProcessHeap(), 0, *guids);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -501,19 +497,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, ...@@ -501,19 +497,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
((*ids)[*num])[len - 1] = 0; ((*ids)[*num])[len - 1] = 0;
CFRelease(name); CFRelease(name);
(*guids)[*num] = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID)); get_device_guid(flow, devices[i], &(*guids)[*num]);
if(!(*guids)[*num]){
HeapFree(GetProcessHeap(), 0, devices);
HeapFree(GetProcessHeap(), 0, (*ids)[*num]);
for(j = 0; j < *num; ++j){
HeapFree(GetProcessHeap(), 0, (*ids)[j]);
HeapFree(GetProcessHeap(), 0, (*guids)[j]);
}
HeapFree(GetProcessHeap(), 0, *ids);
HeapFree(GetProcessHeap(), 0, *guids);
return E_OUTOFMEMORY;
}
get_device_guid(flow, devices[i], (*guids)[*num]);
if(*def_index == (UINT)-1 && devices[i] == default_id) if(*def_index == (UINT)-1 && devices[i] == default_id)
*def_index = *num; *def_index = *num;
...@@ -595,8 +579,7 @@ static BOOL get_deviceid_by_guid(GUID *guid, AudioDeviceID *id, EDataFlow *flow) ...@@ -595,8 +579,7 @@ static BOOL get_deviceid_by_guid(GUID *guid, AudioDeviceID *id, EDataFlow *flow)
return FALSE; return FALSE;
} }
HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient **out)
EDataFlow unused_dataflow, IAudioClient **out)
{ {
ACImpl *This; ACImpl *This;
AudioDeviceID adevid; AudioDeviceID adevid;
......
...@@ -6,5 +6,5 @@ ...@@ -6,5 +6,5 @@
# MMDevAPI driver functions # MMDevAPI driver functions
@ stdcall -private GetPriority() AUDDRV_GetPriority @ stdcall -private GetPriority() AUDDRV_GetPriority
@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
@ stdcall -private GetAudioEndpoint(str ptr long ptr) AUDDRV_GetAudioEndpoint @ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint
@ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager @ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager
...@@ -451,7 +451,7 @@ static UINT get_default_index(EDataFlow flow) ...@@ -451,7 +451,7 @@ static UINT get_default_index(EDataFlow flow)
return 0; return 0;
} }
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids, HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID **guids,
UINT *num, UINT *def_index) UINT *num, UINT *def_index)
{ {
int i, mixer_fd; int i, mixer_fd;
...@@ -497,7 +497,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids ...@@ -497,7 +497,7 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids
} }
*ids = HeapAlloc(GetProcessHeap(), 0, sysinfo.numaudios * sizeof(WCHAR *)); *ids = HeapAlloc(GetProcessHeap(), 0, sysinfo.numaudios * sizeof(WCHAR *));
*guids = HeapAlloc(GetProcessHeap(), 0, sysinfo.numaudios * sizeof(GUID *)); *guids = HeapAlloc(GetProcessHeap(), 0, sysinfo.numaudios * sizeof(GUID));
*num = 0; *num = 0;
for(i = 0; i < sysinfo.numaudios; ++i){ for(i = 0; i < sysinfo.numaudios; ++i){
...@@ -544,29 +544,14 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids ...@@ -544,29 +544,14 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, GUID ***guids
get_device_guid(flow, devnode, &dev_item->guid); get_device_guid(flow, devnode, &dev_item->guid);
strcpy(dev_item->devnode, devnode); strcpy(dev_item->devnode, devnode);
(*guids)[*num] = HeapAlloc(GetProcessHeap(), 0, sizeof(GUID)); (*guids)[*num] = dev_item->guid;
if(!(*guids)[*num]){
for(i = 0; i < *num; ++i){
HeapFree(GetProcessHeap(), 0, (*ids)[i]);
HeapFree(GetProcessHeap(), 0, (*guids)[i]);
}
HeapFree(GetProcessHeap(), 0, *ids);
HeapFree(GetProcessHeap(), 0, *guids);
HeapFree(GetProcessHeap(), 0, dev_item);
close(mixer_fd);
return E_OUTOFMEMORY;
}
*(*guids)[*num] = dev_item->guid;
len = MultiByteToWideChar(CP_UNIXCP, 0, ai.name, -1, NULL, 0); len = MultiByteToWideChar(CP_UNIXCP, 0, ai.name, -1, NULL, 0);
(*ids)[*num] = HeapAlloc(GetProcessHeap(), 0, (*ids)[*num] = HeapAlloc(GetProcessHeap(), 0,
len * sizeof(WCHAR)); len * sizeof(WCHAR));
if(!(*ids)[*num]){ if(!(*ids)[*num]){
HeapFree(GetProcessHeap(), 0, (*guids)[*num]); for(i = 0; i < *num; ++i)
for(i = 0; i < *num; ++i){
HeapFree(GetProcessHeap(), 0, (*ids)[i]); HeapFree(GetProcessHeap(), 0, (*ids)[i]);
HeapFree(GetProcessHeap(), 0, (*guids)[i]);
}
HeapFree(GetProcessHeap(), 0, *ids); HeapFree(GetProcessHeap(), 0, *ids);
HeapFree(GetProcessHeap(), 0, *guids); HeapFree(GetProcessHeap(), 0, *guids);
HeapFree(GetProcessHeap(), 0, dev_item); HeapFree(GetProcessHeap(), 0, dev_item);
...@@ -599,7 +584,7 @@ const OSSDevice *get_ossdevice_from_guid(const GUID *guid) ...@@ -599,7 +584,7 @@ const OSSDevice *get_ossdevice_from_guid(const GUID *guid)
} }
HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev,
EDataFlow unused_dataflow, IAudioClient **out) IAudioClient **out)
{ {
ACImpl *This; ACImpl *This;
const OSSDevice *oss_dev; const OSSDevice *oss_dev;
......
...@@ -7,5 +7,5 @@ ...@@ -7,5 +7,5 @@
# MMDevAPI driver functions # MMDevAPI driver functions
@ stdcall -private GetPriority() AUDDRV_GetPriority @ stdcall -private GetPriority() AUDDRV_GetPriority
@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
@ stdcall -private GetAudioEndpoint(ptr ptr long ptr) AUDDRV_GetAudioEndpoint @ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint
@ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager @ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment