changeset 3716:9489aae0d872

introduce playback_get_length()
author Tomasz Mon <desowin@gmail.com>
date Thu, 11 Oct 2007 19:25:08 +0200
parents 33acaa5a01b3
children 8ec5bb8aac58
files src/audacious/playback.c src/audacious/playback.h src/audacious/ui_main.c
diffstat 3 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)
 {
--- 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);
--- 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) {