From e209e55e5921e9ccaf1f713aa5010ddf1cb1c2d8 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Sat, 13 Sep 2014 00:23:44 -0700 Subject: Use PlaySoundW to play sounds on Windows. Fixes #1133 --- src/common/text.c | 9 ++++++++- src/fe-gtk/fe-gtk.c | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/common/text.c b/src/common/text.c index 22467c99..329ef37b 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -2300,7 +2300,14 @@ sound_play (const char *file, gboolean quiet) if (g_access (wavfile, R_OK) == 0) { #ifdef WIN32 - PlaySound (wavfile, NULL, SND_NODEFAULT|SND_FILENAME|SND_ASYNC); + gunichar2 *wavfile_utf16 = g_utf8_to_utf16 (wavfile, -1, NULL, NULL, NULL); + + if (wavfile_utf16 != NULL) + { + PlaySoundW (wavfile_utf16, NULL, SND_NODEFAULT | SND_FILENAME | SND_ASYNC); + + g_free (wavfile_utf16); + } #else #ifdef USE_LIBCANBERRA if (ca_con == NULL) diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index 3c97a904..4b7d916f 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -656,10 +656,11 @@ void fe_beep (session *sess) { #ifdef WIN32 - if (!PlaySound ("Notification.IM", NULL, SND_ALIAS|SND_ASYNC)) + /* Play the "Instant Message Notification" system sound + */ + if (!PlaySoundW (L"Notification.IM", NULL, SND_ALIAS | SND_ASYNC)) { - /* This is really just a fallback attempt, may or may not work on new Windows releases, especially on x64. - * You should set up the "Instant Message Notification" system sound instead, supported on Vista and up. + /* The user does not have the "Instant Message Notification" sound set. Fall back to system beep. */ Beep (1000, 50); } -- cgit 1.4.1