From 65398a1596eff5d78d04ad39ee694c52db53f833 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 2 May 2016 11:30:43 +0300 Subject: [PATCH] directsoundsrc: Convert Windows strings to UTF8 before comparing against UTF8 strings The device name and descriptions returned are in the locale encoding, not UTF8. Our device name property is in UTF8 though, so we need to convert. https://bugzilla.gnome.org/show_bug.cgi?id=756948 --- sys/directsound/gstdirectsoundsrc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sys/directsound/gstdirectsoundsrc.c b/sys/directsound/gstdirectsoundsrc.c index e23486d..8687e86 100644 --- a/sys/directsound/gstdirectsoundsrc.c +++ b/sys/directsound/gstdirectsoundsrc.c @@ -339,19 +339,34 @@ gst_directsound_enum_callback (GUID * pGUID, TCHAR * strDesc, TCHAR * strDrvName, VOID * pContext) { GstDirectSoundSrc *dsoundsrc = GST_DIRECTSOUND_SRC (pContext); + gchar *driver, *description; + + description = g_locale_to_utf8 (strDesc, -1, NULL, NULL, NULL); + if (!description) { + GST_ERROR_OBJECT (dsoundsrc, + "Failed to convert description from locale encoding to UTF8"); + return TRUE; + } + + driver = g_locale_to_utf8 (strDrvName, -1, NULL, NULL, NULL); if (pGUID && dsoundsrc && dsoundsrc->device_name && - !g_strcmp0 (dsoundsrc->device_name, strDesc)) { + !g_strcmp0 (dsoundsrc->device_name, description)) { g_free (dsoundsrc->device_guid); dsoundsrc->device_guid = (GUID *) g_malloc0 (sizeof (GUID)); memcpy (dsoundsrc->device_guid, pGUID, sizeof (GUID)); GST_INFO_OBJECT (dsoundsrc, "found the requested audio device :%s", dsoundsrc->device_name); + g_free (description); + g_free (driver); return FALSE; } GST_INFO_OBJECT (dsoundsrc, "sound device names: %s, %s, requested device:%s", - strDesc, strDrvName, dsoundsrc->device_name); + description, driver, dsoundsrc->device_name); + + g_free (description); + g_free (driver); return TRUE; } -- 2.7.4