Commit ae296bf1 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

winecoreaudio: Return offsets rather than ptrs to the strings.

This will make the Wow64 syscall rather simpler. Signed-off-by: 's avatarHuw Davies <huw@codeweavers.com> Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 90e9379f
...@@ -185,7 +185,7 @@ static BOOL device_has_channels(AudioDeviceID device, EDataFlow flow) ...@@ -185,7 +185,7 @@ static BOOL device_has_channels(AudioDeviceID device, EDataFlow flow)
static NTSTATUS get_endpoint_ids(void *args) static NTSTATUS get_endpoint_ids(void *args)
{ {
struct get_endpoint_ids_params *params = args; struct get_endpoint_ids_params *params = args;
unsigned int num_devices, i, needed; unsigned int num_devices, i, needed, offset;
AudioDeviceID *devices, default_id; AudioDeviceID *devices, default_id;
AudioObjectPropertyAddress addr; AudioObjectPropertyAddress addr;
struct endpoint *endpoint; struct endpoint *endpoint;
...@@ -196,7 +196,7 @@ static NTSTATUS get_endpoint_ids(void *args) ...@@ -196,7 +196,7 @@ static NTSTATUS get_endpoint_ids(void *args)
AudioDeviceID id; AudioDeviceID id;
} *info; } *info;
OSStatus sc; OSStatus sc;
WCHAR *ptr; UniChar *ptr;
params->num = 0; params->num = 0;
params->default_idx = 0; params->default_idx = 0;
...@@ -262,21 +262,21 @@ static NTSTATUS get_endpoint_ids(void *args) ...@@ -262,21 +262,21 @@ static NTSTATUS get_endpoint_ids(void *args)
} }
free(devices); free(devices);
needed = sizeof(*endpoint) * params->num; offset = needed = sizeof(*endpoint) * params->num;
endpoint = params->endpoints; endpoint = params->endpoints;
ptr = (WCHAR *)(endpoint + params->num);
for(i = 0; i < params->num; i++){ for(i = 0; i < params->num; i++){
SIZE_T len = CFStringGetLength(info[i].name); SIZE_T len = CFStringGetLength(info[i].name);
needed += (len + 1) * sizeof(WCHAR); needed += (len + 1) * sizeof(WCHAR);
if(needed <= params->size){ if(needed <= params->size){
endpoint->name = ptr; endpoint->name = offset;
CFStringGetCharacters(info[i].name, CFRangeMake(0, len), (UniChar*)endpoint->name); ptr = (UniChar *)((char *)params->endpoints + offset);
CFStringGetCharacters(info[i].name, CFRangeMake(0, len), ptr);
ptr[len] = 0; ptr[len] = 0;
endpoint->id = info[i].id; endpoint->id = info[i].id;
endpoint++; endpoint++;
ptr += len + 1; offset += (len + 1) * sizeof(WCHAR);
} }
CFRelease(info[i].name); CFRelease(info[i].name);
if(info[i].id == default_id) params->default_idx = i; if(info[i].id == default_id) params->default_idx = i;
......
...@@ -341,13 +341,15 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, ...@@ -341,13 +341,15 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out,
} }
for(i = 0; i < params.num; i++){ for(i = 0; i < params.num; i++){
int size = (wcslen(params.endpoints[i].name) + 1) * sizeof(WCHAR); WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name);
int size = (wcslen(name) + 1) * sizeof(WCHAR);
ids[i] = heap_alloc(size); ids[i] = heap_alloc(size);
if(!ids[i]){ if(!ids[i]){
params.result = E_OUTOFMEMORY; params.result = E_OUTOFMEMORY;
goto end; goto end;
} }
memcpy(ids[i], params.endpoints[i].name, size); memcpy(ids[i], name, size);
get_device_guid(flow, params.endpoints[i].id, guids + i); get_device_guid(flow, params.endpoints[i].id, guids + i);
} }
*def_index = params.default_idx; *def_index = params.default_idx;
......
...@@ -23,7 +23,7 @@ typedef UINT64 stream_handle; ...@@ -23,7 +23,7 @@ typedef UINT64 stream_handle;
struct endpoint struct endpoint
{ {
WCHAR *name; unsigned int name;
DWORD id; DWORD id;
}; };
......
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