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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct endpt
|
||||||
|
{
|
||||||
|
WCHAR *name;
|
||||||
|
char *device;
|
||||||
|
};
|
||||||
|
|
||||||
struct endpoints_info
|
struct endpoints_info
|
||||||
{
|
{
|
||||||
unsigned int num, size;
|
unsigned int num, size;
|
||||||
struct endpoint *endpoints;
|
struct endpt *endpoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void endpoints_add(struct endpoints_info *endpoints, WCHAR *name, char *device)
|
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};
|
static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0};
|
||||||
struct get_endpoint_ids_params *params = args;
|
struct get_endpoint_ids_params *params = args;
|
||||||
struct endpoints_info endpoints_info;
|
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;
|
struct endpoint *endpoint;
|
||||||
int err, card;
|
int err, card;
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
card = -1;
|
card = -1;
|
||||||
|
|
||||||
|
@ -505,9 +510,8 @@ static NTSTATUS get_endpoint_ids(void *args)
|
||||||
if(err != 0)
|
if(err != 0)
|
||||||
WARN("Got a failure during card enumeration: %d (%s)\n", err, snd_strerror(err));
|
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;
|
endpoint = params->endpoints;
|
||||||
ptr = (char *)(endpoint + endpoints_info.num);
|
|
||||||
|
|
||||||
for(i = 0; i < endpoints_info.num; i++){
|
for(i = 0; i < endpoints_info.num; i++){
|
||||||
name_len = wcslen(endpoints_info.endpoints[i].name) + 1;
|
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);
|
needed += name_len * sizeof(WCHAR) + ((device_len + 1) & ~1);
|
||||||
|
|
||||||
if(needed <= params->size){
|
if(needed <= params->size){
|
||||||
endpoint->name = (WCHAR *)ptr;
|
endpoint->name = offset;
|
||||||
memcpy(endpoint->name, endpoints_info.endpoints[i].name, name_len * sizeof(WCHAR));
|
memcpy((char *)params->endpoints + offset, endpoints_info.endpoints[i].name, name_len * sizeof(WCHAR));
|
||||||
ptr += name_len * sizeof(WCHAR);
|
offset += name_len * sizeof(WCHAR);
|
||||||
endpoint->device = ptr;
|
endpoint->device = offset;
|
||||||
memcpy(endpoint->device, endpoints_info.endpoints[i].device, device_len);
|
memcpy((char *)params->endpoints + offset, endpoints_info.endpoints[i].device, device_len);
|
||||||
ptr += (device_len + 1) & ~1;
|
offset += (device_len + 1) & ~1;
|
||||||
endpoint++;
|
endpoint++;
|
||||||
}
|
}
|
||||||
free(endpoints_info.endpoints[i].name);
|
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++){
|
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);
|
ids[i] = HeapAlloc(GetProcessHeap(), 0, 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].device, guids + i);
|
get_device_guid(flow, device, guids + i);
|
||||||
}
|
}
|
||||||
*def_index = params.default_idx;
|
*def_index = params.default_idx;
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@ typedef UINT64 stream_handle;
|
||||||
|
|
||||||
struct endpoint
|
struct endpoint
|
||||||
{
|
{
|
||||||
WCHAR *name;
|
unsigned int name;
|
||||||
char *device;
|
unsigned int device;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct get_endpoint_ids_params
|
struct get_endpoint_ids_params
|
||||||
|
|
Loading…
Reference in New Issue