changeset 3170:603577228518 trunk

get_current_input_playback() cleanups.
author William Pitcock <nenolod@atheme-project.org>
date Thu, 26 Jul 2007 14:22:26 -0500
parents ee8a1ed30826
children 93d2cda7e072
files src/audacious/input.c src/audacious/playback.c
diffstat 2 files changed, 34 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/input.c	Wed Jul 25 19:10:53 2007 -0500
+++ b/src/audacious/input.c	Thu Jul 26 14:22:26 2007 -0500
@@ -1,5 +1,5 @@
 /*  Audacious - Cross-platform multimedia player
- *  Copyright (C) 2005-2006  Audacious development team
+ *  Copyright (C) 2005-2007  Audacious development team
  *
  *  Based on BMP:
  *  Copyright (C) 2003-2004  BMP development team
@@ -511,14 +511,16 @@
 void
 input_set_eq(gint on, gfloat preamp, gfloat * bands)
 {
+    InputPlayback *playback;
+
     if (!ip_data.playing)
         return;
 
-    if (!get_current_input_playback())
+    if ((playback = get_current_input_playback()) == NULL)
         return;
 
-    if (get_current_input_playback()->plugin->set_eq)
-        get_current_input_playback()->plugin->set_eq(on, preamp, bands);
+    if (playback->plugin->set_eq)
+        playback->plugin->set_eq(on, preamp, bands);
 }
 
 void
@@ -764,14 +766,15 @@
 void
 input_get_volume(gint * l, gint * r)
 {
+    InputPlayback *playback;
+
     *l = -1;
     *r = -1;
     if (playback_get_playing()) {
-        if (get_current_input_playback() &&
-            get_current_input_playback()->plugin->get_volume &&
-            get_current_input_playback()->plugin->get_volume(l, r)) {
+        if ((playback = get_current_input_playback()) != NULL &&
+            playback->plugin->get_volume &&
+            playback->plugin->get_volume(l, r))
             return;
-        }
     }
     output_get_volume(l, r);
 }
@@ -779,19 +782,21 @@
 void
 input_set_volume(gint l, gint r)
 {
+    InputPlayback *playback;
+
     gint h_vol[2];
+
+    h_vol[0] = l;
+    h_vol[1] = r;
+    hook_call("volume set", h_vol);
     
     if (playback_get_playing() &&
-        get_current_input_playback() &&
-        get_current_input_playback()->plugin->set_volume &&
-        get_current_input_playback()->plugin->set_volume(l, r))
+        (playback = get_current_input_playback()) != NULL &&
+        playback->plugin->set_volume &&
+        playback->plugin->set_volume(l, r))
         return;
 
     output_set_volume(l, r);
-    
-    h_vol[0] = l;
-    h_vol[1] = r;
-    hook_call("volume set", h_vol);
 }
 
 void
--- a/src/audacious/playback.c	Wed Jul 25 19:10:53 2007 -0500
+++ b/src/audacious/playback.c	Thu Jul 26 14:22:26 2007 -0500
@@ -148,17 +148,18 @@
 void
 playback_pause(void)
 {
+    InputPlayback *playback;
+
     if (!playback_get_playing())
         return;
 
-    if (!get_current_input_playback())
+    if ((playback = get_current_input_playback()) == NULL)
         return;
 
     ip_data.paused = !ip_data.paused;
 
-    if (get_current_input_playback()->plugin->pause)
-        get_current_input_playback()->plugin->pause(get_current_input_playback(),
-						    ip_data.paused);
+    if (playback->plugin->pause)
+        playback->plugin->pause(playback, ip_data.paused);
 
     if (ip_data.paused)
         hook_call("playback pause", NULL);
@@ -176,23 +177,26 @@
 void
 playback_stop(void)
 {
-    if (ip_data.playing && get_current_input_playback()) {
+    InputPlayback *playback;
 
-        if (playback_get_paused()) {
+    if (ip_data.playing && (playback = get_current_input_playback()) != NULL)
+    {
+        if (playback_get_paused() == TRUE)
+        {
             output_flush(get_written_time()); /* to avoid noise */
             playback_pause();
         }
 
         ip_data.playing = FALSE; 
 
-        if (get_current_input_playback()->plugin->stop)
-            get_current_input_playback()->plugin->stop(get_current_input_playback());
+        if (playback->plugin->stop)
+            playback->plugin->stop(playback);
 
         free_vis_data();
         ip_data.paused = FALSE;
 
-	g_free(get_current_input_playback()->filename);
-	g_free(get_current_input_playback());
+	g_free(playback->filename);
+	g_free(playback);
 	set_current_input_playback(NULL);
     }