From a0347e0651e27be9910015f12baad58f50998203 Mon Sep 17 00:00:00 2001 From: "Diogo Franco (Kovensky)" Date: Tue, 11 Mar 2014 15:50:09 -0300 Subject: ao_wasapi: Use the character set conversion functions from io.h ...rather than rolling out our own. The only possible advantage is that the "custom" ones didn't use talloc. --- audio/out/ao_wasapi.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'audio/out/ao_wasapi.c') diff --git a/audio/out/ao_wasapi.c b/audio/out/ao_wasapi.c index 2353fc4cc2..3d59554dcd 100644 --- a/audio/out/ao_wasapi.c +++ b/audio/out/ao_wasapi.c @@ -35,6 +35,7 @@ #include "audio/format.h" #include "compat/atomics.h" #include "osdep/timer.h" +#include "osdep/io.h" #define EXIT_ON_ERROR(hres) \ do { if (FAILED(hres)) { goto exit_label; } } while(0) @@ -233,16 +234,6 @@ static int init(struct ao *ao) return state->init_ret; } -static wchar_t* utf8_to_wstring(char *string) { - if (string) { - int len = MultiByteToWideChar(CP_UTF8, 0, string, -1, NULL, 0); - wchar_t *ret = malloc(len * sizeof(wchar_t)); - MultiByteToWideChar(CP_UTF8, 0, string, -1, ret, len); - return ret; - } - return NULL; -} - static int control(struct ao *ao, enum aocontrol cmd, void *arg) { struct wasapi_state *state = (struct wasapi_state *)ao->priv; @@ -297,7 +288,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg) return CONTROL_OK; case AOCONTROL_UPDATE_STREAM_TITLE: { MP_VERBOSE(state, "Updating stream title to \"%s\"\n", (char*)arg); - wchar_t *title = utf8_to_wstring((char*)arg); + wchar_t *title = mp_from_utf8(NULL, (char*)arg); wchar_t *tmp = NULL; @@ -311,7 +302,7 @@ static int control(struct ao *ao, enum aocontrol cmd, void *arg) IAudioSessionControl_GetDisplayName(state->pSessionControlProxy, &tmp); } while (lstrcmpW(title, tmp)); SAFE_RELEASE(tmp, CoTaskMemFree(tmp)); - free(title); + talloc_free(title); return CONTROL_OK; } -- cgit v1.2.3