# HG changeset patch # User Nathan Walp # Date 1044755735 0 # Node ID 9df99116840a8232148f2f51fa4e45cb9039a3f2 # Parent eb32b3acef97df4832c2f787b55fa205b17ff58b [gaim-migrate @ 4842] This is the new sound subsystem Lots of stuff got renamed, and everything sound-wise is documented. Gaim now uses libaudiofile and libao to play sounds. Lots of ugly hacks were removed, and now we support playing audio through anything that libao will support. If you need to (you shouldn't) you can force libao to use a specific output driver, by putting a line into ~/.libao like: default_driver=esd You shouldn't need to do this, libao is pretty good at figuring out what driver to use. committer: Tailor Script diff -r eb32b3acef97 -r 9df99116840a acinclude.m4 --- a/acinclude.m4 Sun Feb 09 00:47:57 2003 +0000 +++ b/acinclude.m4 Sun Feb 09 01:55:35 2003 +0000 @@ -798,3 +798,119 @@ AC_SUBST(GTK_LIBS) rm -f conf.gtktest ]) + +dnl This is XIPH_PATH_AO renamed to GAIM_PATH_AO to prevent conflicts. +dnl It's a long story. --elb + +# ao.m4 +# Configure paths for libao +# Jack Moffitt 10-21-2000 +# Shamelessly stolen from Owen Taylor and Manish Singh + +dnl GAIM_PATH_AO([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl Test for libao, and define AO_CFLAGS and AO_LIBS +dnl +AC_DEFUN(GAIM_PATH_AO, +[dnl +dnl Get the cflags and libraries +dnl +AC_ARG_WITH(ao,[ --with-ao=PFX Prefix where libao is installed (optional)], ao_prefix="$withval", ao_prefix="") +AC_ARG_WITH(ao-libraries,[ --with-ao-libraries=DIR Directory where libao library is installed (optional)], ao_libraries="$withval", ao_libraries="") +AC_ARG_WITH(ao-includes,[ --with-ao-includes=DIR Directory where libao header files are installed (optional)], ao_includes="$withval", ao_includes="") +AC_ARG_ENABLE(aotest, [ --disable-aotest Do not try to compile and run a test ao program],, enable_aotest=yes) + + + if test "x$ao_libraries" != "x" ; then + AO_LIBS="-L$ao_libraries" + elif test "x$ao_prefix" != "x"; then + AO_LIBS="-L$ao_prefix/lib" + elif test "x$prefix" != "xNONE"; then + AO_LIBS="-L$prefix/lib" + fi + + if test "x$ao_includes" != "x" ; then + AO_CFLAGS="-I$ao_includes" + elif test "x$ao_prefix" != "x"; then + AO_CFLAGS="-I$ao_prefix/include" + elif test "x$prefix" != "xNONE"; then + AO_CFLAGS="-I$prefix/include" + fi + + # see where dl* and friends live + AC_CHECK_FUNCS(dlopen, [AO_DL_LIBS=""], [ + AC_CHECK_LIB(dl, dlopen, [AO_DL_LIBS="-ldl"], [ + AC_MSG_WARN([could not find dlopen() needed by libao sound drivers + your system may not be supported.]) + ]) + ]) + + AO_LIBS="$AO_LIBS -lao $AO_DL_LIBS" + + AC_MSG_CHECKING(for ao) + no_ao="" + + + if test "x$enable_aotest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $AO_CFLAGS" + LIBS="$LIBS $AO_LIBS" +dnl +dnl Now check if the installed ao is sufficiently new. +dnl + rm -f conf.aotest + AC_TRY_RUN([ +#include +#include +#include +#include + +int main () +{ + system("touch conf.aotest"); + return 0; +} + +],, no_ao=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + + if test "x$no_ao" = "x" ; then + AC_MSG_RESULT(yes) + ifelse([$1], , :, [$1]) + else + AC_MSG_RESULT(no) + if test -f conf.aotest ; then + : + else + echo "*** Could not run ao test program, checking why..." + CFLAGS="$CFLAGS $AO_CFLAGS" + LIBS="$LIBS $AO_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding ao or finding the wrong" + echo "*** version of ao. If it is not finding ao, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means ao was incorrectly installed" + echo "*** or that you have moved ao since it was installed." ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + AO_CFLAGS="" + AO_LIBS="" + ifelse([$2], , :, [$2]) + fi + AC_SUBST(AO_CFLAGS) + AC_SUBST(AO_LIBS) + rm -f conf.aotest +]) diff -r eb32b3acef97 -r 9df99116840a configure.ac --- a/configure.ac Sun Feb 09 00:47:57 2003 +0000 +++ b/configure.ac Sun Feb 09 01:55:35 2003 +0000 @@ -122,10 +122,7 @@ AC_DEFINE_UNQUOTED(STATIC_PROTO_INIT, $extern_init void static_proto_init() { $load_proto }, [Loads static protocol plugin module initialization functions.]) -AC_ARG_ENABLE(esd, [ --disable-esd Turn off ESD (default=auto)],,enable_esd=yes) -AC_ARG_ENABLE(nas, [ --enable-nas Enable NAS (Network Audio System) support],,enable_nas=no) -AC_ARG_ENABLE(artsc, [ --disable-artsc Turn off ArtsC (default=auto)],,enable_artsc=yes) - +AC_ARG_ENABLE(audio, [ --disable-audio compile without libao/libaudiofile for sound playing],,enable_audio=yes) AC_ARG_ENABLE(plugins, [ --disable-plugins compile without plugin support],,enable_plugins=yes) AC_ARG_ENABLE(perl, [ --disable-perl compile without perl scripting],,enable_perl=yes) AC_ARG_ENABLE(gtkspell, [ --disable-gtkspell compile without GtkSpell automatic spell checking],,enable_gtkspell=yes) @@ -274,45 +271,22 @@ fi fi -if test "$enable_nas" = yes ; then - AC_DEFINE(NAS_SOUND, 1, [Define if we have NAS sound support.]) - SOUND_LIBS="-laudio -lXt" -fi -if test "$enable_esd" = yes ; then - AM_PATH_GESD - if test "$no_esd" != yes ; then - old_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $ESD_CFLAGS" - AC_TRY_COMPILE(,[#include ], - [ - AC_DEFINE(ESD_SOUND, 1, [Define if we have ESD sound support.]) - SOUND_LIBS="$SOUND_LIBS $ESD_LIBS" - ],[ - enable_esd=no - CFLAGS="$old_CFLAGS" - ]) +if test "$enable_audio" = yes ; then + GAIM_PATH_AO(found_ao_lib=true) + + AM_PATH_AUDIOFILE([0.2.0], found_af_lib=true) + + if test "$found_ao_lib" = "true" -a "$found_af_lib" = "true"; then + SOUND_LIBS="$AO_LIBS $AUDIOFILE_LIBS" + AC_SUBST(SOUND_LIBS) + AC_DEFINE(USE_AO, 1, [Define if we're using libao and libaudiofile for sound playing]) + enable_audio=yes else - enable_esd=no - fi + enable_audio=no + fi +else + enable_audio=no fi -if test "x$enable_artsc" = "xyes"; then - AM_PATH_ARTSC - if test "x$no_artsc" != "xyes" ; then - old_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $ARTSC_CFLAGS" - AC_TRY_COMPILE(,[#include ], - [ - AC_DEFINE(ARTSC_SOUND, 1, [Define if we have artsc sound support.]) - SOUND_LIBS="$SOUND_LIBS $ARTSC_LIBS" - ],[ - enable_artsc=no - CFLAGS="$old_CFLAGS" - ]) - else - enable_artsc=no - fi -fi -AC_SUBST(SOUND_LIBS) if test "$ac_cv_cygwin" = yes ; then LDADD="$LDADD -static" @@ -443,20 +417,16 @@ echo Build Protocol Plugins........ : $enable_prpls echo Protocols to link statically.. : $STATIC_PRPLS echo -echo UI Library.................... : GTK 2.0 +echo UI Library.................... : GTK 2.x echo echo Build with Plugin support..... : $enable_plugins echo Build with Perl support....... : $enable_perl -echo -echo Build with GtkSpell............: $enable_gtkspell +echo Build with Audio support...... : $enable_audio +echo Build with GtkSpell support... : $enable_gtkspell echo echo Use XScreenSaver Extension.... : $enable_xss echo Use X Session Management...... : $enable_sm echo -echo Build with ESD................ : $enable_esd -echo Build with NAS................ : $enable_nas -echo Build with ArtsC.............. : $enable_artsc -echo echo Print debugging messages...... : $enable_debug echo eval eval echo Gaim will be installed in $bindir. diff -r eb32b3acef97 -r 9df99116840a configure.in --- a/configure.in Sun Feb 09 00:47:57 2003 +0000 +++ b/configure.in Sun Feb 09 01:55:35 2003 +0000 @@ -112,16 +112,13 @@ AC_DEFINE_UNQUOTED(STATIC_PROTO_INIT, $extern_init void static_proto_init() { $load_proto }, [Loads static protocol plugin module initialization functions.]) -AC_ARG_ENABLE(esd, [ --disable-esd Turn off ESD (default=auto)],,enable_esd=yes) -AC_ARG_ENABLE(nas, [ --enable-nas Enable NAS (Network Audio System) support],,enable_nas=no) -AC_ARG_ENABLE(artsc, [ --disable-artsc Turn off ArtsC (default=auto)],,enable_artsc=yes) - +AC_ARG_ENABLE(audio, [ --disable-audio compile without libao/libaudiofile for sound playing],,enable_audio=yes) AC_ARG_ENABLE(plugins, [ --disable-plugins compile without plugin support],,enable_plugins=yes) AC_ARG_ENABLE(perl, [ --disable-perl compile without perl scripting],,enable_perl=yes) AC_ARG_ENABLE(gtkspell, [ --disable-gtkspell compile without GtkSpell automatic spell checking],,enable_gtkspell=yes) - AC_ARG_ENABLE(debug, [ --enable-debug compile with debugging support],,enable_debug=no) AC_ARG_ENABLE(screensaver, [ --disable-screensaver compile without X screensaver extension],,enable_xss=yes) +AC_ARG_ENABLE(sm, [ --disable-sm compile without X session management support],,enable_sm=yes) AC_ARG_WITH(krb4, [ --with-krb4=PREFIX Compile Zephyr plugin with Kerberos 4 support],kerberos="$withval",kerberos="no") if test "$enable_debug" = yes ; then @@ -248,45 +245,22 @@ fi fi -if test "$enable_nas" = yes ; then - AC_DEFINE(NAS_SOUND, 1, [Define if we have NAS sound support.]) - SOUND_LIBS="-laudio -lXt" -fi -if test "$enable_esd" = yes ; then - AM_PATH_GESD - if test "$no_esd" != yes ; then - old_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $ESD_CFLAGS" - AC_TRY_COMPILE(,[#include ], - [ - AC_DEFINE(ESD_SOUND, 1, [Define if we have ESD sound support.]) - SOUND_LIBS="$SOUND_LIBS $ESD_LIBS" - ],[ - enable_esd=no - CFLAGS="$old_CFLAGS" - ]) +if test "$enable_audio" = yes ; then + GAIM_PATH_AO(found_ao_lib=true) + + AM_PATH_AUDIOFILE([0.2.0], found_af_lib=true) + + if test "$found_ao_lib" = "true" -a "$found_af_lib" = "true"; then + SOUND_LIBS="$AO_LIBS $AUDIOFILE_LIBS" + AC_SUBST(SOUND_LIBS) + AC_DEFINE(USE_AO, 1, [Define if we're using libao and libaudiofile for sound playing]) + enable_audio=yes else - enable_esd=no - fi + enable_audio=no + fi +else + enable_audio=no fi -if test "x$enable_artsc" = "xyes"; then - AM_PATH_ARTSC - if test "x$no_artsc" != "xyes" ; then - old_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $ARTSC_CFLAGS" - AC_TRY_COMPILE(,[#include ], - [ - AC_DEFINE(ARTSC_SOUND, 1, [Define if we have artsc sound support.]) - SOUND_LIBS="$SOUND_LIBS $ARTSC_LIBS" - ],[ - enable_artsc=no - CFLAGS="$old_CFLAGS" - ]) - else - enable_artsc=no - fi -fi -AC_SUBST(SOUND_LIBS) if test "$ac_cv_cygwin" = yes ; then LDADD="$LDADD -static" @@ -419,18 +393,15 @@ echo Build Protocol Plugins........ : $enable_prpls echo Protocols to link statically.. : $STATIC_PRPLS echo -echo UI Library.................... : GTK 2.0 +echo UI Library.................... : GTK 2.x echo echo Build with Plugin support..... : $enable_plugins echo Build with Perl support....... : $enable_perl -echo -echo Build with GtkSpell............: $enable_gtkspell +echo Build with Audio support...... : $enable_audio +echo Build with GtkSpell support... : $enable_gtkspell echo echo Use XScreenSaver Extension.... : $enable_xss -echo -echo Build with ESD................ : $enable_esd -echo Build with NAS................ : $enable_nas -echo Build with ArtsC.............. : $enable_artsc +echo Use X Session Management...... : $enable_sm echo echo Print debugging messages...... : $enable_debug echo diff -r eb32b3acef97 -r 9df99116840a plugins/docklet/docklet.c --- a/plugins/docklet/docklet.c Sun Feb 09 00:47:57 2003 +0000 +++ b/plugins/docklet/docklet.c Sun Feb 09 01:55:35 2003 +0000 @@ -30,6 +30,7 @@ /* includes */ #include #include "gaim.h" +#include "sound.h" #include "eggtrayicon.h" #ifndef GAIM_PLUGINS @@ -60,7 +61,7 @@ static enum docklet_status icon; static void docklet_toggle_mute(GtkWidget *toggle, void *data) { - mute_sounds = GTK_CHECK_MENU_ITEM(toggle)->active; + gaim_sound_set_mute(GTK_CHECK_MENU_ITEM(toggle)->active); } static void docklet_toggle_queue(GtkWidget *widget, void *data) { @@ -149,7 +150,7 @@ gaim_separator(menu); entry = gtk_check_menu_item_new_with_label(_("Mute Sounds")); - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), mute_sounds); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(entry), gaim_sound_get_mute()); g_signal_connect(G_OBJECT(entry), "toggled", G_CALLBACK(docklet_toggle_mute), NULL); gtk_menu_append(GTK_MENU(menu), entry); diff -r eb32b3acef97 -r 9df99116840a src/Makefile.am --- a/src/Makefile.am Sun Feb 09 00:47:57 2003 +0000 +++ b/src/Makefile.am Sun Feb 09 01:55:35 2003 +0000 @@ -55,6 +55,7 @@ session.c \ socket.c \ sound.c \ + sound.h \ stock.c \ stock.h \ themes.c \ diff -r eb32b3acef97 -r 9df99116840a src/buddy.c --- a/src/buddy.c Sun Feb 09 00:47:57 2003 +0000 +++ b/src/buddy.c Sun Feb 09 01:55:35 2003 +0000 @@ -45,6 +45,7 @@ #include #include #include "prpl.h" +#include "sound.h" #include "gaim.h" #ifdef _WIN32 @@ -1459,9 +1460,9 @@ } if (b->options & OPT_POUNCE_SOUND) { if (strlen(b->sound)) - play_file(b->sound); + gaim_sound_play_file(b->sound); else - play_sound(SND_POUNCE_DEFAULT); + gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); } if (!(b->options & OPT_POUNCE_SAVE)) @@ -2214,7 +2215,7 @@ } if (b->present == 1) { if (bs->sound != 2) - play_sound(SND_BUDDY_ARRIVE); + gaim_sound_play_event(GAIM_SOUND_BUDDY_ARRIVE); if (blist_options & OPT_BLIST_POPUP) gdk_window_show(blist->window); pm = gdk_pixmap_create_from_xpm_d(blist->window, &bm, @@ -2276,7 +2277,7 @@ buddies that have already signed off */ if (bs->sound != 1) - play_sound(SND_BUDDY_LEAVE); + gaim_sound_play_event(GAIM_SOUND_BUDDY_LEAVE); if (blist_options & OPT_BLIST_POPUP) gdk_window_show(blist->window); bs->connlist = g_slist_remove(bs->connlist, gc); diff -r eb32b3acef97 -r 9df99116840a src/gaim.h --- a/src/gaim.h Sun Feb 09 00:47:57 2003 +0000 +++ b/src/gaim.h Sun Feb 09 01:55:35 2003 +0000 @@ -312,30 +312,6 @@ #define OPT_SOUND_ESD 0x00010000 #define OPT_SOUND_CMD 0x00020000 #define OPT_SOUND_CHAT_NICK 0x00040000 -/* remember to also change the struct in sound.c */ - -#define SND_BUDDY_ARRIVE 0 -#define SND_BUDDY_LEAVE 1 -#define SND_RECEIVE 2 -#define SND_FIRST_RECEIVE 3 -#define SND_SEND 4 -#define SND_CHAT_JOIN 5 -#define SND_CHAT_LEAVE 6 -#define SND_CHAT_YOU_SAY 7 -#define SND_CHAT_SAY 8 -#define SND_POUNCE_DEFAULT 9 -#define SND_CHAT_NICK 10 -#define NUM_SOUNDS 11 - -extern char *sound_file[NUM_SOUNDS]; - -/* global sound struct */ -struct sound_struct { - char *label; - guint opt; - char *def; -}; -extern struct sound_struct sounds[]; extern guint away_options; #define OPT_AWAY_DISCARD 0x00000001 @@ -355,7 +331,6 @@ extern GSList *message_queue; extern GSList *unread_message_queue; extern GSList *away_time_queue; -extern char sound_cmd[2048]; extern char web_command[2048]; extern struct save_pos blist_pos; extern struct window_size conv_size, buddy_chat_size; diff -r eb32b3acef97 -r 9df99116840a src/gaimrc.c --- a/src/gaimrc.c Sun Feb 09 00:47:57 2003 +0000 +++ b/src/gaimrc.c Sun Feb 09 01:55:35 2003 +0000 @@ -38,6 +38,7 @@ #include "gaim.h" #include "prpl.h" #include "proxy.h" +#include "sound.h" #ifdef _WIN32 #include "win32dep.h" @@ -72,10 +73,6 @@ struct save_pos blist_pos; struct window_size conv_size, buddy_chat_size; char web_command[2048] = ""; -char *sound_file[NUM_SOUNDS]; -#ifndef _WIN32 -char sound_cmd[2048]; -#endif struct parse { char option[256]; @@ -802,8 +799,8 @@ } /* this is where we do bugs and compatibility stuff */ - if (!(sound_options & (OPT_SOUND_BEEP | OPT_SOUND_ESD | OPT_SOUND_NORMAL | OPT_SOUND_NAS | OPT_SOUND_ARTSC | OPT_SOUND_CMD))) - sound_options |= OPT_SOUND_ESD | OPT_SOUND_NORMAL | OPT_SOUND_NAS | OPT_SOUND_ARTSC; + if (!(sound_options & (OPT_SOUND_BEEP | OPT_SOUND_NORMAL | OPT_SOUND_CMD))) + sound_options |= OPT_SOUND_NORMAL; if (conv_size.width == 0 && conv_size.height == 0 && @@ -904,11 +901,9 @@ buf[0] = 0; - for (i = 0; i < NUM_SOUNDS; i++) - sound_file[i] = NULL; -#ifndef _WIN32 - sound_cmd[0] = 0; -#endif + for(i=0; ioption, "sound_cmd")) { - g_snprintf(sound_cmd, sizeof(sound_cmd), "%s", p->value[0]); - } else + gaim_sound_set_command(p->value[0]); + } else #endif if (!strncmp(p->option, "sound", strlen("sound"))) { i = p->option[strlen("sound")] - 'A'; if (p->value[0][0]) - sound_file[i] = g_strdup(p->value[0]); + gaim_sound_set_event_file(i, p->value[0]); } } } @@ -934,23 +929,30 @@ static void gaimrc_write_sounds(FILE *f) { int i; + char *cmd; fprintf(f, "sound_files {\n"); - for (i = 0; i < NUM_SOUNDS; i++) - if (sound_file[i]) { + for (i = 0; i < GAIM_NUM_SOUNDS; i++) { + char *file = gaim_sound_get_event_file(i); + if (file) { #ifndef _WIN32 - fprintf(f, "\tsound%c { %s }\n", i + 'A', sound_file[i]); + fprintf(f, "\tsound%c { %s }\n", i + 'A', file); #else /* Make sure windows dir speparators arn't swallowed up when path is read back in from resource file */ - char* tmp=wgaim_escape_dirsep(sound_file[i]); + char* tmp=wgaim_escape_dirsep(file); fprintf(f, "\tsound%c { %s }\n", i + 'A', tmp); g_free(tmp); #endif } else fprintf(f, "\tsound%c { }\n", i + 'A'); + } #ifndef _WIN32 - fprintf(f, "\tsound_cmd { %s }\n", sound_cmd); + cmd = gaim_sound_get_command(); + if(cmd) + fprintf(f, "\tsound_cmd { %s }\n", cmd); + else + fprintf(f, "\tsound_cmd { }\n"); #endif fprintf(f, "}\n"); } @@ -1218,8 +1220,9 @@ away_options = OPT_AWAY_BACK_ON_IM; - for (i = 0; i < NUM_SOUNDS; i++) - sound_file[i] = NULL; + for (i = 0; i < GAIM_NUM_SOUNDS; i++) + gaim_sound_set_event_file(i, NULL); + font_options = 0; /* Enable all of the sound players that might be available. The first available one will be used. */ @@ -1229,10 +1232,7 @@ OPT_SOUND_RECV | OPT_SOUND_SEND | OPT_SOUND_SILENT_SIGNON | - OPT_SOUND_NORMAL | - OPT_SOUND_NAS | - OPT_SOUND_ARTSC | - OPT_SOUND_ESD; + OPT_SOUND_NORMAL; #ifdef USE_SCREENSAVER report_idle = IDLE_SCREENSAVER; diff -r eb32b3acef97 -r 9df99116840a src/gtkconv.c --- a/src/gtkconv.c Sun Feb 09 00:47:57 2003 +0000 +++ b/src/gtkconv.c Sun Feb 09 01:55:35 2003 +0000 @@ -43,6 +43,7 @@ #include "prpl.h" #include "gtkimhtml.h" #include "dnd-hints.h" +#include "sound.h" #ifdef _WIN32 #include "win32dep.h" @@ -3619,13 +3620,13 @@ if (gtkconv->u.im->a_virgin && (sound_options & OPT_SOUND_FIRST_RCV)) { - play_sound(SND_FIRST_RECEIVE); + gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); } else - play_sound(SND_RECEIVE); + gaim_sound_play_event(GAIM_SOUND_RECEIVE); } else { - play_sound(SND_SEND); + gaim_sound_play_event(GAIM_SOUND_SEND); } } @@ -3645,12 +3646,12 @@ /* Play a sound, if specified in prefs. */ if (gtkconv->make_sound) { if (!(flags & WFLAG_WHISPER) && (flags & WFLAG_SEND)) - play_sound(SND_CHAT_YOU_SAY); + gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); else if (flags & WFLAG_RECV) { if ((flags & WFLAG_NICK) && (sound_options & OPT_SOUND_CHAT_NICK)) - play_sound(SND_CHAT_NICK); + gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); else - play_sound(SND_CHAT_SAY); + gaim_sound_play_event(GAIM_SOUND_CHAT_SAY); } } @@ -3944,7 +3945,7 @@ gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); if (gtkconv->make_sound) - play_sound(SND_CHAT_JOIN); + gaim_sound_play_event(GAIM_SOUND_CHAT_JOIN); pos = g_list_index(gaim_chat_get_users(chat), user); @@ -4063,7 +4064,7 @@ gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); if (gtkconv->make_sound) - play_sound(SND_CHAT_LEAVE); + gaim_sound_play_event(GAIM_SOUND_CHAT_LEAVE); } static void diff -r eb32b3acef97 -r 9df99116840a src/main.c --- a/src/main.c Sun Feb 09 00:47:57 2003 +0000 +++ b/src/main.c Sun Feb 09 01:55:35 2003 +0000 @@ -47,6 +47,7 @@ #include #include #include "prpl.h" +#include "sound.h" #include "gaim.h" #include "gaim-socket.h" #if HAVE_SIGNAL_H @@ -71,6 +72,7 @@ GtkWidget *mainwindow = NULL; + int opt_away = 0; char *opt_away_arg = NULL; char *opt_rcfile_arg = NULL; @@ -133,12 +135,11 @@ gtk_main_quit(); } -static int snd_tmout; -int logins_not_muted = 1; +static guint snd_tmout = 0; static gboolean sound_timeout(gpointer data) { - logins_not_muted = 1; - g_source_remove(snd_tmout); + gaim_sound_set_login_mute(FALSE); + snd_tmout = 0; return FALSE; } @@ -148,7 +149,10 @@ void gaim_setup(struct gaim_connection *gc) { if ((sound_options & OPT_SOUND_LOGIN) && (sound_options & OPT_SOUND_SILENT_SIGNON)) { - logins_not_muted = 0; + if(snd_tmout) { + g_source_remove(snd_tmout); + } + gaim_sound_set_login_mute(TRUE); snd_tmout = g_timeout_add(10000, sound_timeout, NULL); } } @@ -526,6 +530,8 @@ setup_stock(); + gaim_sound_init(); + #ifndef _WIN32 /* use the nice PNG icon for all the windows */ icon_path = g_build_filename(DATADIR, "pixmaps", "gaim.png", NULL); @@ -899,7 +905,7 @@ gtk_main(); core_quit(); - /* don't need ui_quit here because ui doesn't create anything */ + gaim_sound_quit(); #ifdef _WIN32 wgaim_cleanup(); #endif diff -r eb32b3acef97 -r 9df99116840a src/perl.c --- a/src/perl.c Sun Feb 09 00:47:57 2003 +0000 +++ b/src/perl.c Sun Feb 09 01:55:35 2003 +0000 @@ -81,6 +81,7 @@ #endif #include "gaim.h" #include "prpl.h" +#include "sound.h" struct perlscript { char *name; @@ -1183,7 +1184,7 @@ id = SvIV(ST(0)); - play_sound(id); + gaim_sound_play_event(id); XSRETURN_EMPTY; } diff -r eb32b3acef97 -r 9df99116840a src/prefs.c --- a/src/prefs.c Sun Feb 09 00:47:57 2003 +0000 +++ b/src/prefs.c Sun Feb 09 01:55:35 2003 +0000 @@ -38,6 +38,7 @@ #include "gaim.h" #include "prpl.h" #include "proxy.h" +#include "sound.h" #ifdef _WIN32 #include "win32dep.h" @@ -957,7 +958,7 @@ #ifndef _WIN32 static gint sound_cmd_yeah(GtkEntry *entry, gpointer d) { - g_snprintf(sound_cmd, sizeof(sound_cmd), "%s", gtk_entry_get_text(GTK_ENTRY(sndcmd))); + gaim_sound_set_command(gtk_entry_get_text(GTK_ENTRY(sndcmd))); return TRUE; } #endif @@ -970,6 +971,7 @@ GtkWidget *dd; GtkWidget *hbox; GtkWidget *label; + char *cmd; #endif ret = gtk_vbox_new(FALSE, 18); @@ -984,19 +986,12 @@ #ifndef _WIN32 vbox = make_frame (ret, _("Sound Method")); dd = gaim_dropdown(vbox, _("_Method"), &sound_options, OPT_SOUND_BEEP | - OPT_SOUND_ESD | OPT_SOUND_ARTSC | OPT_SOUND_NAS | OPT_SOUND_NORMAL | + OPT_SOUND_NORMAL | OPT_SOUND_CMD, _("Console beep"), OPT_SOUND_BEEP, -#ifdef ESD_SOUND - "ESD", OPT_SOUND_ESD, +#ifdef USE_AO + _("Automatic"), OPT_SOUND_NORMAL, #endif -#ifdef ARTSC_SOUND - "ArtsC", OPT_SOUND_ARTSC, -#endif -#ifdef NAS_SOUND - "NAS", OPT_SOUND_NAS, -#endif - _("Internal"), OPT_SOUND_NORMAL, _("Command"), OPT_SOUND_CMD, NULL); gtk_size_group_add_widget(sg, dd); gtk_misc_set_alignment(GTK_MISC(dd), 0, 0); @@ -1015,7 +1010,9 @@ gtk_label_set_mnemonic_widget(GTK_LABEL(label), sndcmd); gtk_entry_set_editable(GTK_ENTRY(sndcmd), TRUE); - gtk_entry_set_text(GTK_ENTRY(sndcmd), sound_cmd); + cmd = gaim_sound_get_command(); + if(cmd) + gtk_entry_set_text(GTK_ENTRY(sndcmd), cmd); gtk_widget_set_size_request(sndcmd, 75, -1); gtk_widget_set_sensitive(sndcmd, (sound_options & OPT_SOUND_CMD)); @@ -1343,8 +1340,8 @@ gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, 2, &soundnum, -1); - sound_options ^= sounds[soundnum].opt; - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, sound_options & sounds[soundnum].opt, -1); + sound_options ^= gaim_sound_get_event_option(soundnum); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, sound_options & gaim_sound_get_event_option(soundnum), -1); gtk_tree_path_free(path); } @@ -1354,9 +1351,9 @@ guint32 tmp_sound = sound_options; if (!(sound_options & OPT_SOUND_WHEN_AWAY)) sound_options ^= OPT_SOUND_WHEN_AWAY; - if (!(sound_options & sounds[sound_row_sel].opt)) - sound_options ^= sounds[sound_row_sel].opt; - play_sound(sound_row_sel); + if (!(sound_options & gaim_sound_get_event_option(sound_row_sel))) + sound_options ^= gaim_sound_get_event_option(sound_row_sel); + gaim_sound_play_event(sound_row_sel); sound_options = tmp_sound; } @@ -1364,10 +1361,7 @@ static void reset_sound(GtkWidget *button, gpointer i_am_also_NULL) { /* This just resets a sound file back to default */ - if (sound_file[sound_row_sel]) { - g_free(sound_file[sound_row_sel]); - sound_file[sound_row_sel] = NULL; - } + gaim_sound_set_event_file(sound_row_sel, NULL); gtk_entry_set_text(GTK_ENTRY(sound_entry), "(default)"); } @@ -1397,22 +1391,18 @@ if (file_is_dir(file, sounddialog)) return; - /* Let's just be safe */ - if (sound_file[snd]) - g_free(sound_file[snd]); - /* Set it -- and forget it */ - sound_file[snd] = g_strdup(file); + gaim_sound_set_event_file(snd, file); /* Set our text entry */ - gtk_entry_set_text(GTK_ENTRY(sound_entry), sound_file[snd]); + gtk_entry_set_text(GTK_ENTRY(sound_entry), file); /* Close the window! It's getting cold in here! */ close_sounddialog(NULL, sounddialog); if (last_sound_dir) g_free(last_sound_dir); - last_sound_dir = g_dirname(sound_file[snd]); + last_sound_dir = g_dirname(file); } static void sel_sound(GtkWidget *button, gpointer being_NULL_is_fun) @@ -1447,13 +1437,15 @@ static void prefs_sound_sel (GtkTreeSelection *sel, GtkTreeModel *model) { GtkTreeIter iter; GValue val = { 0, }; + char *file; if (! gtk_tree_selection_get_selected (sel, &model, &iter)) return; gtk_tree_model_get_value (model, &iter, 2, &val); sound_row_sel = g_value_get_uint(&val); + file = gaim_sound_get_event_file(sound_row_sel); if (sound_entry) - gtk_entry_set_text(GTK_ENTRY(sound_entry), sound_file[sound_row_sel] ? sound_file[sound_row_sel] : "(default)"); + gtk_entry_set_text(GTK_ENTRY(sound_entry), file ? file : "(default)"); g_value_unset (&val); if (sounddialog) gtk_widget_destroy(sounddialog); @@ -1472,6 +1464,7 @@ GtkTreeSelection *sel; GtkTreePath *path; int j; + char *file; ret = gtk_vbox_new(FALSE, 18); gtk_container_set_border_width (GTK_CONTAINER (ret), 12); @@ -1483,14 +1476,15 @@ gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0); event_store = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT); - for (j=0; j < NUM_SOUNDS; j++) { - if (sounds[j].opt == 0) + for (j=0; j < GAIM_NUM_SOUNDS; j++) { + guint opt = gaim_sound_get_event_option(j); + if (opt == 0) continue; gtk_list_store_append (event_store, &iter); gtk_list_store_set(event_store, &iter, - 0, sound_options & sounds[j].opt, - 1, gettext(sounds[j].label), + 0, sound_options & opt, + 1, gettext(gaim_sound_get_event_label(j)), 2, j, -1); } @@ -1525,7 +1519,8 @@ hbox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(ret), hbox, FALSE, FALSE, 0); sound_entry = gtk_entry_new(); - gtk_entry_set_text(GTK_ENTRY(sound_entry), sound_file[0] ? sound_file[0] : "(default)"); + file = gaim_sound_get_event_file(0); + gtk_entry_set_text(GTK_ENTRY(sound_entry), file ? file : "(default)"); gtk_entry_set_editable(GTK_ENTRY(sound_entry), FALSE); gtk_box_pack_start(GTK_BOX(hbox), sound_entry, FALSE, FALSE, 5); diff -r eb32b3acef97 -r 9df99116840a src/sound.c --- a/src/sound.c Sun Feb 09 00:47:57 2003 +0000 +++ b/src/sound.c Sun Feb 09 01:55:35 2003 +0000 @@ -1,7 +1,7 @@ /* * gaim * - * Copyright (C) 1998-1999, Mark Spencer + * Copyright (C) 2003, Nathan Walp * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,31 +40,38 @@ #include #include -#ifdef ESD_SOUND -#include -#endif - -#ifdef ARTSC_SOUND -#include -#endif - -#ifdef NAS_SOUND -#include