# HG changeset patch # User Matti Hamalainen # Date 1206451006 -7200 # Node ID 2fa51f742f25feee4b7bb98c25d40d8cc4dd5759 # Parent 6a26dabad84f77805f9f04da6eaecd311cb8900c# Parent 695e1c91be36570a1ce15ea126e370f5342c03ce Automated merge with ssh://hg.atheme.org//hg/audacious diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/bmpconfig.c --- a/src/audacious/bmpconfig.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/bmpconfig.c Tue Mar 25 15:16:46 2008 +0200 @@ -23,6 +23,14 @@ * Audacious or using our public API to be a derived work. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef USE_SRC +# include +#endif + #include "effect.h" #include "general.h" #include "playback.h" diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/main.c --- a/src/audacious/main.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/main.c Tue Mar 25 15:16:46 2008 +0200 @@ -366,10 +366,33 @@ } static void -handle_cmd_line_options(AudCmdLineOpt * options, - gboolean remote) +parse_cmd_line_options(gint *argc, gchar ***argv) { - gchar **filenames = options->filenames; + GOptionContext *context; + GError *error = NULL; + + memset(&options, '\0', sizeof(AudCmdLineOpt)); + options.session = -1; + + context = g_option_context_new(_("- play multimedia files")); + g_option_context_add_main_entries(context, cmd_entries, PACKAGE_NAME); + g_option_context_add_group(context, gtk_get_option_group(FALSE)); + g_option_context_add_group(context, egg_sm_client_get_option_group()); + g_option_context_parse(context, argc, argv, &error); + if (!g_option_context_parse(context, argc, argv, &error)) + /* checking for MacOS X -psn_0_* errors*/ + if (error->message && !g_strrstr(error->message,"-psn_0_")) + { + g_printerr(_("%s: %s\nTry `%s --help' for more information.\n"), + (*argv)[0], error->message, (*argv)[0]); + exit(EXIT_FAILURE); + } +} + +static void +handle_cmd_line_options() +{ + gchar **filenames = options.filenames; #ifdef USE_DBUS DBusGProxy *session = audacious_get_dbus_proxy(); gboolean is_running = audacious_remote_is_running(session); @@ -377,7 +400,7 @@ gboolean is_running = FALSE; #endif - if (options->version) + if (options.version) { dump_version(); exit(EXIT_SUCCESS); @@ -415,7 +438,7 @@ fns = g_list_reverse(fns); - if (options->load_skins) + if (options.load_skins) { audacious_remote_set_skin(session, filenames[0]); skin_install_skin(filenames[0]); @@ -424,13 +447,13 @@ { GList *i; - if (options->enqueue_to_temp) + if (options.enqueue_to_temp) audacious_remote_playlist_enqueue_to_temp(session, filenames[0]); - if (options->enqueue && options->play) + if (options.enqueue && options.play) pos = audacious_remote_get_playlist_length(session); - if (!options->enqueue) + if (!options.enqueue) { audacious_remote_playlist_clear(session); audacious_remote_stop(session); @@ -439,11 +462,11 @@ for (i = fns; i != NULL; i = i->next) audacious_remote_playlist_add_url_string(session, i->data); - if (options->enqueue && options->play && + if (options.enqueue && options.play && audacious_remote_get_playlist_length(session) > pos) audacious_remote_set_playlist_pos(session, pos); - if (!options->enqueue) + if (!options.enqueue) audacious_remote_play(session); } @@ -453,31 +476,31 @@ g_strfreev(filenames); } /* filename */ - if (options->rew) + if (options.rew) audacious_remote_playlist_prev(session); - if (options->play) + if (options.play) audacious_remote_play(session); - if (options->pause) + if (options.pause) audacious_remote_pause(session); - if (options->stop) + if (options.stop) audacious_remote_stop(session); - if (options->fwd) + if (options.fwd) audacious_remote_playlist_next(session); - if (options->play_pause) + if (options.play_pause) audacious_remote_play_pause(session); - if (options->show_jump_box) + if (options.show_jump_box) audacious_remote_show_jtf_box(session); - if (options->mainwin) + if (options.mainwin) audacious_remote_main_win_toggle(session, TRUE); - if (options->activate) + if (options.activate) audacious_remote_activate(session); exit(EXIT_SUCCESS); @@ -515,13 +538,13 @@ fns = g_list_reverse(fns); { - if (options->enqueue_to_temp) + if (options.enqueue_to_temp) drct_pl_enqueue_to_temp(filenames[0]); - if (options->enqueue && options->play) + if (options.enqueue && options.play) pos = drct_pl_get_length(); - if (!options->enqueue) + if (!options.enqueue) { drct_pl_clear(); drct_stop(); @@ -529,11 +552,11 @@ drct_pl_add(fns); - if (options->enqueue && options->play && + if (options.enqueue && options.play && drct_pl_get_length() > pos) drct_pl_set_pos(pos); - if (!options->enqueue) + if (!options.enqueue) g_idle_add(aud_start_playback, NULL); } @@ -543,35 +566,35 @@ g_strfreev(filenames); } /* filename */ - if (options->rew) + if (options.rew) drct_pl_prev(); - if (options->play) + if (options.play) drct_play(); - if (options->pause) + if (options.pause) drct_pause(); - if (options->stop) + if (options.stop) drct_stop(); - if (options->fwd) + if (options.fwd) drct_pl_next(); - if (options->play_pause) { + if (options.play_pause) { if (drct_get_paused()) drct_play(); else drct_pause(); } - if (options->show_jump_box) + if (options.show_jump_box) drct_jtf_show(); - if (options->mainwin) + if (options.mainwin) drct_main_win_toggle(TRUE); - if (options->activate) + if (options.activate) drct_activate(); } /* !is_running */ } @@ -639,18 +662,13 @@ gint main(gint argc, gchar ** argv) { - gboolean gtk_init_check_ok; Playlist *playlist; - GOptionContext *context; - GError *error = NULL; /* glib-2.13.0 requires g_thread_init() to be called before all other GLib functions */ g_thread_init(NULL); if (!g_thread_supported()) { - g_printerr(_("Sorry, threads isn't supported on your platform.\n\n" - "If you're on a libc5 based linux system and installed Glib & GTK+ before you\n" - "installed LinuxThreads you need to recompile Glib & GTK+.\n")); + g_printerr(_("Sorry, threads aren't supported on your platform.\n")); exit(EXIT_FAILURE); } @@ -674,68 +692,40 @@ mutex_scan = g_mutex_new(); gtk_rc_add_default_file(bmp_paths[BMP_PATH_GTKRC_FILE]); - memset(&options, '\0', sizeof(AudCmdLineOpt)); - options.session = -1; - - context = g_option_context_new(_("- play multimedia files")); - g_option_context_add_main_entries(context, cmd_entries, PACKAGE_NAME); - g_option_context_add_group(context, gtk_get_option_group(FALSE)); - g_option_context_add_group(context, egg_sm_client_get_option_group()); - g_option_context_parse(context, &argc, &argv, &error); - - - gtk_init_check_ok = gtk_init_check(&argc, &argv); - - - if (error != NULL) - { - /* checking for MacOS X -psn_0_* errors*/ - if(error->message && !g_strrstr(error->message,"-psn_0_")) { - g_printerr(_("%s: %s\nTry `%s --help' for more information.\n"), - argv[0], error->message, argv[0]); - exit(EXIT_FAILURE); - } - - if (!gtk_init_check_ok && argc < 2) { - /* GTK check failed, and no arguments passed to indicate - that user is intending to only remote control a running - session */ - g_printerr(_("%s: Unable to open display, exiting.\n"), argv[0]); - exit(EXIT_FAILURE); - } - - handle_cmd_line_options(&options, TRUE); - - /* we could be running headless, so GTK probably wont matter */ - if (options.headless == FALSE) - exit(EXIT_SUCCESS); - } + parse_cmd_line_options(&argc, &argv); if (options.no_log == FALSE) bmp_setup_logger(); - signal_handlers_init(); + if (!gtk_init_check(&argc, &argv) && options.headless == FALSE) { + /* GTK check failed, and no arguments passed to indicate + that user is intending to only remote control a running + session */ + g_printerr(_("%s: Unable to open display, exiting.\n"), argv[0]); + exit(EXIT_FAILURE); + } g_random_set_seed(time(NULL)); SAD_dither_init_rand((gint32)time(NULL)); bmp_config_load(); + signal_handlers_init(); mowgli_init(); if (options.headless == FALSE) { - ui_main_check_theme_engine(); + ui_main_check_theme_engine(); - /* register icons in stock - NOTE: should be called before UIManager */ - register_aud_stock_icons(); + /* register icons in stock + NOTE: should be called before UIManager */ + register_aud_stock_icons(); - /* UIManager - NOTE: this needs to be called before plugin init, cause - plugin init functions may want to add custom menu entries */ - ui_manager_init(); - ui_manager_create_menus(); + /* UIManager + NOTE: this needs to be called before plugin init, cause + plugin init functions may want to add custom menu entries */ + ui_manager_init(); + ui_manager_create_menus(); } plugin_system_init(); @@ -746,7 +736,12 @@ playlist_load(playlist, bmp_paths[BMP_PATH_PLAYLIST_FILE]); playlist_set_position(playlist, cfg.playlist_position); - handle_cmd_line_options(&options, TRUE); + /* Load extra playlists */ + if (!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist, + playlist, NULL)) + g_warning("Could not load extra playlists\n"); + + handle_cmd_line_options(); #ifdef USE_DBUS init_dbus(); @@ -767,22 +762,13 @@ } GDK_THREADS_ENTER(); - } - - /* Load extra playlists */ - if(!dir_foreach(bmp_paths[BMP_PATH_PLAYLISTS_DIR], load_extra_playlist, - playlist, NULL)) { - g_warning("Could not load extra playlists\n"); - } - /* this needs to be called after all 3 windows are created and - * input plugins are setup'ed - * but not if we're running headless --nenolod - */ - mainwin_setup_menus(); + /* this needs to be called after all 3 windows are created and + * input plugins are setup'ed + * but not if we're running headless --nenolod + */ + mainwin_setup_menus(); - if (options.headless == FALSE) - { ui_main_set_initial_volume(); /* FIXME: delayed, because it deals directly with the plugin diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/output.c --- a/src/audacious/output.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/output.c Tue Mar 25 15:16:46 2008 +0200 @@ -289,6 +289,9 @@ { plugin_set_current((Plugin *)op); op->close_audio(); + op_state.fmt = 0; + op_state.rate = 0; + op_state.nch = 0; } plugin_set_current((Plugin *)op); diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/playback.c --- a/src/audacious/playback.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/playback.c Tue Mar 25 15:16:46 2008 +0200 @@ -40,39 +40,17 @@ #include #include "configdb.h" - #include "eventqueue.h" #include "hook.h" #include "input.h" -#include "main.h" #include "output.h" #include "playlist.h" #include "pluginenum.h" -#include "skin.h" -#include "ui_equalizer.h" -#include "ui_main.h" -#include "ui_skinned_playstatus.h" #include "util.h" -#include "visualization.h" #include "playback.h" #include "playback_evlisteners.h" -static gint song_info_timeout_source = 0; -static gint update_vis_timeout_source = 0; - -/* XXX: there has to be a better way than polling here! */ -static gboolean -playback_update_vis_func(gpointer unused) -{ - if (!playback_get_playing()) - return FALSE; - - input_update_vis(playback_get_time()); - - return TRUE; -} - static gint playback_set_pb_ready(InputPlayback *playback) { @@ -194,10 +172,6 @@ if (playback_get_playing()) playback_stop(); - ui_vis_clear_data(mainwin_vis); - ui_svis_clear_data(mainwin_svis); - mainwin_disable_seekbar(); - entry = playlist_get_entry_to_play(playlist); g_return_if_fail(entry != NULL); #ifdef USE_DBUS @@ -205,38 +179,7 @@ #endif playback_play_file(entry); -// if (playback_get_time() != -1) { - equalizerwin_load_auto_preset(entry->filename); - input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, - cfg.equalizer_bands); - output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, - cfg.equalizer_bands); -// } - playlist_check_pos_current(playlist); - mainwin_update_song_info(); - - /* FIXME: use g_timeout_add_seconds when glib-2.14 is required */ - song_info_timeout_source = g_timeout_add(1000, - (GSourceFunc) mainwin_update_song_info, NULL); - - update_vis_timeout_source = g_timeout_add(10, - (GSourceFunc) playback_update_vis_func, NULL); - - if (cfg.player_shaded) { - gtk_widget_show(mainwin_stime_min); - gtk_widget_show(mainwin_stime_sec); - gtk_widget_show(mainwin_sposition); - } else { - gtk_widget_show(mainwin_minus_num); - gtk_widget_show(mainwin_10min_num); - gtk_widget_show(mainwin_min_num); - gtk_widget_show(mainwin_10sec_num); - gtk_widget_show(mainwin_sec_num); - gtk_widget_show(mainwin_position); - } - - vis_playback_start(); hook_call("playback begin", entry); } @@ -265,19 +208,12 @@ else hook_call("playback unpause", NULL); - g_return_if_fail(mainwin_playstatus != NULL); - - if (ip_data.paused) { - ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE); #ifdef USE_DBUS + if (ip_data.paused) mpris_emit_status_change(mpris, MPRIS_STATUS_PAUSE); -#endif - } else { - ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); -#ifdef USE_DBUS + else mpris_emit_status_change(mpris, MPRIS_STATUS_PLAY); #endif - } } void @@ -309,10 +245,10 @@ playback->set_pb_change(playback); if (playback->plugin->stop) - { - plugin_set_current((Plugin *)(playback->plugin)); + { + plugin_set_current((Plugin *)(playback->plugin)); playback->plugin->stop(playback); - } + } if (playback->thread != NULL) { @@ -320,7 +256,6 @@ playback->thread = NULL; } - free_vis_data(); ip_data.paused = FALSE; playback_free(playback); @@ -332,13 +267,7 @@ ip_data.playing = FALSE; - if (song_info_timeout_source) - g_source_remove(song_info_timeout_source); - - vis_playback_stop(); - - g_return_if_fail(mainwin_playstatus != NULL); - ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE); + hook_call("playback stop", NULL); } static void @@ -443,9 +372,6 @@ return FALSE; } - if (cfg.random_skin_on_play) - skin_set_random_skin(); - if (!entry->decoder) { ProbeResult *pr = input_check_file(entry->filename, FALSE); @@ -484,6 +410,8 @@ mpris_emit_status_change(mpris, MPRIS_STATUS_PLAY); #endif + hook_call("playback play file", NULL); + return TRUE; } @@ -524,7 +452,6 @@ plugin_set_current((Plugin *)(playback->plugin)); playback->plugin->seek(playback, time); playback->set_pb_change(playback); - free_vis_data(); if (restore_pause) { diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/playlist.c --- a/src/audacious/playlist.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/playlist.c Tue Mar 25 15:16:46 2008 +0200 @@ -60,7 +60,6 @@ #include "util.h" #include "configdb.h" #include "vfs.h" -#include "ui_equalizer.h" #include "playback.h" #include "playlist.h" #include "playlist_container.h" diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/playlist_evlisteners.c --- a/src/audacious/playlist_evlisteners.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/playlist_evlisteners.c Tue Mar 25 15:16:46 2008 +0200 @@ -20,23 +20,10 @@ #include #include "hook.h" -#include "playback.h" #include "playlist.h" -#include "playlist_evmessages.h" -#include "playlist_evlisteners.h" - -#include "ui_main.h" #include "ui_playlist.h" -static void -playlist_evlistener_playlist_info_change(gpointer hook_data, gpointer user_data) -{ - PlaylistEventInfoChange *msg = (PlaylistEventInfoChange *) hook_data; - - mainwin_set_song_info(msg->bitrate, msg->samplerate, msg->channels); - - g_free(msg); -} +#include "playlist_evlisteners.h" static void playlist_evlistener_playlistwin_update_list(gpointer hook_data, gpointer user_data) @@ -48,6 +35,5 @@ void playlist_evlistener_init(void) { - hook_associate("playlist info change", playlist_evlistener_playlist_info_change, NULL); hook_associate("playlistwin update list", playlist_evlistener_playlistwin_update_list, NULL); } diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/ui_main_evlisteners.c --- a/src/audacious/ui_main_evlisteners.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/ui_main_evlisteners.c Tue Mar 25 15:16:46 2008 +0200 @@ -26,12 +26,30 @@ #include "playlist.h" #include "playlist_evmessages.h" #include "playlist_evlisteners.h" +#include "visualization.h" #include "ui_main.h" #include "ui_equalizer.h" +#include "ui_skinned_playstatus.h" #include "ui_skinned_textbox.h" #include "ui_playlist.h" +static gint song_info_timeout_source = 0; +static gint update_vis_timeout_source = 0; + +/* XXX: there has to be a better way than polling here! */ +/* also: where should this function go? should it stay here? --mf0102 */ +static gboolean +update_vis_func(gpointer unused) +{ + if (!playback_get_playing()) + return FALSE; + + input_update_vis(playback_get_time()); + + return TRUE; +} + static void ui_main_evlistener_title_change(gpointer hook_data, gpointer user_data) { @@ -76,6 +94,94 @@ playback_initiate(); } +static void +ui_main_evlistener_playback_begin(gpointer hook_data, gpointer user_data) +{ + PlaylistEntry *entry = (PlaylistEntry*)hook_data; + g_return_if_fail(entry != NULL); + + equalizerwin_load_auto_preset(entry->filename); + input_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, + cfg.equalizer_bands); + output_set_eq(cfg.equalizer_active, cfg.equalizer_preamp, + cfg.equalizer_bands); + + ui_vis_clear_data(mainwin_vis); + ui_svis_clear_data(mainwin_svis); + mainwin_disable_seekbar(); + mainwin_update_song_info(); + + if (cfg.player_shaded) { + gtk_widget_show(mainwin_stime_min); + gtk_widget_show(mainwin_stime_sec); + gtk_widget_show(mainwin_sposition); + } else { + gtk_widget_show(mainwin_minus_num); + gtk_widget_show(mainwin_10min_num); + gtk_widget_show(mainwin_min_num); + gtk_widget_show(mainwin_10sec_num); + gtk_widget_show(mainwin_sec_num); + gtk_widget_show(mainwin_position); + } + + song_info_timeout_source = + g_timeout_add_seconds(1, (GSourceFunc) mainwin_update_song_info, NULL); + + update_vis_timeout_source = + g_timeout_add(10, (GSourceFunc) update_vis_func, NULL); + + vis_playback_start(); + + ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); +} + +static void +ui_main_evlistener_playback_stop(gpointer hook_data, gpointer user_data) +{ + if (song_info_timeout_source) + g_source_remove(song_info_timeout_source); + + vis_playback_stop(); + free_vis_data(); + + ui_skinned_playstatus_set_buffering(mainwin_playstatus, FALSE); +} + +static void +ui_main_evlistener_playback_pause(gpointer hook_data, gpointer user_data) +{ + ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PAUSE); +} + +static void +ui_main_evlistener_playback_unpause(gpointer hook_data, gpointer user_data) +{ + ui_skinned_playstatus_set_status(mainwin_playstatus, STATUS_PLAY); +} + +static void +ui_main_evlistener_playback_seek(gpointer hook_data, gpointer user_data) +{ + free_vis_data(); +} + +static void +ui_main_evlistener_playback_play_file(gpointer hook_data, gpointer user_data) +{ + if (cfg.random_skin_on_play) + skin_set_random_skin(); +} + +static void +ui_main_evlistener_playlist_info_change(gpointer hook_data, gpointer user_data) +{ + PlaylistEventInfoChange *msg = (PlaylistEventInfoChange *) hook_data; + + mainwin_set_song_info(msg->bitrate, msg->samplerate, msg->channels); + + g_free(msg); +} + void ui_main_evlistener_init(void) { @@ -83,5 +189,12 @@ hook_associate("hide seekbar", ui_main_evlistener_hide_seekbar, NULL); hook_associate("volume set", ui_main_evlistener_volume_change, NULL); hook_associate("playback initiate", ui_main_evlistener_playback_initiate, NULL); + hook_associate("playback begin", ui_main_evlistener_playback_begin, NULL); + hook_associate("playback stop", ui_main_evlistener_playback_stop, NULL); + hook_associate("playback pause", ui_main_evlistener_playback_pause, NULL); + hook_associate("playback unpause", ui_main_evlistener_playback_unpause, NULL); + hook_associate("playback seek", ui_main_evlistener_playback_seek, NULL); + hook_associate("playback play file", ui_main_evlistener_playback_play_file, NULL); + hook_associate("playlist info change", ui_main_evlistener_playlist_info_change, NULL); } diff -r 6a26dabad84f -r 2fa51f742f25 src/audacious/visualization.c --- a/src/audacious/visualization.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/audacious/visualization.c Tue Mar 25 15:16:46 2008 +0200 @@ -74,10 +74,10 @@ for (node = vp_data.enabled_list; node; node = g_list_next(node)) { vp = node->data; if (vp->playback_start) - { + { plugin_set_current((Plugin *)vp); vp->playback_start(); - } + } } vp_data.playback_started = TRUE; } @@ -94,10 +94,10 @@ for (node = vp_data.enabled_list; node; node = g_list_next(node)) { vp = node->data; if (vp->playback_stop) - { + { plugin_set_current((Plugin *)vp); vp->playback_stop(); - } + } } vp_data.playback_started = FALSE; } @@ -115,28 +115,28 @@ if (enable && !vp->enabled) { vp_data.enabled_list = g_list_append(vp_data.enabled_list, vp); if (vp->init) - { + { plugin_set_current((Plugin *)vp); vp->init(); - } + } if (playback_get_playing() && vp->playback_start) - { + { plugin_set_current((Plugin *)vp); vp->playback_start(); - } + } } else if (!enable && vp->enabled) { vp_data.enabled_list = g_list_remove(vp_data.enabled_list, vp); if (playback_get_playing() && vp->playback_stop) - { + { plugin_set_current((Plugin *)vp); vp->playback_stop(); - } + } if (vp->cleanup) - { + { plugin_set_current((Plugin *)vp); vp->cleanup(); - } + } } vp->enabled = enable; @@ -180,15 +180,15 @@ vp_data.enabled_list = g_list_append(vp_data.enabled_list, vp); if (vp->init) - { + { plugin_set_current((Plugin *)vp); vp->init(); - } + } if (playback_get_playing() && vp->playback_start) - { + { plugin_set_current((Plugin *)vp); vp->playback_start(); - } + } vp->enabled = TRUE; } g_free(base); @@ -301,7 +301,7 @@ calc_mono_pcm(mono_pcm, pcm_data, nch); mono_pcm_calced = TRUE; } - plugin_set_current((Plugin *)vp); + plugin_set_current((Plugin *)vp); vp->render_pcm(mono_pcm); } else { @@ -309,7 +309,7 @@ calc_stereo_pcm(stereo_pcm, pcm_data, nch); stereo_pcm_calced = TRUE; } - plugin_set_current((Plugin *)vp); + plugin_set_current((Plugin *)vp); vp->render_pcm(stereo_pcm); } } @@ -319,7 +319,7 @@ calc_mono_freq(mono_freq, pcm_data, nch); mono_freq_calced = TRUE; } - plugin_set_current((Plugin *)vp); + plugin_set_current((Plugin *)vp); vp->render_freq(mono_freq); } else { @@ -327,7 +327,7 @@ calc_stereo_freq(stereo_freq, pcm_data, nch); stereo_freq_calced = TRUE; } - plugin_set_current((Plugin *)vp); + plugin_set_current((Plugin *)vp); vp->render_freq(stereo_freq); } } @@ -430,24 +430,26 @@ else intern_vis_data[1] = intern_vis_data[0]; } - else{ /*Voiceprint*/ - if (!mono_freq_calced) - calc_mono_freq(mono_freq, pcm_data, nch); - memset(intern_vis_data, 0, 256); - /* For the values [0-16] we use the frequency that's 3/2 as much. - If we assume the 512 values calculated by calc_mono_freq to cover 0-22kHz linearly - we get a range of [0-16] * 3/2 * 22000/512 = [0-1,031] Hz. - Most stuff above that is harmonics and we want to utilize the 16 samples we have - to the max[tm] - */ - for(i = 0; i < 50 ; i+=3){ - intern_vis_data[i/3] += (mono_freq[0][i/2] >> 5); - - /*Boost frequencies above 257Hz a little*/ - //if(i > 4 * 3) - // intern_vis_data[i/3] += 8; - } - } + else { /*Voiceprint*/ + if (!mono_freq_calced) + calc_mono_freq(mono_freq, pcm_data, nch); + memset(intern_vis_data, 0, 256); + + /* For the values [0-16] we use the frequency that's 3/2 as much. + If we assume the 512 values calculated by calc_mono_freq to + cover 0-22kHz linearly we get a range of + [0-16] * 3/2 * 22000/512 = [0-1,031] Hz. + Most stuff above that is harmonics and we want to utilize the + 16 samples we have to the max[tm] + */ + for (i = 0; i < 50 ; i+=3){ + intern_vis_data[i/3] += (mono_freq[0][i/2] >> 5); + + /*Boost frequencies above 257Hz a little*/ + //if(i > 4 * 3) + // intern_vis_data[i/3] += 8; + } + } } else { /* (cfg.vis_type == VIS_SCOPE) */ diff -r 6a26dabad84f -r 2fa51f742f25 src/libeggsmclient/ChangeLog --- a/src/libeggsmclient/ChangeLog Tue Mar 25 15:16:24 2008 +0200 +++ b/src/libeggsmclient/ChangeLog Tue Mar 25 15:16:46 2008 +0200 @@ -1,17 +1,32 @@ -2008-03-03 Ivan N. Zlatev +2008-03-23 Jussi Judin + + * eggdesktopfile.c (egg_desktop_file_new_from_key_file): do not + leak the type. + +2008-03-15 Dan Winship - * eggsmclient-xsmp.c (sm_client_xsmp_startup): Connect - immediately, so that windows created before - running the main loop will have SM_CLIENT_ID set. We are not - supposed to modify SM_CLIENT_ID after the visible window has - been created (e.g Metacity will just ignore us). - Delay setting the initial properties until after the main loop, - has started in order to provide a larger time frame for the - user to call egg_set_desktop_file(). + * eggsmclient-xsmp.c: Reorganize; we have to call + gdk_set_sm_client_id() before the application creates any windows + (you're not allowed to change SM_CLIENT_ID while you have windows + mapped), which means that to be safe, we have to do it at startup + time, not after the main loop starts. + (EggSMClientXSMP): add a waiting_to_set_initial_properties flag. + (sm_client_xsmp_startup): Move the begining of the old + sm_client_xsmp_connect to here. Set + waiting_to_set_initial_properties and set up an idle handler to do + that. + (sm_client_xsmp_set_initial_properties): The rest of the old + sm_client_xsmp_connect. + (sm_client_xsmp_end_session): XSMP_STATE_START no longer exists, + but we have to deal with waiting_to_set_initial_properties now. + (xsmp_save_yourself): Likewise, if this arrives before we get a + chance to set the initial properties, set them now. + + Based on a patch from Ivan N. Zlatev. 2007-05-02 Dan Winship - * egglauncher.c: + * egglauncher.c: * eggdesktopfile.c: Replace EggLauncher with EggDesktopFile, which is more like GnomeDesktopItem, but with a nicer launching API. diff -r 6a26dabad84f -r 2fa51f742f25 src/libeggsmclient/eggdesktopfile.c --- a/src/libeggsmclient/eggdesktopfile.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/libeggsmclient/eggdesktopfile.c Tue Mar 25 15:16:46 2008 +0200 @@ -202,6 +202,7 @@ if (!exec) { egg_desktop_file_free (desktop_file); + g_free(type); return NULL; } @@ -234,6 +235,7 @@ if (!url) { egg_desktop_file_free (desktop_file); + g_free(type); return NULL; } g_free (url); @@ -243,6 +245,8 @@ else desktop_file->type = EGG_DESKTOP_FILE_TYPE_UNRECOGNIZED; + g_free(type); + /* Check the Icon key */ desktop_file->icon = g_key_file_get_string (key_file, EGG_DESKTOP_FILE_GROUP, diff -r 6a26dabad84f -r 2fa51f742f25 src/libeggsmclient/eggsmclient-xsmp.c --- a/src/libeggsmclient/eggsmclient-xsmp.c Tue Mar 25 15:16:24 2008 +0200 +++ b/src/libeggsmclient/eggsmclient-xsmp.c Tue Mar 25 15:16:46 2008 +0200 @@ -56,7 +56,6 @@ */ typedef enum { - XSMP_STATE_START, XSMP_STATE_IDLE, XSMP_STATE_SAVE_YOURSELF, XSMP_STATE_INTERACT_REQUEST, @@ -101,6 +100,7 @@ guint shutting_down : 1; /* Todo list */ + guint waiting_to_set_initial_properties : 1; guint waiting_to_emit_quit : 1; guint waiting_to_emit_quit_cancelled : 1; guint waiting_to_save_myself : 1; @@ -199,71 +199,6 @@ return g_object_new (EGG_TYPE_SM_CLIENT_XSMP, NULL); } -static void -sm_client_xsmp_connect (EggSMClient *client) -{ - EggSMClientXSMP *xsmp = (EggSMClientXSMP *) client; - SmcCallbacks callbacks; - char *client_id; - char error_string_ret[256]; - - ice_init (); - SmcSetErrorHandler (smc_error_handler); - - callbacks.save_yourself.callback = xsmp_save_yourself; - callbacks.die.callback = xsmp_die; - callbacks.save_complete.callback = xsmp_save_complete; - callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled; - - callbacks.save_yourself.client_data = xsmp; - callbacks.die.client_data = xsmp; - callbacks.save_complete.client_data = xsmp; - callbacks.shutdown_cancelled.client_data = xsmp; - - client_id = NULL; - error_string_ret[0] = '\0'; - xsmp->connection = - SmcOpenConnection (NULL, xsmp, SmProtoMajor, SmProtoMinor, - SmcSaveYourselfProcMask | SmcDieProcMask | - SmcSaveCompleteProcMask | - SmcShutdownCancelledProcMask, - &callbacks, - xsmp->client_id, &client_id, - sizeof (error_string_ret), error_string_ret); - - if (!xsmp->connection) - { - g_warning ("Failed to connect to the session manager: %s\n", - error_string_ret[0] ? - error_string_ret : "no error message given"); - xsmp->state = XSMP_STATE_CONNECTION_CLOSED; - return; - } - - /* We expect a pointless initial SaveYourself if either (a) we - * didn't have an initial client ID, or (b) we DID have an initial - * client ID, but the server rejected it and gave us a new one. - */ - if (!xsmp->client_id || - (client_id && strcmp (xsmp->client_id, client_id) != 0)) - xsmp->expecting_initial_save_yourself = TRUE; - - if (client_id) - { - g_free (xsmp->client_id); - xsmp->client_id = g_strdup (client_id); - free (client_id); - - gdk_threads_enter (); - gdk_set_sm_client_id (xsmp->client_id); - gdk_threads_leave (); - - g_debug ("Got client ID \"%s\"", xsmp->client_id); - } - - xsmp->state = XSMP_STATE_IDLE; -} - static gboolean sm_client_xsmp_set_initial_properties (gpointer user_data) { @@ -272,8 +207,12 @@ GPtrArray *clone, *restart; char pid_str[64]; - g_source_remove (xsmp->idle); - xsmp->idle = 0; + if (xsmp->idle) + { + g_source_remove (xsmp->idle); + xsmp->idle = 0; + } + xsmp->waiting_to_set_initial_properties = FALSE; if (egg_sm_client_get_mode () == EGG_SM_CLIENT_MODE_NO_RESTART) xsmp->restart_style = SmRestartNever; @@ -347,6 +286,7 @@ NULL); } + update_pending_events (xsmp); return FALSE; } @@ -378,18 +318,75 @@ const char *client_id) { EggSMClientXSMP *xsmp = (EggSMClientXSMP *)client; + SmcCallbacks callbacks; + char *ret_client_id; + char error_string_ret[256]; - xsmp->state = XSMP_STATE_START; - if (xsmp->client_id) - g_free (xsmp->client_id); xsmp->client_id = g_strdup (client_id); - sm_client_xsmp_connect (client); - /* Do not initialize the properties until we reach the main. - * This also gives the application a chance to call - * egg_set_desktop_file() before we set the initial - * properties. + ice_init (); + SmcSetErrorHandler (smc_error_handler); + + callbacks.save_yourself.callback = xsmp_save_yourself; + callbacks.die.callback = xsmp_die; + callbacks.save_complete.callback = xsmp_save_complete; + callbacks.shutdown_cancelled.callback = xsmp_shutdown_cancelled; + + callbacks.save_yourself.client_data = xsmp; + callbacks.die.client_data = xsmp; + callbacks.save_complete.client_data = xsmp; + callbacks.shutdown_cancelled.client_data = xsmp; + + client_id = NULL; + error_string_ret[0] = '\0'; + xsmp->connection = + SmcOpenConnection (NULL, xsmp, SmProtoMajor, SmProtoMinor, + SmcSaveYourselfProcMask | SmcDieProcMask | + SmcSaveCompleteProcMask | + SmcShutdownCancelledProcMask, + &callbacks, + xsmp->client_id, &ret_client_id, + sizeof (error_string_ret), error_string_ret); + + if (!xsmp->connection) + { + g_warning ("Failed to connect to the session manager: %s\n", + error_string_ret[0] ? + error_string_ret : "no error message given"); + xsmp->state = XSMP_STATE_CONNECTION_CLOSED; + return; + } + + /* We expect a pointless initial SaveYourself if either (a) we + * didn't have an initial client ID, or (b) we DID have an initial + * client ID, but the server rejected it and gave us a new one. */ + if (!xsmp->client_id || + (ret_client_id && strcmp (xsmp->client_id, ret_client_id) != 0)) + xsmp->expecting_initial_save_yourself = TRUE; + + if (ret_client_id) + { + g_free (xsmp->client_id); + xsmp->client_id = g_strdup (ret_client_id); + free (ret_client_id); + + gdk_threads_enter (); + gdk_set_sm_client_id (xsmp->client_id); + gdk_threads_leave (); + + g_debug ("Got client ID \"%s\"", xsmp->client_id); + } + + xsmp->state = XSMP_STATE_IDLE; + + /* Do not set the initial properties until we reach the main loop, + * so that the application has a chance to call + * egg_set_desktop_file(). (This may also help the session manager + * have a better idea of when the application is fully up and + * running.) + */ + xsmp->waiting_to_set_initial_properties = TRUE; xsmp->idle = g_idle_add (sm_client_xsmp_set_initial_properties, client); } @@ -480,11 +477,6 @@ switch (xsmp->state) { - case XSMP_STATE_START: - /* Force the connection to complete (or fail) now. */ - sm_client_xsmp_connect (client); - break; - case XSMP_STATE_CONNECTION_CLOSED: return FALSE; @@ -505,6 +497,9 @@ return TRUE; case XSMP_STATE_IDLE: + if (xsmp->waiting_to_set_initial_properties) + sm_client_xsmp_set_initial_properties (xsmp); + if (!xsmp->expecting_initial_save_yourself) break; /* else fall through */ @@ -645,6 +640,9 @@ return; } + if (xsmp->waiting_to_set_initial_properties) + sm_client_xsmp_set_initial_properties (xsmp); + /* If this is the initial SaveYourself, ignore it; we've already set * properties and there's no reason to actually save state too. */