Commit 09a84020 authored by Davide Beatrici's avatar Davide Beatrici Committed by Alexandre Julliard

winepulse: Move GetEndpointIDs into mmdevapi.

parent a8963c00
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <wchar.h>
#define COBJMACROS
#include "windef.h"
......@@ -526,29 +527,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, &params);
} 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)
......
......@@ -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));
......
......@@ -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;
......
......@@ -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, &params);
} 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;
......
# 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
......
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