# HG changeset patch # User yaz # Date 1175832779 25200 # Node ID a8494c2a87eb1629a3ad0c2ab561e27e98b320a8 # Parent 1ccc7a9c7fc23b71606b76403f733fbc2b06b3a9 [svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it. - 1. time count will be recorded and restored on reopen. this seems to be right way, but it causes a short stoppage of playback. - 2. introduce a new plugin option "force_reopen_audio". if this is set to FALSE (default), decoder will not reopen output. this is a bit rude, but does not cause any interruption. diff -r 1ccc7a9c7fc2 -r a8494c2a87eb ChangeLog --- a/ChangeLog Thu Apr 05 10:47:18 2007 -0700 +++ b/ChangeLog Thu Apr 05 21:12:59 2007 -0700 @@ -1,3 +1,12 @@ +2007-04-05 17:47:18 +0000 Giacomo Lozito + revision [1958] + - statusicon: memorize player windows visibility status between sessions + trunk/src/statusicon/si.c | 25 ++++++++++++------------- + trunk/src/statusicon/si_cfg.c | 17 +++++++++++++++++ + trunk/src/statusicon/si_cfg.h | 3 +++ + 3 files changed, 32 insertions(+), 13 deletions(-) + + 2007-04-04 18:49:12 +0000 Giacomo Lozito revision [1946] - statusicon: smarter show/hide on statusicon click (plugin will now correctly handle the situation where the player window is always hidden and the playlist window should be shown/hidden) diff -r 1ccc7a9c7fc2 -r a8494c2a87eb src/madplug/configure.c --- a/src/madplug/configure.c Thu Apr 05 10:47:18 2007 -0700 +++ b/src/madplug/configure.c Thu Apr 05 21:12:59 2007 -0700 @@ -27,7 +27,7 @@ static GtkWidget *configure_win = NULL; static GtkWidget *vbox; -static GtkWidget *fast_playback, *use_xing, *dither, *sjis, *show_avg; +static GtkWidget *fast_playback, *use_xing, *dither, *sjis, *show_avg, *reopen; static GtkWidget *RG_enable, *RG_track_mode, *RG_default, *pregain, *hard_limit; static GtkWidget *title_id3_box, *title_tag_desc; @@ -38,7 +38,7 @@ ConfigDb *db; const gchar *text = NULL; #ifdef DEBUG - g_message("saving\n"); + g_message("saving"); #endif audmad_config.fast_play_time_calc = @@ -51,6 +51,8 @@ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(sjis)); audmad_config.show_avg_vbr_bitrate = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(show_avg)); + audmad_config.force_reopen_audio = + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(reopen)); audmad_config.replaygain.enable = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(RG_enable)); @@ -100,6 +102,8 @@ bmp_cfg_db_set_bool(db, "MAD", "show_avg_vbr_bitrate", audmad_config.show_avg_vbr_bitrate); + bmp_cfg_db_set_bool(db, "MAD", "force_reopen_audio", + audmad_config.force_reopen_audio); bmp_cfg_db_close(db); gtk_widget_destroy(configure_win); @@ -179,6 +183,11 @@ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_avg), audmad_config.show_avg_vbr_bitrate); + reopen = gtk_check_button_new_with_label(_("Force reopen audio when audio type changed")); + gtk_box_pack_start(GTK_BOX(vbox2), reopen, TRUE, TRUE, 0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(reopen), + audmad_config.force_reopen_audio); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox2, gtk_label_new(_("General"))); vbox2 = gtk_vbox_new(FALSE, 5); diff -r 1ccc7a9c7fc2 -r a8494c2a87eb src/madplug/decoder.c --- a/src/madplug/decoder.c Thu Apr 05 10:47:18 2007 -0700 +++ b/src/madplug/decoder.c Thu Apr 05 21:12:59 2007 -0700 @@ -596,7 +596,7 @@ || info->channels != (guint) MAD_NCHANNELS(&frame.header)) { #ifdef DEBUG - g_message("re-opening audio due to change in audio type"); + g_message("change in audio type detected"); g_message("old: frequency = %d, channels = %d", info->freq, info->channels); g_message("new: frequency = %d, channels = %d", @@ -605,22 +605,28 @@ #endif /* DEBUG */ info->freq = frame.header.samplerate; info->channels = MAD_NCHANNELS(&frame.header); - info->playback->output->close_audio(); - if(check_audio_param(info) == FALSE) - return NULL; - - if (!info->playback->output->open_audio(info->fmt, info->freq, - info->channels)) { - g_mutex_lock(pb_mutex); - info->playback->error = TRUE; - info->playback->eof = 1; - g_mutex_unlock(pb_mutex); - g_message("failed to re-open audio output: %s", + if(audmad_config.force_reopen_audio && check_audio_param(info)) { + gint current_time = info->playback->output->output_time(); +#ifdef DEBUG + g_message("re-opening audio due to change in audio type"); +#endif + info->playback->output->close_audio(); + if (!info->playback->output->open_audio(info->fmt, info->freq, + info->channels)) { + g_mutex_lock(pb_mutex); + info->playback->error = TRUE; + info->playback->eof = 1; + g_mutex_unlock(pb_mutex); + g_message("failed to re-open audio output: %s", info->playback->output->description); - return NULL; + return NULL; + } + // restore time and advance 0.5sec + info->seek = current_time + 500; } } + if (!info->playback->playing) break; mad_synth_frame(&synth, &frame); diff -r 1ccc7a9c7fc2 -r a8494c2a87eb src/madplug/plugin.c --- a/src/madplug/plugin.c Thu Apr 05 10:47:18 2007 -0700 +++ b/src/madplug/plugin.c Thu Apr 05 21:12:59 2007 -0700 @@ -129,6 +129,7 @@ audmad_config.replaygain.track_mode = FALSE; audmad_config.title_override = FALSE; audmad_config.show_avg_vbr_bitrate = TRUE; + audmad_config.force_reopen_audio = FALSE; db = bmp_cfg_db_open(); if (db) { @@ -154,6 +155,8 @@ &audmad_config.id3_format); bmp_cfg_db_get_bool(db, "MAD", "show_avg_vbr_bitrate", &audmad_config.show_avg_vbr_bitrate); + bmp_cfg_db_get_bool(db, "MAD", "force_reopen_audio", + &audmad_config.force_reopen_audio); bmp_cfg_db_close(db); } diff -r 1ccc7a9c7fc2 -r a8494c2a87eb src/madplug/plugin.h --- a/src/madplug/plugin.h Thu Apr 05 10:47:18 2007 -0700 +++ b/src/madplug/plugin.h Thu Apr 05 21:12:59 2007 -0700 @@ -122,6 +122,7 @@ gboolean title_override; gchar *id3_format; gboolean show_avg_vbr_bitrate; + gboolean force_reopen_audio; }; // global variables