-- v3: wineoss: Remove GetEndpointIDs. winecoreaudio: Remove GetEndpointIDs. winealsa: Remove GetEndpointIDs. winepulse: Move GetEndpointIDs into mmdevapi. mmdevapi: Import get_device_guid() from driver. winepulse: Export get_device_guid(). wineoss: Export get_device_guid(). winecoreaudio: Export get_device_guid(). winealsa: Export get_device_guid(). winepulse: Open/create driver registry key in get_device_guid().
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/wineoss.drv/mmdevdrv.c | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 4a45c532dd0..343581ee9e1 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -95,6 +95,18 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) return TRUE; }
+static void device_add(OSSDevice *oss_dev) +{ + OSSDevice *dev_item; + LIST_FOR_EACH_ENTRY(dev_item, &g_devices, OSSDevice, entry) + if(IsEqualGUID(&oss_dev->guid, &dev_item->guid)){ /* already in list */ + HeapFree(GetProcessHeap(), 0, oss_dev); + return; + } + + list_add_tail(&g_devices, &oss_dev->entry); +} + static void set_device_guid(EDataFlow flow, HKEY drv_key, const WCHAR *key_name, GUID *guid) { @@ -135,6 +147,15 @@ static void get_device_guid(EDataFlow flow, const char *device, GUID *guid) HKEY key = NULL, dev_key; DWORD type, size = sizeof(*guid); WCHAR key_name[256]; + const unsigned int dev_size = strlen(device) + 1; + OSSDevice *oss_dev = HeapAlloc(GetProcessHeap(), 0, offsetof(OSSDevice, devnode[dev_size])); + + if(oss_dev){ + oss_dev->flow = flow; + oss_dev->guid = *guid; + memcpy(oss_dev->devnode, device, dev_size); + device_add(oss_dev); + }
if(flow == eCapture) key_name[0] = '1'; @@ -185,18 +206,6 @@ BOOL WINAPI get_device_name_from_guid(GUID *guid, char **name, EDataFlow *flow) return FALSE; }
-static void device_add(OSSDevice *oss_dev) -{ - OSSDevice *dev_item; - LIST_FOR_EACH_ENTRY(dev_item, &g_devices, OSSDevice, entry) - if(IsEqualGUID(&oss_dev->guid, &dev_item->guid)){ /* already in list */ - HeapFree(GetProcessHeap(), 0, oss_dev); - return; - } - - list_add_tail(&g_devices, &oss_dev->entry); -} - HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **guids_out, UINT *num, UINT *def_index) { @@ -229,23 +238,14 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **gu WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name); char *device = (char *)params.endpoints + params.endpoints[i].device; unsigned int name_size = (wcslen(name) + 1) * sizeof(WCHAR); - unsigned int dev_size = strlen(device) + 1; - OSSDevice *oss_dev;
ids[i] = HeapAlloc(GetProcessHeap(), 0, name_size); - oss_dev = HeapAlloc(GetProcessHeap(), 0, offsetof(OSSDevice, devnode[dev_size])); - if(!ids[i] || !oss_dev){ - HeapFree(GetProcessHeap(), 0, oss_dev); + if(!ids[i]){ params.result = E_OUTOFMEMORY; goto end; } memcpy(ids[i], name, name_size); get_device_guid(flow, device, guids + i); - - oss_dev->flow = flow; - oss_dev->guid = guids[i]; - memcpy(oss_dev->devnode, device, dev_size); - device_add(oss_dev); } *def_index = params.default_idx;
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winepulse.drv/mmdevdrv.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index f7de3296567..3eb95fa1f18 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -103,19 +103,22 @@ static void pulse_call(enum unix_funcs code, void *params) assert(!status); }
-static void get_device_guid(HKEY drv_key, EDataFlow flow, const char *pulse_name, GUID *guid) +static void get_device_guid(EDataFlow flow, const char *pulse_name, GUID *guid) { WCHAR key_name[MAX_PULSE_NAME_LEN + 2]; DWORD type, size = sizeof(*guid); LSTATUS status; - HKEY dev_key; + HKEY drv_key, dev_key;
if (!pulse_name[0]) { *guid = (flow == eRender) ? pulse_render_guid : pulse_capture_guid; return; }
- if (!drv_key) { + status = RegCreateKeyExW(HKEY_CURRENT_USER, drv_key_devicesW, 0, NULL, 0, + KEY_WRITE | KEY_WOW64_64KEY, NULL, &drv_key, NULL); + if (status != ERROR_SUCCESS) { + ERR("Failed to open devices registry key: %lu\n", status); CoCreateGuid(guid); return; } @@ -128,6 +131,7 @@ static void get_device_guid(HKEY drv_key, EDataFlow flow, const char *pulse_name NULL, &dev_key, NULL); if (status != ERROR_SUCCESS) { ERR("Failed to open registry key for device %s: %lu\n", pulse_name, status); + RegCloseKey(drv_key); CoCreateGuid(guid); return; } @@ -140,6 +144,7 @@ static void get_device_guid(HKEY drv_key, EDataFlow flow, const char *pulse_name ERR("Failed to store device GUID for %s to registry: %lu\n", pulse_name, status); } RegCloseKey(dev_key); + RegCloseKey(drv_key); }
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **keys, @@ -149,8 +154,6 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **ke GUID *guids = NULL; WCHAR **ids = NULL; unsigned int i = 0; - LSTATUS status; - HKEY drv_key;
TRACE("%d %p %p %p\n", flow, ids_out, num, def_index);
@@ -173,13 +176,6 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **ke goto end; }
- status = RegCreateKeyExW(HKEY_CURRENT_USER, drv_key_devicesW, 0, NULL, 0, - KEY_WRITE | KEY_WOW64_64KEY, NULL, &drv_key, NULL); - if (status != ERROR_SUCCESS) { - ERR("Failed to open devices registry key: %lu\n", status); - drv_key = NULL; - } - for (i = 0; i < params.num; i++) { WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name); char *pulse_name = (char *)params.endpoints + params.endpoints[i].device; @@ -190,10 +186,8 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **ke break; } memcpy(ids[i], name, size); - get_device_guid(drv_key, flow, pulse_name, &guids[i]); + get_device_guid(flow, pulse_name, &guids[i]); } - if (drv_key) - RegCloseKey(drv_key);
end: HeapFree(GetProcessHeap(), 0, params.endpoints);
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winealsa.drv/mmdevdrv.c | 2 +- dlls/winealsa.drv/winealsa.drv.spec | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index caeade5be56..eaf4679ce9b 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -117,7 +117,7 @@ exit: RegCloseKey(drv_key); }
-static void get_device_guid(EDataFlow flow, const char *device, GUID *guid) +void WINAPI get_device_guid(EDataFlow flow, const char *device, GUID *guid) { HKEY key = NULL, dev_key; DWORD type, size = sizeof(*guid); diff --git a/dlls/winealsa.drv/winealsa.drv.spec b/dlls/winealsa.drv/winealsa.drv.spec index 64089c6df10..47db9f1a179 100644 --- a/dlls/winealsa.drv/winealsa.drv.spec +++ b/dlls/winealsa.drv/winealsa.drv.spec @@ -4,5 +4,6 @@ @ stdcall -private modMessage(long long long long long) ALSA_modMessage
# MMDevAPI driver functions +@ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winecoreaudio.drv/mmdevdrv.c | 2 +- dlls/winecoreaudio.drv/winecoreaudio.drv.spec | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 09668ee9699..8e8fc57f47d 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -113,7 +113,7 @@ exit: RegCloseKey(drv_key); }
-static void get_device_guid(EDataFlow flow, const char *dev, GUID *guid) +void WINAPI get_device_guid(EDataFlow flow, const char *dev, GUID *guid) { HKEY key = NULL, dev_key; DWORD type, size = sizeof(*guid); diff --git a/dlls/winecoreaudio.drv/winecoreaudio.drv.spec b/dlls/winecoreaudio.drv/winecoreaudio.drv.spec index 16cd7f08b2b..5dbdf80bd23 100644 --- a/dlls/winecoreaudio.drv/winecoreaudio.drv.spec +++ b/dlls/winecoreaudio.drv/winecoreaudio.drv.spec @@ -4,5 +4,6 @@ @ stdcall -private modMessage(long long long long long) CoreAudio_modMessage
# MMDevAPI driver functions +@ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/wineoss.drv/mmdevdrv.c | 2 +- dlls/wineoss.drv/wineoss.drv.spec | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 343581ee9e1..65756317c96 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -142,7 +142,7 @@ exit: RegCloseKey(drv_key); }
-static void get_device_guid(EDataFlow flow, const char *device, GUID *guid) +void WINAPI get_device_guid(EDataFlow flow, const char *device, GUID *guid) { HKEY key = NULL, dev_key; DWORD type, size = sizeof(*guid); diff --git a/dlls/wineoss.drv/wineoss.drv.spec b/dlls/wineoss.drv/wineoss.drv.spec index e12fb20fd17..f8b1420901d 100644 --- a/dlls/wineoss.drv/wineoss.drv.spec +++ b/dlls/wineoss.drv/wineoss.drv.spec @@ -5,5 +5,6 @@ @ stdcall -private modMessage(long long long long long) OSS_modMessage
# MMDevAPI driver functions +@ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winepulse.drv/mmdevdrv.c | 2 +- dlls/winepulse.drv/winepulse.drv.spec | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 3eb95fa1f18..11cbc15448c 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -103,7 +103,7 @@ static void pulse_call(enum unix_funcs code, void *params) assert(!status); }
-static void get_device_guid(EDataFlow flow, const char *pulse_name, GUID *guid) +void WINAPI get_device_guid(EDataFlow flow, const char *pulse_name, GUID *guid) { WCHAR key_name[MAX_PULSE_NAME_LEN + 2]; DWORD type, size = sizeof(*guid); diff --git a/dlls/winepulse.drv/winepulse.drv.spec b/dlls/winepulse.drv/winepulse.drv.spec index 5bb84b1764d..5aea12a6a86 100644 --- a/dlls/winepulse.drv/winepulse.drv.spec +++ b/dlls/winepulse.drv/winepulse.drv.spec @@ -1,4 +1,5 @@ # MMDevAPI driver functions +@ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid @ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/mmdevapi/main.c | 1 + dlls/mmdevapi/mmdevapi_private.h | 1 + 2 files changed, 2 insertions(+)
diff --git a/dlls/mmdevapi/main.c b/dlls/mmdevapi/main.c index 43b5921dcc5..d5ed3a653d4 100644 --- a/dlls/mmdevapi/main.c +++ b/dlls/mmdevapi/main.c @@ -98,6 +98,7 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver)
#define LDFC(n) do { driver->p##n = (void*)GetProcAddress(driver->module, #n);\ if(!driver->p##n) { goto fail; } } while(0) + LDFC(get_device_guid); LDFC(get_device_name_from_guid); LDFC(GetEndpointIDs); #undef LDFC diff --git a/dlls/mmdevapi/mmdevapi_private.h b/dlls/mmdevapi/mmdevapi_private.h index f8bf7d3a440..c703ef2517b 100644 --- a/dlls/mmdevapi/mmdevapi_private.h +++ b/dlls/mmdevapi/mmdevapi_private.h @@ -42,6 +42,7 @@ typedef struct _DriverFuncs { * valid. See enum _DriverPriority. */ int priority;
+ void (WINAPI *pget_device_guid)(EDataFlow flow, const char *name, GUID *guid); BOOL (WINAPI *pget_device_name_from_guid)(GUID *guid, char **name, EDataFlow *flow); /* ids gets an array of human-friendly endpoint names * keys gets an array of driver-specific stuff that is used
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/mmdevapi/devenum.c | 53 +++++++++++++++++----- dlls/mmdevapi/main.c | 1 - dlls/mmdevapi/mmdevapi_private.h | 7 --- dlls/winepulse.drv/mmdevdrv.c | 64 --------------------------- dlls/winepulse.drv/winepulse.drv.spec | 1 - 5 files changed, 41 insertions(+), 85 deletions(-)
diff --git a/dlls/mmdevapi/devenum.c b/dlls/mmdevapi/devenum.c index 6344ec66d34..2611393a5c4 100644 --- a/dlls/mmdevapi/devenum.c +++ b/dlls/mmdevapi/devenum.c @@ -17,6 +17,7 @@ */
#include <stdarg.h> +#include <wchar.h>
#define NONAMELESSUNION #define COBJMACROS @@ -527,29 +528,57 @@ static HRESULT set_format(MMDevice *dev)
HRESULT load_driver_devices(EDataFlow flow) { - WCHAR **ids; - GUID *guids; - UINT num, def, i; - HRESULT hr; + struct get_endpoint_ids_params params; + WCHAR **ids = NULL; + GUID *guids = NULL; + UINT i;
- if(!drvs.pGetEndpointIDs) - return S_OK; + params.flow = flow; + params.size = 1024; + params.endpoints = NULL; + do { + HeapFree(GetProcessHeap(), 0, params.endpoints); + params.endpoints = HeapAlloc(GetProcessHeap(), 0, params.size); + __wine_unix_call(drvs.module_unixlib, get_endpoint_ids, ¶ms); + } while (params.result == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER));
- hr = drvs.pGetEndpointIDs(flow, &ids, &guids, &num, &def); - if(FAILED(hr)) - return hr; + if (FAILED(params.result)) + goto end; + + ids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*ids)); + guids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*guids)); + if (!ids || !guids) { + params.result = E_OUTOFMEMORY; + goto end; + } + + for (i = 0; i < params.num; i++) { + const WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name); + const char *dev_name = (char *)params.endpoints + params.endpoints[i].device; + const unsigned int size = (wcslen(name) + 1) * sizeof(WCHAR);
- for(i = 0; i < num; ++i){ + if (!(ids[i] = HeapAlloc(GetProcessHeap(), 0, size))) { + while (i--) HeapFree(GetProcessHeap(), 0, ids[i]); + params.result = E_OUTOFMEMORY; + goto end; + } + memcpy(ids[i], name, size); + drvs.pget_device_guid(flow, dev_name, &guids[i]); + } + + for (i = 0; i < params.num; i++) { MMDevice *dev; dev = MMDevice_Create(ids[i], &guids[i], flow, DEVICE_STATE_ACTIVE, - def == i); + params.default_idx == i); set_format(dev); }
+end: + HeapFree(GetProcessHeap(), 0, params.endpoints); HeapFree(GetProcessHeap(), 0, guids); HeapFree(GetProcessHeap(), 0, ids);
- return S_OK; + return params.result; }
static void MMDevice_Destroy(MMDevice *This) diff --git a/dlls/mmdevapi/main.c b/dlls/mmdevapi/main.c index d5ed3a653d4..12a81ba9aa5 100644 --- a/dlls/mmdevapi/main.c +++ b/dlls/mmdevapi/main.c @@ -100,7 +100,6 @@ static BOOL load_driver(const WCHAR *name, DriverFuncs *driver) if(!driver->p##n) { goto fail; } } while(0) LDFC(get_device_guid); LDFC(get_device_name_from_guid); - LDFC(GetEndpointIDs); #undef LDFC
GetModuleFileNameW(NULL, path, ARRAY_SIZE(path)); diff --git a/dlls/mmdevapi/mmdevapi_private.h b/dlls/mmdevapi/mmdevapi_private.h index c703ef2517b..0ed9140c3ed 100644 --- a/dlls/mmdevapi/mmdevapi_private.h +++ b/dlls/mmdevapi/mmdevapi_private.h @@ -44,13 +44,6 @@ typedef struct _DriverFuncs {
void (WINAPI *pget_device_guid)(EDataFlow flow, const char *name, GUID *guid); BOOL (WINAPI *pget_device_name_from_guid)(GUID *guid, char **name, EDataFlow *flow); - /* ids gets an array of human-friendly endpoint names - * keys gets an array of driver-specific stuff that is used - * in GetAudioEndpoint to identify the endpoint - * it is the caller's responsibility to free both arrays, and - * all of the elements in both arrays with HeapFree() */ - HRESULT (WINAPI *pGetEndpointIDs)(EDataFlow flow, WCHAR ***ids, - GUID **guids, UINT *num, UINT *default_index); } DriverFuncs;
extern DriverFuncs drvs DECLSPEC_HIDDEN; diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 11cbc15448c..19d3d4040a3 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -96,13 +96,6 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved) return TRUE; }
-static void pulse_call(enum unix_funcs code, void *params) -{ - NTSTATUS status; - status = WINE_UNIX_CALL(code, params); - assert(!status); -} - void WINAPI get_device_guid(EDataFlow flow, const char *pulse_name, GUID *guid) { WCHAR key_name[MAX_PULSE_NAME_LEN + 2]; @@ -147,63 +140,6 @@ void WINAPI get_device_guid(EDataFlow flow, const char *pulse_name, GUID *guid) RegCloseKey(drv_key); }
-HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **keys, - UINT *num, UINT *def_index) -{ - struct get_endpoint_ids_params params; - GUID *guids = NULL; - WCHAR **ids = NULL; - unsigned int i = 0; - - TRACE("%d %p %p %p\n", flow, ids_out, num, def_index); - - params.flow = flow; - params.size = MAX_PULSE_NAME_LEN * 4; - params.endpoints = NULL; - do { - HeapFree(GetProcessHeap(), 0, params.endpoints); - params.endpoints = HeapAlloc(GetProcessHeap(), 0, params.size); - pulse_call(get_endpoint_ids, ¶ms); - } while(params.result == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)); - - if (FAILED(params.result)) - goto end; - - ids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*ids)); - guids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*guids)); - if (!ids || !guids) { - params.result = E_OUTOFMEMORY; - goto end; - } - - for (i = 0; i < params.num; i++) { - WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name); - char *pulse_name = (char *)params.endpoints + params.endpoints[i].device; - unsigned int size = (wcslen(name) + 1) * sizeof(WCHAR); - - if (!(ids[i] = HeapAlloc(GetProcessHeap(), 0, size))) { - params.result = E_OUTOFMEMORY; - break; - } - memcpy(ids[i], name, size); - get_device_guid(flow, pulse_name, &guids[i]); - } - -end: - HeapFree(GetProcessHeap(), 0, params.endpoints); - if (FAILED(params.result)) { - HeapFree(GetProcessHeap(), 0, guids); - while (i--) HeapFree(GetProcessHeap(), 0, ids[i]); - HeapFree(GetProcessHeap(), 0, ids); - } else { - *ids_out = ids; - *keys = guids; - *num = params.num; - *def_index = params.default_idx; - } - return params.result; -} - BOOL WINAPI get_device_name_from_guid(GUID *guid, char **name, EDataFlow *flow) { struct device_cache *device; diff --git a/dlls/winepulse.drv/winepulse.drv.spec b/dlls/winepulse.drv/winepulse.drv.spec index 5aea12a6a86..17a0d504c7c 100644 --- a/dlls/winepulse.drv/winepulse.drv.spec +++ b/dlls/winepulse.drv/winepulse.drv.spec @@ -1,7 +1,6 @@ # MMDevAPI driver functions @ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid -@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
# WinMM driver functions @ stdcall -private DriverProc(long long long long long) winealsa.drv.DriverProc
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winealsa.drv/mmdevdrv.c | 61 ----------------------------- dlls/winealsa.drv/winealsa.drv.spec | 1 - 2 files changed, 62 deletions(-)
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index eaf4679ce9b..ee80aa7c09d 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -154,67 +154,6 @@ void WINAPI get_device_guid(EDataFlow flow, const char *device, GUID *guid) RegCloseKey(key); }
-HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **guids_out, - UINT *num, UINT *def_index) -{ - struct get_endpoint_ids_params params; - unsigned int i; - GUID *guids = NULL; - WCHAR **ids = NULL; - - TRACE("%d %p %p %p %p\n", flow, ids, guids, num, def_index); - - params.flow = flow; - params.size = 1000; - params.endpoints = NULL; - do{ - HeapFree(GetProcessHeap(), 0, params.endpoints); - params.endpoints = HeapAlloc(GetProcessHeap(), 0, params.size); - ALSA_CALL(get_endpoint_ids, ¶ms); - }while(params.result == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)); - - if(FAILED(params.result)) goto end; - - ids = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, params.num * sizeof(*ids)); - guids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*guids)); - if(!ids || !guids){ - params.result = E_OUTOFMEMORY; - goto end; - } - - for(i = 0; i < params.num; i++){ - WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name); - char *device = (char *)params.endpoints + params.endpoints[i].device; - unsigned int size = (wcslen(name) + 1) * sizeof(WCHAR); - - ids[i] = HeapAlloc(GetProcessHeap(), 0, size); - if(!ids[i]){ - params.result = E_OUTOFMEMORY; - goto end; - } - memcpy(ids[i], name, size); - get_device_guid(flow, device, guids + i); - } - *def_index = params.default_idx; - -end: - HeapFree(GetProcessHeap(), 0, params.endpoints); - if(FAILED(params.result)){ - HeapFree(GetProcessHeap(), 0, guids); - if(ids){ - for(i = 0; i < params.num; i++) - HeapFree(GetProcessHeap(), 0, ids[i]); - HeapFree(GetProcessHeap(), 0, ids); - } - }else{ - *ids_out = ids; - *guids_out = guids; - *num = params.num; - } - - return params.result; -} - BOOL WINAPI get_device_name_from_guid(GUID *guid, char **name, EDataFlow *flow) { HKEY devices_key; diff --git a/dlls/winealsa.drv/winealsa.drv.spec b/dlls/winealsa.drv/winealsa.drv.spec index 47db9f1a179..8c73d066a39 100644 --- a/dlls/winealsa.drv/winealsa.drv.spec +++ b/dlls/winealsa.drv/winealsa.drv.spec @@ -6,4 +6,3 @@ # MMDevAPI driver functions @ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid -@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/winecoreaudio.drv/mmdevdrv.c | 60 ------------------- dlls/winecoreaudio.drv/winecoreaudio.drv.spec | 1 - 2 files changed, 61 deletions(-)
diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 8e8fc57f47d..b8992618a5a 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -151,66 +151,6 @@ void WINAPI get_device_guid(EDataFlow flow, const char *dev, GUID *guid) RegCloseKey(key); }
-HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, - GUID **guids_out, UINT *num, UINT *def_index) -{ - struct get_endpoint_ids_params params; - unsigned int i; - GUID *guids = NULL; - WCHAR **ids = NULL; - - TRACE("%d %p %p %p\n", flow, ids_out, num, def_index); - - params.flow = flow; - params.size = 1000; - params.endpoints = NULL; - do{ - heap_free(params.endpoints); - params.endpoints = heap_alloc(params.size); - UNIX_CALL(get_endpoint_ids, ¶ms); - }while(params.result == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)); - - if(FAILED(params.result)) goto end; - - ids = heap_alloc_zero(params.num * sizeof(*ids)); - guids = heap_alloc(params.num * sizeof(*guids)); - if(!ids || !guids){ - params.result = E_OUTOFMEMORY; - goto end; - } - - for(i = 0; i < params.num; i++){ - const WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name); - const char *device = (char *)params.endpoints + params.endpoints[i].device; - const unsigned int size = (wcslen(name) + 1) * sizeof(WCHAR); - - ids[i] = heap_alloc(size); - if(!ids[i]){ - params.result = E_OUTOFMEMORY; - goto end; - } - memcpy(ids[i], name, size); - get_device_guid(flow, device, guids + i); - } - *def_index = params.default_idx; - -end: - heap_free(params.endpoints); - if(FAILED(params.result)){ - heap_free(guids); - if(ids){ - for(i = 0; i < params.num; i++) heap_free(ids[i]); - heap_free(ids); - } - }else{ - *ids_out = ids; - *guids_out = guids; - *num = params.num; - } - - return params.result; -} - BOOL WINAPI get_device_name_from_guid(const GUID *guid, char **name, EDataFlow *flow) { HKEY devices_key; diff --git a/dlls/winecoreaudio.drv/winecoreaudio.drv.spec b/dlls/winecoreaudio.drv/winecoreaudio.drv.spec index 5dbdf80bd23..0537f2d2d8b 100644 --- a/dlls/winecoreaudio.drv/winecoreaudio.drv.spec +++ b/dlls/winecoreaudio.drv/winecoreaudio.drv.spec @@ -6,4 +6,3 @@ # MMDevAPI driver functions @ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid -@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
From: Davide Beatrici git@davidebeatrici.dev
--- dlls/wineoss.drv/mmdevdrv.c | 61 ------------------------------- dlls/wineoss.drv/wineoss.drv.spec | 1 - 2 files changed, 62 deletions(-)
diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c index 65756317c96..48a46473956 100644 --- a/dlls/wineoss.drv/mmdevdrv.c +++ b/dlls/wineoss.drv/mmdevdrv.c @@ -205,64 +205,3 @@ BOOL WINAPI get_device_name_from_guid(GUID *guid, char **name, EDataFlow *flow)
return FALSE; } - -HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **guids_out, - UINT *num, UINT *def_index) -{ - struct get_endpoint_ids_params params; - GUID *guids = NULL; - WCHAR **ids = NULL; - unsigned int i; - - TRACE("%d %p %p %p %p\n", flow, ids, guids, num, def_index); - - params.flow = flow; - params.size = 1000; - params.endpoints = NULL; - do{ - HeapFree(GetProcessHeap(), 0, params.endpoints); - params.endpoints = HeapAlloc(GetProcessHeap(), 0, params.size); - OSS_CALL(get_endpoint_ids, ¶ms); - }while(params.result == HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)); - - if(FAILED(params.result)) goto end; - - ids = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, params.num * sizeof(*ids)); - guids = HeapAlloc(GetProcessHeap(), 0, params.num * sizeof(*guids)); - if(!ids || !guids){ - params.result = E_OUTOFMEMORY; - goto end; - } - - for(i = 0; i < params.num; i++){ - WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name); - char *device = (char *)params.endpoints + params.endpoints[i].device; - unsigned int name_size = (wcslen(name) + 1) * sizeof(WCHAR); - - ids[i] = HeapAlloc(GetProcessHeap(), 0, name_size); - if(!ids[i]){ - params.result = E_OUTOFMEMORY; - goto end; - } - memcpy(ids[i], name, name_size); - get_device_guid(flow, device, guids + i); - } - *def_index = params.default_idx; - -end: - HeapFree(GetProcessHeap(), 0, params.endpoints); - if(FAILED(params.result)){ - HeapFree(GetProcessHeap(), 0, guids); - if(ids){ - for(i = 0; i < params.num; i++) - HeapFree(GetProcessHeap(), 0, ids[i]); - HeapFree(GetProcessHeap(), 0, ids); - } - }else{ - *ids_out = ids; - *guids_out = guids; - *num = params.num; - } - - return params.result; -} diff --git a/dlls/wineoss.drv/wineoss.drv.spec b/dlls/wineoss.drv/wineoss.drv.spec index f8b1420901d..c6d68a70eee 100644 --- a/dlls/wineoss.drv/wineoss.drv.spec +++ b/dlls/wineoss.drv/wineoss.drv.spec @@ -7,4 +7,3 @@ # MMDevAPI driver functions @ stdcall -private get_device_guid(long ptr ptr) get_device_guid @ stdcall -private get_device_name_from_guid(ptr ptr ptr) get_device_name_from_guid -@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
This merge request was approved by Huw Davies.
Once this is in, we can simplify `load_driver_devices()` by combining the two loops and eliminating the need to allocate `ids[]` and `guids[]`.