Use PlaySoundW to play sounds on Windows.

Fixes #1133
This commit is contained in:
Arnavion 2014-09-13 00:23:44 -07:00
parent ad2300f236
commit e209e55e59
2 changed files with 12 additions and 4 deletions

View File

@ -2300,7 +2300,14 @@ sound_play (const char *file, gboolean quiet)
if (g_access (wavfile, R_OK) == 0) if (g_access (wavfile, R_OK) == 0)
{ {
#ifdef WIN32 #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 #else
#ifdef USE_LIBCANBERRA #ifdef USE_LIBCANBERRA
if (ca_con == NULL) if (ca_con == NULL)

View File

@ -656,10 +656,11 @@ void
fe_beep (session *sess) fe_beep (session *sess)
{ {
#ifdef WIN32 #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. /* The user does not have the "Instant Message Notification" sound set. Fall back to system beep.
* You should set up the "Instant Message Notification" system sound instead, supported on Vista and up.
*/ */
Beep (1000, 50); Beep (1000, 50);
} }