Ken Thomases : winecoreaudio: Avoid an extra copy/conversion of a string.
Module: wine Branch: master Commit: cf390232089a53bd3adcc5364e0da95599aa80ae URL: http://source.winehq.org/git/wine.git/?a=commit;h=cf390232089a53bd3adcc5364e... Author: Ken Thomases <ken(a)codeweavers.com> Date: Thu Oct 20 23:24:12 2011 -0500 winecoreaudio: Avoid an extra copy/conversion of a string. --- dlls/winecoreaudio.drv/mmdevdrv.c | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-) diff --git a/dlls/winecoreaudio.drv/mmdevdrv.c b/dlls/winecoreaudio.drv/mmdevdrv.c index 8d1e046..6842b7e 100644 --- a/dlls/winecoreaudio.drv/mmdevdrv.c +++ b/dlls/winecoreaudio.drv/mmdevdrv.c @@ -325,7 +325,6 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, AudioBufferList *buffers; CFStringRef name; SIZE_T len; - char nameA[256]; int j; addr.mSelector = kAudioDevicePropertyStreamConfiguration; @@ -384,18 +383,10 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, continue; } - if(!CFStringGetCString(name, nameA, sizeof(nameA), - kCFStringEncodingUTF8)){ - WARN("Error converting string to UTF8\n"); - CFRelease(name); - continue; - } - - CFRelease(name); - - len = MultiByteToWideChar(CP_UNIXCP, 0, nameA, -1, NULL, 0); + len = CFStringGetLength(name) + 1; (*ids)[*num] = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if(!(*ids)[*num]){ + CFRelease(name); HeapFree(GetProcessHeap(), 0, devices); for(j = 0; j < *num; ++j){ HeapFree(GetProcessHeap(), 0, (*ids)[j]); @@ -405,7 +396,9 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, HeapFree(GetProcessHeap(), 0, *keys); 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)); if(!(*keys)[*num]){
participants (1)
-
Alexandre Julliard