winealsa: 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:
parent
3dfd1fdc14
commit
73a5009510
|
@ -291,10 +291,16 @@ static WCHAR *construct_device_id(EDataFlow flow, const WCHAR *chunk1, const WCH
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct endpt
|
||||
{
|
||||
WCHAR *name;
|
||||
char *device;
|
||||
};
|
||||
|
||||
struct endpoints_info
|
||||
{
|
||||
unsigned int num, size;
|
||||
struct endpoint *endpoints;
|
||||
struct endpt *endpoints;
|
||||
};
|
||||
|
||||
static void endpoints_add(struct endpoints_info *endpoints, WCHAR *name, char *device)
|
||||
|
@ -467,10 +473,9 @@ static NTSTATUS get_endpoint_ids(void *args)
|
|||
static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0};
|
||||
struct get_endpoint_ids_params *params = args;
|
||||
struct endpoints_info endpoints_info;
|
||||
unsigned int i, needed, name_len, device_len;
|
||||
unsigned int i, needed, name_len, device_len, offset;
|
||||
struct endpoint *endpoint;
|
||||
int err, card;
|
||||
char *ptr;
|
||||
|
||||
card = -1;
|
||||
|
||||
|
@ -505,9 +510,8 @@ static NTSTATUS get_endpoint_ids(void *args)
|
|||
if(err != 0)
|
||||
WARN("Got a failure during card enumeration: %d (%s)\n", err, snd_strerror(err));
|
||||
|
||||
needed = endpoints_info.num * sizeof(*params->endpoints);
|
||||
offset = needed = endpoints_info.num * sizeof(*params->endpoints);
|
||||
endpoint = params->endpoints;
|
||||
ptr = (char *)(endpoint + endpoints_info.num);
|
||||
|
||||
for(i = 0; i < endpoints_info.num; i++){
|
||||
name_len = wcslen(endpoints_info.endpoints[i].name) + 1;
|
||||
|
@ -515,12 +519,12 @@ static NTSTATUS get_endpoint_ids(void *args)
|
|||
needed += name_len * sizeof(WCHAR) + ((device_len + 1) & ~1);
|
||||
|
||||
if(needed <= params->size){
|
||||
endpoint->name = (WCHAR *)ptr;
|
||||
memcpy(endpoint->name, endpoints_info.endpoints[i].name, name_len * sizeof(WCHAR));
|
||||
ptr += name_len * sizeof(WCHAR);
|
||||
endpoint->device = ptr;
|
||||
memcpy(endpoint->device, endpoints_info.endpoints[i].device, device_len);
|
||||
ptr += (device_len + 1) & ~1;
|
||||
endpoint->name = offset;
|
||||
memcpy((char *)params->endpoints + offset, endpoints_info.endpoints[i].name, name_len * sizeof(WCHAR));
|
||||
offset += name_len * sizeof(WCHAR);
|
||||
endpoint->device = offset;
|
||||
memcpy((char *)params->endpoints + offset, endpoints_info.endpoints[i].device, device_len);
|
||||
offset += (device_len + 1) & ~1;
|
||||
endpoint++;
|
||||
}
|
||||
free(endpoints_info.endpoints[i].name);
|
||||
|
|
|
@ -366,14 +366,17 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **gu
|
|||
}
|
||||
|
||||
for(i = 0; i < params.num; i++){
|
||||
unsigned int size = (wcslen(params.endpoints[i].name) + 1) * sizeof(WCHAR);
|
||||
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], params.endpoints[i].name, size);
|
||||
get_device_guid(flow, params.endpoints[i].device, guids + i);
|
||||
memcpy(ids[i], name, size);
|
||||
get_device_guid(flow, device, guids + i);
|
||||
}
|
||||
*def_index = params.default_idx;
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ typedef UINT64 stream_handle;
|
|||
|
||||
struct endpoint
|
||||
{
|
||||
WCHAR *name;
|
||||
char *device;
|
||||
unsigned int name;
|
||||
unsigned int device;
|
||||
};
|
||||
|
||||
struct get_endpoint_ids_params
|
||||
|
|
Loading…
Reference in New Issue