XAudio2/DirectSound: Use the usual Windows string convert (thanks, Norfanin!).
authorRyan C. Gordon <icculus@icculus.org>
Thu, 22 Aug 2013 13:32:27 -0400
changeset 7689 c64896ddeeae
parent 7688 00042bf02d17
child 7690 76d7b6007a64
XAudio2/DirectSound: Use the usual Windows string convert (thanks, Norfanin!).
src/audio/directsound/SDL_directsound.c
src/audio/xaudio2/SDL_xaudio2.c
--- a/src/audio/directsound/SDL_directsound.c	Thu Aug 22 13:00:05 2013 -0400
+++ b/src/audio/directsound/SDL_directsound.c	Thu Aug 22 13:32:27 2013 -0400
@@ -91,14 +91,6 @@
     return loaded;
 }
 
-static __inline__ char *
-utf16_to_utf8(const WCHAR *S)
-{
-    /* !!! FIXME: this should be UTF-16, not UCS-2! */
-    return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S),
-                            (SDL_wcslen(S)+1)*sizeof(WCHAR));
-}
-
 static int
 SetDSerror(const char *function, int code)
 {
@@ -158,7 +150,7 @@
 {
     SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data;
     if (guid != NULL) {  /* skip default device */
-        char *str = utf16_to_utf8(desc);
+        char *str = WIN_StringToUTF8(desc);
         if (str != NULL) {
             addfn(str);
             SDL_free(str);  /* addfn() makes a copy of this string. */
@@ -439,7 +431,7 @@
 {
     if (guid != NULL) {  /* skip the default device. */
         FindDevGUIDData *data = (FindDevGUIDData *) _data;
-        char *str = utf16_to_utf8(desc);
+        char *str = WIN_StringToUTF8(desc);
         const int match = (SDL_strcmp(str, data->devname) == 0);
         SDL_free(str);
         if (match) {
--- a/src/audio/xaudio2/SDL_xaudio2.c	Thu Aug 22 13:00:05 2013 -0400
+++ b/src/audio/xaudio2/SDL_xaudio2.c	Thu Aug 22 13:32:27 2013 -0400
@@ -60,14 +60,6 @@
 };
 
 
-static __inline__ char *
-utf16_to_utf8(const WCHAR *S)
-{
-    /* !!! FIXME: this should be UTF-16, not UCS-2! */
-    return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S),
-                            (SDL_wcslen(S)+1)*sizeof(WCHAR));
-}
-
 static void
 XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn)
 {
@@ -90,7 +82,7 @@
     for (i = 0; i < devcount; i++) {
         XAUDIO2_DEVICE_DETAILS details;
         if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
-            char *str = utf16_to_utf8(details.DisplayName);
+            char *str = WIN_StringToUTF8(details.DisplayName);
             if (str != NULL) {
                 addfn(str);
                 SDL_free(str);  /* addfn() made a copy of the string. */
@@ -265,7 +257,7 @@
         for (i = 0; i < devcount; i++) {
             XAUDIO2_DEVICE_DETAILS details;
             if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) {
-                char *str = utf16_to_utf8(details.DisplayName);
+                char *str = WIN_StringToUTF8(details.DisplayName);
                 if (str != NULL) {
                     const int match = (SDL_strcmp(str, devname) == 0);
                     SDL_free(str);