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)
static NTSTATUS get_endpoint_ids(void *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;
AudioObjectPropertyAddress addr;
struct endpoint *endpoint;
......@@ -196,7 +196,7 @@ static NTSTATUS get_endpoint_ids(void *args)
AudioDeviceID id;
} *info;
OSStatus sc;
WCHAR *ptr;
UniChar *ptr;
params->num = 0;
params->default_idx = 0;
......@@ -262,21 +262,21 @@ static NTSTATUS get_endpoint_ids(void *args)
}
free(devices);
needed = sizeof(*endpoint) * params->num;
offset = needed = sizeof(*endpoint) * params->num;
endpoint = params->endpoints;
ptr = (WCHAR *)(endpoint + params->num);
for(i = 0; i < params->num; i++){
SIZE_T len = CFStringGetLength(info[i].name);
needed += (len + 1) * sizeof(WCHAR);
if(needed <= params->size){
endpoint->name = ptr;
CFStringGetCharacters(info[i].name, CFRangeMake(0, len), (UniChar*)endpoint->name);
endpoint->name = offset;
ptr = (UniChar *)((char *)params->endpoints + offset);
CFStringGetCharacters(info[i].name, CFRangeMake(0, len), ptr);
ptr[len] = 0;
endpoint->id = info[i].id;
endpoint++;
ptr += len + 1;
offset += (len + 1) * sizeof(WCHAR);
}
CFRelease(info[i].name);
if(info[i].id == default_id) params->default_idx = i;
......
......@@ -341,13 +341,15 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out,
}
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);
if(!ids[i]){
params.result = E_OUTOFMEMORY;
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);
}
*def_index = params.default_idx;
......
......@@ -23,7 +23,7 @@ typedef UINT64 stream_handle;
struct endpoint
{
WCHAR *name;
unsigned int name;
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