mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 12:49:45 +00:00
winecoreaudio: Avoid an extra copy/conversion of a string.
This commit is contained in:
parent
4bceee9e15
commit
cf39023208
@ -325,7 +325,6 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
|
|||||||
AudioBufferList *buffers;
|
AudioBufferList *buffers;
|
||||||
CFStringRef name;
|
CFStringRef name;
|
||||||
SIZE_T len;
|
SIZE_T len;
|
||||||
char nameA[256];
|
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
addr.mSelector = kAudioDevicePropertyStreamConfiguration;
|
addr.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||||
@ -384,18 +383,10 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CFStringGetCString(name, nameA, sizeof(nameA),
|
len = CFStringGetLength(name) + 1;
|
||||||
kCFStringEncodingUTF8)){
|
|
||||||
WARN("Error converting string to UTF8\n");
|
|
||||||
CFRelease(name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CFRelease(name);
|
|
||||||
|
|
||||||
len = MultiByteToWideChar(CP_UNIXCP, 0, nameA, -1, NULL, 0);
|
|
||||||
(*ids)[*num] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
(*ids)[*num] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
||||||
if(!(*ids)[*num]){
|
if(!(*ids)[*num]){
|
||||||
|
CFRelease(name);
|
||||||
HeapFree(GetProcessHeap(), 0, devices);
|
HeapFree(GetProcessHeap(), 0, devices);
|
||||||
for(j = 0; j < *num; ++j){
|
for(j = 0; j < *num; ++j){
|
||||||
HeapFree(GetProcessHeap(), 0, (*ids)[j]);
|
HeapFree(GetProcessHeap(), 0, (*ids)[j]);
|
||||||
@ -405,7 +396,9 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids,
|
|||||||
HeapFree(GetProcessHeap(), 0, *keys);
|
HeapFree(GetProcessHeap(), 0, *keys);
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
MultiByteToWideChar(CP_UNIXCP, 0, nameA, -1, (*ids)[*num], len);
|
CFStringGetCharacters(name, CFRangeMake(0, len - 1), (UniChar*)(*ids)[*num]);
|
||||||
|
((*ids)[*num])[len - 1] = 0;
|
||||||
|
CFRelease(name);
|
||||||
|
|
||||||
(*keys)[*num] = HeapAlloc(GetProcessHeap(), 0, sizeof(AudioDeviceID));
|
(*keys)[*num] = HeapAlloc(GetProcessHeap(), 0, sizeof(AudioDeviceID));
|
||||||
if(!(*keys)[*num]){
|
if(!(*keys)[*num]){
|
||||||
|
Loading…
Reference in New Issue
Block a user