From: Sebastian Dröge Date: Mon, 2 May 2016 08:30:43 +0000 (+0300) Subject: directsoundsrc: Convert Windows strings to UTF8 before comparing against UTF8 strings X-Git-Tag: 1.19.3~507^2~6647 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=65398a1596eff5d78d04ad39ee694c52db53f833;p=platform%2Fupstream%2Fgstreamer.git 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 --- 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; }