From bc1169e9793229a749b5c5878a4bab1d5c423768 Mon Sep 17 00:00:00 2001 From: TingPing Date: Sat, 27 Apr 2013 20:02:27 -0300 Subject: Use canberra for files --- src/common/text.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/common/text.c b/src/common/text.c index 4fad92ec..98f0bfba 100644 --- a/src/common/text.c +++ b/src/common/text.c @@ -47,6 +47,10 @@ #include #endif +#ifdef USE_LIBCANBERRA +#include +#endif + struct pevt_stage1 { int len; @@ -2198,28 +2202,6 @@ sound_beep (session *sess) } } -static char * -sound_find_command (void) -{ - /* some sensible unix players. You're bound to have one of them */ - static const char * const progs[] = {"play", "paplay", "aplay", "esdplay", "artsplay", NULL}; - char *cmd; - int i = 0; - - if (prefs.hex_sound_command[0]) - return g_strdup (prefs.hex_sound_command); - - while (progs[i]) - { - cmd = g_find_program_in_path (progs[i]); - if (cmd) - return cmd; - i++; - } - - return NULL; -} - void sound_play (const char *file, gboolean quiet) { @@ -2227,8 +2209,12 @@ sound_play (const char *file, gboolean quiet) char *wavfile; #ifndef WIN32 char *cmd; +#ifdef USE_LIBCANBERRA + ca_context *con; +#endif #endif + /* the pevents GUI editor triggers this after removing a soundfile */ if (!file[0]) { @@ -2254,7 +2240,17 @@ sound_play (const char *file, gboolean quiet) #ifdef WIN32 PlaySound (wavfile, NULL, SND_NODEFAULT|SND_FILENAME|SND_ASYNC); #else - cmd = sound_find_command (); +#ifdef USE_LIBCANBERRA + ca_context_create (&con); + /* TODO: Volume setting? */ + if (ca_context_play (con, 0, + CA_PROP_MEDIA_FILENAME, wavfile, NULL) == 0) + { + g_free (wavfile); + return; + } +#endif + cmd = g_find_program_in_path ("play"); if (cmd) { -- cgit 1.4.1