changeset 998:8c6949ffd7f8 trunk

[svn] Support for saving the playback state, and resuming playback after restart. Patch by cha0smaster, closes bug #479.
author chainsaw
date Mon, 01 May 2006 13:53:20 -0700
parents e64eb333b63f
children 386cda529c28
files audacious/main.c audacious/main.h
diffstat 2 files changed, 28 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/audacious/main.c	Mon May 01 08:38:43 2006 -0700
+++ b/audacious/main.c	Mon May 01 13:53:20 2006 -0700
@@ -193,7 +193,9 @@
     FALSE,                      /* software volume control enabled */
     TRUE,                       /* UNUSED (XMMS compatibility mode) */
     TRUE,                       /* extra eq filtering */
-    3                          /* scroll pl by */
+    3,                          /* scroll pl by */
+    FALSE,                      /* resume playback on startup */
+    -1,                         /* resume playback on startup time */
 };
 
 typedef struct bmp_cfg_boolent_t {
@@ -268,7 +270,8 @@
     {"analyzer_peaks", &cfg.analyzer_peaks, TRUE},
     {"custom_cursors", &cfg.custom_cursors, TRUE},
     {"close_dialog_open", &cfg.close_dialog_open, TRUE},
-    {"close_dialog_add", &cfg.close_dialog_add, TRUE}
+    {"close_dialog_add", &cfg.close_dialog_add, TRUE},
+    {"resume_playback_on_startup", &cfg.resume_playback_on_startup, TRUE},
 };
 
 static gint ncfgbent = G_N_ELEMENTS(bmp_boolents);
@@ -297,6 +300,7 @@
     {"mouse_wheel_change", &cfg.mouse_change, TRUE},
     {"scroll_pl_by", &cfg.scroll_pl_by, TRUE},
     {"titlestring_preset", &cfg.titlestring_preset, TRUE},
+    {"resume_playback_on_startup_time", &cfg.resume_playback_on_startup_time, TRUE},
 };
 
 static gint ncfgient = G_N_ELEMENTS(bmp_numents);
@@ -530,7 +534,7 @@
 {
     GList *node;
     gchar *str;
-    gint i;
+    gint i, cur_pb_time;
     ConfigDb *db;
 
     cfg.disabled_iplugins = input_stringify_disabled_list();
@@ -631,6 +635,14 @@
         g_free(str);
     }
 
+    if (bmp_playback_get_playing()) {
+	    cur_pb_time = bmp_playback_get_time();
+    } else
+	    cur_pb_time = -1;
+    cfg.resume_playback_on_startup_time = cur_pb_time;
+    bmp_cfg_db_set_int(db, NULL, "resume_playback_on_startup_time",
+		       cfg.resume_playback_on_startup_time);
+
     bmp_cfg_db_close(db);
 
     playlist_save(bmp_paths[BMP_PATH_PLAYLIST_FILE], FALSE);
@@ -1066,6 +1078,17 @@
 
 	has_x11_connection = TRUE;
 
+	if (cfg.resume_playback_on_startup) {
+		if (cfg.resume_playback_on_startup_time != -1) {
+			while (gtk_events_pending()) gtk_main_iteration();
+			bmp_playback_initiate();
+			while (!ip_data.playing)
+				g_usleep(10000);
+			bmp_playback_seek(cfg.resume_playback_on_startup_time /
+					  1000);
+		}
+	}
+
         gtk_main();
 
         GDK_THREADS_LEAVE();
--- a/audacious/main.h	Mon May 01 08:38:43 2006 -0700
+++ b/audacious/main.h	Mon May 01 13:53:20 2006 -0700
@@ -104,6 +104,8 @@
     gboolean xmms_compat_mode;
     gboolean eq_extra_filtering;
     gint scroll_pl_by;
+    gboolean resume_playback_on_startup;
+    gint resume_playback_on_startup_time;
 };
 
 typedef struct _BmpConfig BmpConfig;