pidgin/gtksound.c

changeset 33948
b6c9e5dd95d1
parent 33509
60647bc63acc
child 34293
c1da9082287f
child 34622
753f46dd000f
equal deleted inserted replaced
33947:7c0420c7ac81 33948:b6c9e5dd95d1
422 422
423 return FALSE; 423 return FALSE;
424 } 424 }
425 #endif 425 #endif
426 426
427 #ifdef _WIN32
428 static void
429 pidgin_sound_play_file_win32(const char *filename)
430 {
431 wchar_t *wc_filename = g_utf8_to_utf16(filename,
432 -1, NULL, NULL, NULL);
433 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME))
434 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
435 g_free(wc_filename);
436 }
437 #endif /* _WIN32 */
438
427 static void 439 static void
428 pidgin_sound_play_file(const char *filename) 440 pidgin_sound_play_file(const char *filename)
429 { 441 {
430 const char *method; 442 const char *method;
431 #ifdef USE_GSTREAMER 443 #ifdef USE_GSTREAMER
445 return; 457 return;
446 } else if (!strcmp(method, "beep")) { 458 } else if (!strcmp(method, "beep")) {
447 gdk_beep(); 459 gdk_beep();
448 return; 460 return;
449 } 461 }
462 #ifdef _WIN32
463 else if (!strcmp(method, "playsoundw")) {
464 pidgin_sound_play_file_win32(filename);
465 return;
466 }
467 #endif /* _WIN32 */
450 468
451 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { 469 if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
452 purple_debug_error("gtksound", "sound file (%s) does not exist.\n", filename); 470 purple_debug_error("gtksound", "sound file (%s) does not exist.\n", filename);
453 return; 471 return;
454 } 472 }
505 523
506 #ifdef USE_GSTREAMER 524 #ifdef USE_GSTREAMER
507 if (gst_init_failed) /* Perhaps do gdk_beep instead? */ 525 if (gst_init_failed) /* Perhaps do gdk_beep instead? */
508 return; 526 return;
509 volume = (float)(CLAMP(purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"),0,100)) / 50; 527 volume = (float)(CLAMP(purple_prefs_get_int(PIDGIN_PREFS_ROOT "/sound/volume"),0,100)) / 50;
528 #ifdef _WIN32
529 if (!strcmp(method, "automatic")) {
530 sink = gst_element_factory_make("directsoundsink", "sink");
531 if (sink == NULL)
532 sink = gst_element_factory_make("waveformsink", "sink");
533 if (sink == NULL)
534 sink = gst_element_factory_make("gconfaudiosink", "sink");
535 } else if (!strcmp(method, "directsound")) {
536 sink = gst_element_factory_make("directsoundsink", "sink");
537 } else if (!strcmp(method, "waveform")) {
538 sink = gst_element_factory_make("waveformsink", "sink");
539 }
540 #else
510 if (!strcmp(method, "automatic")) { 541 if (!strcmp(method, "automatic")) {
511 sink = gst_element_factory_make("gconfaudiosink", "sink"); 542 sink = gst_element_factory_make("gconfaudiosink", "sink");
512 } 543 } else if (!strcmp(method, "esd")) {
513 #ifndef _WIN32
514 else if (!strcmp(method, "esd")) {
515 sink = gst_element_factory_make("esdsink", "sink"); 544 sink = gst_element_factory_make("esdsink", "sink");
516 } else if (!strcmp(method, "alsa")) { 545 } else if (!strcmp(method, "alsa")) {
517 sink = gst_element_factory_make("alsasink", "sink"); 546 sink = gst_element_factory_make("alsasink", "sink");
518 } 547 }
519 #endif 548 #endif
535 564
536 if (play == NULL) { 565 if (play == NULL) {
537 return; 566 return;
538 } 567 }
539 568
569 #ifdef _WIN32
570 uri = g_strdup_printf("file:///%s", filename);
571 g_strdelimit(uri, "\\", '/');
572 #else
540 uri = g_strdup_printf("file://%s", filename); 573 uri = g_strdup_printf("file://%s", filename);
574 #endif
541 575
542 g_object_set(G_OBJECT(play), "uri", uri, 576 g_object_set(G_OBJECT(play), "uri", uri,
543 "volume", volume, 577 "volume", volume,
544 "audio-sink", sink, NULL); 578 "audio-sink", sink, NULL);
545 579
554 #else /* #ifdef USE_GSTREAMER */ 588 #else /* #ifdef USE_GSTREAMER */
555 589
556 #ifndef _WIN32 590 #ifndef _WIN32
557 gdk_beep(); 591 gdk_beep();
558 #else /* _WIN32 */ 592 #else /* _WIN32 */
559 purple_debug_info("sound", "Playing %s\n", filename); 593 pidgin_sound_play_file_win32(filename);
560
561 {
562 wchar_t *wc_filename = g_utf8_to_utf16(filename,
563 -1, NULL, NULL, NULL);
564 if (!PlaySoundW(wc_filename, NULL, SND_ASYNC | SND_FILENAME))
565 purple_debug(PURPLE_DEBUG_ERROR, "sound", "Error playing sound.\n");
566 g_free(wc_filename);
567 }
568 #endif /* _WIN32 */ 594 #endif /* _WIN32 */
569 595
570 #endif /* USE_GSTREAMER */ 596 #endif /* USE_GSTREAMER */
571 } 597 }
572 598

mercurial