Mercurial > audlegacy
changeset 3018:6a9fdd5aee3a trunk
Move timer updates out of the 100hz giant loop.
author | Daniel Drake <dsd@gentoo.org> |
---|---|
date | Mon, 09 Jul 2007 23:19:35 -0500 |
parents | 02a62ac3d9c2 |
children | 89b85a1b7fd2 |
files | src/audacious/playback.c src/audacious/ui_main.c src/audacious/ui_main.h |
diffstat | 3 files changed, 22 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/audacious/playback.c Mon Jul 09 05:17:21 2007 -0500 +++ b/src/audacious/playback.c Mon Jul 09 23:19:35 2007 -0500 @@ -52,6 +52,7 @@ #include "playback.h" +static int song_info_timeout_source = 0; gint playback_get_time(void) @@ -100,6 +101,11 @@ playlist_check_pos_current(playlist); mainwin_set_info_text(); + 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); if (cfg.player_shaded) { gtk_widget_show(mainwin_stime_min); @@ -169,7 +175,10 @@ ip_data.buffering = FALSE; ip_data.playing = FALSE; - + + if (song_info_timeout_source) + g_source_remove(song_info_timeout_source); + g_return_if_fail(mainwin_playstatus != NULL); playstatus_set_status_buffering(mainwin_playstatus, FALSE); }
--- a/src/audacious/ui_main.c Mon Jul 09 05:17:21 2007 -0500 +++ b/src/audacious/ui_main.c Mon Jul 09 23:19:35 2007 -0500 @@ -2482,6 +2482,7 @@ set_timer_mode(TIMER_REMAINING); else set_timer_mode(TIMER_ELAPSED); + mainwin_update_song_info(); } static void @@ -2981,21 +2982,21 @@ mainwin_idle_func, NULL); } -static void -idle_func_update_song_info(gint time) +gboolean +mainwin_update_song_info(void) { + gint time = playback_get_time(); gint length, t; gchar stime_prefix; + if (!playback_get_playing() || time < 0) + return FALSE; + 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()); - if (playback_get_playing()) - playlistwin_set_time(time, length, cfg.timer_mode); - else - playlistwin_hide_timer(); - input_update_vis(time); + playlistwin_set_time(time, length, cfg.timer_mode); if (cfg.timer_mode == TIMER_REMAINING) { if (length != -1) { @@ -3055,6 +3056,8 @@ hslider_set_position(mainwin_position, 0); hslider_set_position(mainwin_sposition, 1); } + + return TRUE; } static gboolean @@ -3076,7 +3079,7 @@ break; default: - idle_func_update_song_info(time); + input_update_vis(time); /* nothing at this time */ }
--- a/src/audacious/ui_main.h Mon Jul 09 05:17:21 2007 -0500 +++ b/src/audacious/ui_main.h Mon Jul 09 23:19:35 2007 -0500 @@ -168,6 +168,7 @@ GtkWidget * widget); void mainwin_attach_idle_func(void); +gboolean mainwin_update_song_info(void); void mainwin_drag_data_received(GtkWidget * widget, GdkDragContext * context, gint x,