winecoreaudio: Return offsets rather than ptrs to the strings.

This will make the Wow64 syscall rather simpler.

Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Huw Davies 2022-04-25 07:58:35 +01:00 committed by Alexandre Julliard
parent 90e9379f2a
commit ae296bf12f
3 changed files with 12 additions and 10 deletions

View file

@ -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;

View file

@ -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;

View file

@ -23,7 +23,7 @@ typedef UINT64 stream_handle;
struct endpoint
{
WCHAR *name;
unsigned int name;
DWORD id;
};