diff -r 7c0420c7ac81 -r b6c9e5dd95d1 pidgin/gtksound.c --- a/pidgin/gtksound.c Sun Jun 02 14:00:50 2013 +0200 +++ b/pidgin/gtksound.c Sun Jun 02 22:17:12 2013 +0200 @@ -424,6 +424,18 @@ } #endif +#ifdef _WIN32 +static void +pidgin_sound_play_file_win32(const char *filename) +{ + wchar_t *wc_filename = g_utf8_to_utf16(filename, + -1, NULL, NULL, NULL); + if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) + purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); + g_free(wc_filename); +} +#endif /* _WIN32 */ + static void pidgin_sound_play_file(const char *filename) { @@ -447,6 +459,12 @@ gdk_beep(); return; } +#ifdef _WIN32 + else if (!strcmp(method, "playsoundw")) { + pidgin_sound_play_file_win32(filename); + return; + } +#endif /* _WIN32 */ if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { purple_debug_error("gtksound", "sound file (%s) does not exist.\n", filename); @@ -507,11 +525,22 @@ if (gst_init_failed) /* Perhaps do gdk_beep instead? */ return; volume = (float)(CLAMP(purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"),0,100)) / 50; +#ifdef _WIN32 + if (!strcmp(method, "automatic")) { + sink = gst_element_factory_make("directsoundsink", "sink"); + if (sink == NULL) + sink = gst_element_factory_make("waveformsink", "sink"); + if (sink == NULL) + sink = gst_element_factory_make("gconfaudiosink", "sink"); + } else if (!strcmp(method, "directsound")) { + sink = gst_element_factory_make("directsoundsink", "sink"); + } else if (!strcmp(method, "waveform")) { + sink = gst_element_factory_make("waveformsink", "sink"); + } +#else if (!strcmp(method, "automatic")) { sink = gst_element_factory_make("gconfaudiosink", "sink"); - } -#ifndef _WIN32 - else if (!strcmp(method, "esd")) { + } else if (!strcmp(method, "esd")) { sink = gst_element_factory_make("esdsink", "sink"); } else if (!strcmp(method, "alsa")) { sink = gst_element_factory_make("alsasink", "sink"); @@ -537,7 +566,12 @@ return; } +#ifdef _WIN32 + uri = g_strdup_printf("file:///%s", filename); + g_strdelimit(uri, "\\", '/'); +#else uri = g_strdup_printf("file://%s", filename); +#endif g_object_set(G_OBJECT(play), "uri", uri, "volume", volume, @@ -556,15 +590,7 @@ #ifndef _WIN32 gdk_beep(); #else /* _WIN32 */ - purple_debug_info("sound", "Playing %s\n", filename); - - { - wchar_t *wc_filename = g_utf8_to_utf16(filename, - -1, NULL, NULL, NULL); - if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME)) - purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n"); - g_free(wc_filename); - } + pidgin_sound_play_file_win32(filename); #endif /* _WIN32 */ #endif /* USE_GSTREAMER */