| Summary: | String conversion of XAudio2 and DirectSound backends are UCS-2BE | ||
|---|---|---|---|
| Product: | SDL | Reporter: | norfanin |
| Component: | audio | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | Windows (All) | ||
| Attachments: |
patch as attachment
patch as attachment again one last time |
||
|
Description
norfanin
2013-08-21 23:42:10 UTC
Uhm. Can't attach anything. It errors with "The file you are trying to attach is empty, does not exist, or you don't have permission to read it." Let's hope the comment section survives this.
diff -r adacc93b5213 src/audio/directsound/SDL_directsound.c
--- a/src/audio/directsound/SDL_directsound.c Wed Aug 21 12:12:04 2013 -0700
+++ b/src/audio/directsound/SDL_directsound.c Thu Aug 22 01:30:20 2013 +0200
@@ -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) {
diff -r adacc93b5213 src/audio/xaudio2/SDL_xaudio2.c
--- a/src/audio/xaudio2/SDL_xaudio2.c Wed Aug 21 12:12:04 2013 -0700
+++ b/src/audio/xaudio2/SDL_xaudio2.c Thu Aug 22 01:30:20 2013 +0200
@@ -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);
Created attachment 1301 [details]
patch as attachment
Testing attachments...
--ryan.
Created attachment 1302 [details]
patch as attachment again
Ignore me.
Created attachment 1303 [details]
one last time
ignore this too
(In reply to norfanin from comment #1) > Uhm. Can't attach anything. It errors with "The file you are trying to > attach is empty, does not exist, or you don't have permission to read it." Weird, don't know why that happened. If it happens to you again, email me directly and we'll figure it out. Looking at the actual patch now. --ryan. This is now http://hg.libsdl.org/SDL/rev/c64896ddeeae, thanks! --ryan. |