# HG changeset patch # User Tomasz Mon # Date 1192123508 -7200 # Node ID 9489aae0d8723945a9ccc86416258ac7d681c5f4 # Parent 33acaa5a01b38179f111b6c9deff20fbe153d1ce introduce playback_get_length() diff -r 33acaa5a01b3 -r 9489aae0d872 src/audacious/playback.c --- a/src/audacious/playback.c Wed Oct 10 20:31:38 2007 +0300 +++ b/src/audacious/playback.c Thu Oct 11 19:25:08 2007 +0200 @@ -155,6 +155,21 @@ return playback->output->output_time(); } +gint +playback_get_length(void) +{ + InputPlayback *playback; + g_return_val_if_fail(playback_get_playing(), -1); + playback = get_current_input_playback(); + + if (playback && playback->plugin->get_song_tuple) { + Tuple *tuple = playback->plugin->get_song_tuple(playback->filename); + if (tuple_get_value_type(tuple, FIELD_LENGTH, NULL) == TUPLE_INT) + return tuple_get_value_type(tuple, FIELD_LENGTH, NULL); + } + return -1; +} + void playback_initiate(void) { diff -r 33acaa5a01b3 -r 9489aae0d872 src/audacious/playback.h --- a/src/audacious/playback.h Wed Oct 10 20:31:38 2007 +0300 +++ b/src/audacious/playback.h Thu Oct 11 19:25:08 2007 +0200 @@ -29,6 +29,7 @@ #include "plugin.h" gint playback_get_time(void); +gint playback_get_length(void); void playback_initiate(void); void playback_pause(void); void playback_stop(void); diff -r 33acaa5a01b3 -r 9489aae0d872 src/audacious/ui_main.c --- a/src/audacious/ui_main.c Wed Oct 10 20:31:38 2007 +0300 +++ b/src/audacious/ui_main.c Thu Oct 11 19:25:08 2007 +0200 @@ -2511,7 +2511,10 @@ if (ab_position_a != -1 && ab_position_b != -1 && time > ab_position_b) playback_seek(ab_position_a/1000); - length = playlist_get_current_length(playlist_get_active()); + length = playback_get_length(); + if (length == -1 && cfg.timer_mode == TIMER_REMAINING) + cfg.timer_mode = TIMER_ELAPSED; + playlistwin_set_time(time, length, cfg.timer_mode); if (cfg.timer_mode == TIMER_REMAINING) {