changeset 2436:f346d30bf5ab trunk

[svn] Change the input plugin API to use a struct for the currently-playing file.
author iabervon
date Sun, 28 Jan 2007 17:02:15 -0800
parents 5b23e9b07317
children 62d8f9c05832
files ChangeLog src/audacious/input.c src/audacious/input.h src/audacious/playback.c src/audacious/plugin.h
diffstat 5 files changed, 69 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jan 28 12:15:08 2007 -0800
+++ b/ChangeLog	Sun Jan 28 17:02:15 2007 -0800
@@ -1,3 +1,13 @@
+2007-01-28 20:15:08 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [3880]
+  - new croatian translation from Marin Glibic
+  
+  trunk/po/LINGUAS                 |    1 
+  trunk/po/hr.po                   | 2104 +++++++++++++++++++++++++++++++++++++++
+  trunk/src/audacious/ui_credits.c |    3 
+  3 files changed, 2108 insertions(+)
+
+
 2007-01-28 11:55:46 +0000  Tony Vroon <chainsaw@gentoo.org>
   revision [3878]
   Add Joseph Jezak to the list of patch submitters.
--- a/src/audacious/input.c	Sun Jan 28 12:15:08 2007 -0800
+++ b/src/audacious/input.c	Sun Jan 28 17:02:15 2007 -0800
@@ -73,16 +73,16 @@
 
 gchar *input_info_text = NULL;
 
-InputPlugin *
-get_current_input_plugin(void)
+InputPlayback *
+get_current_input_playback(void)
 {
-    return ip_data.current_input_plugin;
+    return ip_data.current_input_playback;
 }
 
 void
-set_current_input_plugin(InputPlugin * ip)
+set_current_input_playback(InputPlayback * ip)
 {
-    ip_data.current_input_plugin = ip;
+    ip_data.current_input_playback = ip;
 }
 
 GList *
@@ -511,11 +511,11 @@
     if (!ip_data.playing)
         return;
 
-    if (!get_current_input_plugin())
+    if (!get_current_input_playback())
         return;
 
-    if (get_current_input_plugin()->set_eq)
-        get_current_input_plugin()->set_eq(on, preamp, bands);
+    if (get_current_input_playback()->plugin->set_eq)
+        get_current_input_playback()->plugin->set_eq(on, preamp, bands);
 }
 
 void
@@ -736,9 +736,9 @@
     *l = -1;
     *r = -1;
     if (playback_get_playing()) {
-        if (get_current_input_plugin() &&
-            get_current_input_plugin()->get_volume) {
-            get_current_input_plugin()->get_volume(l, r);
+        if (get_current_input_playback() &&
+            get_current_input_playback()->plugin->get_volume) {
+            get_current_input_playback()->plugin->get_volume(l, r);
             return;
         }
     }
@@ -749,9 +749,9 @@
 input_set_volume(gint l, gint r)
 {
     if (playback_get_playing()) {
-        if (get_current_input_plugin() &&
-            get_current_input_plugin()->set_volume) {
-            get_current_input_plugin()->set_volume(l, r);
+        if (get_current_input_playback() &&
+            get_current_input_playback()->plugin->set_volume) {
+            get_current_input_playback()->plugin->set_volume(l, r);
             return;
         }
     }
@@ -814,7 +814,7 @@
     if (!playback_get_playing())
         return;
 
-    if (!get_current_input_plugin())
+    if (!get_current_input_playback())
         return;
 
     ip_data.buffering = status;
--- a/src/audacious/input.h	Sun Jan 28 12:15:08 2007 -0800
+++ b/src/audacious/input.h	Sun Jan 28 17:02:15 2007 -0800
@@ -30,7 +30,7 @@
 
 struct _InputPluginData {
     GList *input_list;
-    InputPlugin *current_input_plugin;
+    InputPlayback *current_input_playback;
     gboolean playing;
     gboolean paused;
     gboolean stop;
@@ -39,8 +39,9 @@
 };
 
 GList *get_input_list(void);
-InputPlugin *get_current_input_plugin(void);
-void set_current_input_plugin(InputPlugin * ip);
+InputPlayback *get_current_input_playback(void);
+void set_current_input_playback(InputPlayback * ip);
+void set_current_input_data(void * data);
 InputVisType input_get_vis_type();
 void free_vis_data(void);
 InputPlugin *input_check_file(const gchar * filename, gboolean show_warning);
--- a/src/audacious/playback.c	Sun Jan 28 12:15:08 2007 -0800
+++ b/src/audacious/playback.c	Sun Jan 28 17:02:15 2007 -0800
@@ -71,9 +71,9 @@
 playback_get_time(void)
 {
     g_return_val_if_fail(playback_get_playing(), -1);
-    g_return_val_if_fail(get_current_input_plugin(), -1);
+    g_return_val_if_fail(get_current_input_playback(), -1);
 
-    return get_current_input_plugin()->get_time();
+    return get_current_input_playback()->plugin->get_time(get_current_input_playback());
 }
 
 void
@@ -142,13 +142,14 @@
     if (!playback_get_playing())
         return;
 
-    if (!get_current_input_plugin())
+    if (!get_current_input_playback())
         return;
 
     ip_data.paused = !ip_data.paused;
 
-    if (get_current_input_plugin()->pause)
-        get_current_input_plugin()->pause(ip_data.paused);
+    if (get_current_input_playback()->plugin->pause)
+        get_current_input_playback()->plugin->pause(get_current_input_playback(),
+						    ip_data.paused);
 
     g_return_if_fail(mainwin_playstatus != NULL);
 
@@ -161,7 +162,7 @@
 void
 playback_stop(void)
 {
-    if (ip_data.playing && get_current_input_plugin()) {
+    if (ip_data.playing && get_current_input_playback()) {
 
         if (playback_get_paused()) {
             output_flush(get_written_time()); /* to avoid noise */
@@ -170,8 +171,8 @@
 
         ip_data.playing = FALSE; 
 
-        if (get_current_input_plugin()->stop)
-            get_current_input_plugin()->stop();
+        if (get_current_input_playback()->plugin->stop)
+            get_current_input_playback()->plugin->stop(get_current_input_playback());
 
         free_vis_data();
         ip_data.paused = FALSE;
@@ -181,6 +182,9 @@
             input_info_text = NULL;
             mainwin_set_info_text();
         }
+
+	g_free(get_current_input_playback());
+	set_current_input_playback(NULL);
     }
 
     ip_data.buffering = FALSE;
@@ -210,6 +214,7 @@
 gboolean
 playback_play_file(PlaylistEntry *entry)
 {
+    InputPlayback * playback;
     g_return_val_if_fail(entry != NULL, FALSE);
 
     if (!get_current_output_plugin()) {
@@ -232,15 +237,23 @@
     {
         input_file_not_playable(entry->filename);
 
-        set_current_input_plugin(NULL);
+        set_current_input_playback(NULL);
         mainwin_set_info_text();
 
         return FALSE;
     }
 
-    set_current_input_plugin(entry->decoder);
+    playback = g_new0(InputPlayback, 1);
+    
     entry->decoder->output = &psuedo_output_plugin;
-    entry->decoder->play_file(entry->filename);
+
+    playback->plugin = entry->decoder;
+    playback->output = &psuedo_output_plugin;
+    playback->filename = entry->filename;
+    
+    set_current_input_playback(playback);
+
+    entry->decoder->play_file(playback);
 
     ip_data.playing = TRUE;
 
@@ -266,7 +279,7 @@
     gint l=0, r=0;
 
     g_return_if_fail(ip_data.playing);
-    g_return_if_fail(get_current_input_plugin());
+    g_return_if_fail(get_current_input_playback());
 
     /* FIXME WORKAROUND...that should work with all plugins
      * mute the volume, start playback again, do the seek, then pause again
@@ -281,7 +294,7 @@
     }
     
     free_vis_data();
-    get_current_input_plugin()->seek(time);
+    get_current_input_playback()->plugin->seek(get_current_input_playback(), time);
     
     if (restore_pause)
     {
--- a/src/audacious/plugin.h	Sun Jan 28 12:15:08 2007 -0800
+++ b/src/audacious/plugin.h	Sun Jan 28 17:02:15 2007 -0800
@@ -80,6 +80,8 @@
 
 typedef struct _LowlevelPlugin LowlevelPlugin;
 
+typedef struct _InputPlayback InputPlayback;
+
 /* Sadly, this is the most we can generalize out of the disparate
    plugin structs usable with typecasts - descender */
 struct _Plugin {
@@ -145,6 +147,13 @@
     void (*query_format) (AFormat * fmt, gint * rate, gint * nch);
 };
 
+struct _InputPlayback {
+    gchar *filename;
+    InputPlugin *plugin;
+    void *data;
+    OutputPlugin *output;
+};
+
 struct _InputPlugin {
     gpointer handle;
     gchar *filename;
@@ -158,14 +167,14 @@
     gint (*is_our_file) (gchar * filename);
     GList *(*scan_dir) (gchar * dirname);
 
-    void (*play_file) (gchar * filename);
-    void (*stop) (void);
-    void (*pause) (gshort paused);
-    void (*seek) (gint time);
+    void (*play_file) (InputPlayback * playback);
+    void (*stop) (InputPlayback * playback);
+    void (*pause) (InputPlayback * playback, gshort paused);
+    void (*seek) (InputPlayback * playback, gint time);
 
     void (*set_eq) (gint on, gfloat preamp, gfloat * bands);
 
-    gint (*get_time) (void);
+    gint (*get_time) (InputPlayback * playback);
 
     void (*get_volume) (gint * l, gint * r);
     void (*set_volume) (gint l, gint r);