Mercurial > pidgin.yaz
diff src/gtksound.c @ 10074:2e225cd35615
[gaim-migrate @ 11054]
This is some sound related stuff. Add a "No Sounds" sound method for those
who like their Gaim to be really really quiet, switched to using the prefs API
for mute_sounds, added a Mute Sounds entry to the buddy list tools menu so
those without a system tray icon can use this, and kill off old child sound
processes (any older than 15 seconds) which should fix bug #1034209.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 02 Oct 2004 18:53:19 +0000 |
parents | 4a15962c344a |
children | 9fdbfe832fac |
line wrap: on
line diff
--- a/src/gtksound.c Sat Oct 02 15:28:03 2004 +0000 +++ b/src/gtksound.c Sat Oct 02 18:53:19 2004 +0000 @@ -53,10 +53,9 @@ char *def; }; - +#define PLAY_SOUND_TIMEOUT 15000 static gboolean mute_login_sounds = FALSE; -static gboolean mute_sounds = FALSE; static gboolean sound_initialized = FALSE; static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { @@ -109,6 +108,7 @@ gaim_prefs_add_bool("/gaim/gtk/sound/enabled/pounce_default", TRUE); gaim_prefs_add_string("/gaim/gtk/sound/file/pounce_default", ""); gaim_prefs_add_bool("/gaim/gtk/sound/conv_focus", TRUE); + gaim_prefs_add_bool("/gaim/gtk/sound/mute", FALSE); gaim_prefs_add_string("/gaim/gtk/sound/command", ""); gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic"); @@ -131,6 +131,23 @@ sound_initialized = FALSE; } +#if defined(USE_NAS_AUDIO) || defined(USE_AO) +gboolean expire_old_child(gpointer data) +{ + int ret; + pid_t pid = GPOINTER_TO_INT(data); + + ret = waitpid(pid, NULL, WNOHANG | WUNTRACED); + + if(ret == 0) { + if(kill(pid, SIGKILL) < 0) + gaim_debug_error("gtksound", "Killing process %d failed (%s)\n", pid, strerror(errno)); + } + + return FALSE; /* do not run again */ +} +#endif + static void gaim_gtk_sound_play_file(const char *filename) { const char *method; @@ -144,12 +161,14 @@ if (!sound_initialized) gaim_prefs_trigger_callback("/gaim/gtk/sound/method"); - if (mute_sounds) + if (gaim_prefs_get_bool("/gaim/gtk/sound/mute")) return; method = gaim_prefs_get_string("/gaim/gtk/sound/method"); - if (!strcmp(method, "beep")) { + if (!strcmp(method, "none")) { + return; + } else if (!strcmp(method, "beep")) { gdk_beep(); return; } @@ -256,6 +275,8 @@ ao_shutdown(); #endif /* USE_AO */ _exit(0); + } else { + gaim_timeout_add(PLAY_SOUND_TIMEOUT, expire_old_child, GINT_TO_POINTER(pid)); } #else /* USE_NAS_AUDIO || USE_AO */ gdk_beep(); @@ -364,16 +385,6 @@ #endif /* USE_NAS_AUDIO */ -void gaim_gtk_sound_set_mute(gboolean mute) -{ - mute_sounds = mute; -} - -gboolean gaim_gtk_sound_get_mute() -{ - return mute_sounds; -} - void gaim_gtk_sound_set_login_mute(gboolean mute) { mute_login_sounds = mute;