changeset 2928:ede9a8b8deff trunk

Split out playback functions.
author William Pitcock <nenolod@atheme.org>
date Fri, 29 Jun 2007 08:10:38 -0500
parents dbba106b417f
children b0ca7bddaec9
files src/audtool/Makefile src/audtool/audtool_handlers_general.c src/audtool/audtool_handlers_playback.c
diffstat 3 files changed, 144 insertions(+), 105 deletions(-) [+]
line wrap: on
line diff
--- a/src/audtool/Makefile	Fri Jun 29 08:08:30 2007 -0500
+++ b/src/audtool/Makefile	Fri Jun 29 08:10:38 2007 -0500
@@ -25,6 +25,7 @@
 SOURCES =	 			\
 	audtool_main.c			\
 	audtool_handlers_general.c	\
+	audtool_handlers_playback.c	\
 	audtool_handlers_playlist.c	\
 	audtool_handlers_vitals.c
 
--- a/src/audtool/audtool_handlers_general.c	Fri Jun 29 08:08:30 2007 -0500
+++ b/src/audtool/audtool_handlers_general.c	Fri Jun 29 08:10:38 2007 -0500
@@ -37,111 +37,6 @@
 #include "libaudclient/audctrl.h"
 #include "audtool.h"
 
-void playback_play(gint argc, gchar **argv)
-{
-	audacious_remote_play(dbus_proxy);
-}
-
-void playback_pause(gint argc, gchar **argv)
-{
-	audacious_remote_pause(dbus_proxy);
-}
-
-void playback_playpause(gint argc, gchar **argv)
-{
-	if (audacious_remote_is_playing(dbus_proxy))
-	{
-		audacious_remote_pause(dbus_proxy);
-	}
-	else
-	{
-		audacious_remote_play(dbus_proxy);
-	}
-}
-
-void playback_stop(gint argc, gchar **argv)
-{
-	audacious_remote_stop(dbus_proxy);
-}
-
-void playback_playing(gint argc, gchar **argv)
-{
-	if (!audacious_remote_is_paused(dbus_proxy))
-	{
-		exit(!audacious_remote_is_playing(dbus_proxy));
-	}
-	else
-	{
-		exit(1);
-	}
-}
-
-void playback_paused(gint argc, gchar **argv)
-{
-	exit(!audacious_remote_is_paused(dbus_proxy));
-}
-
-void playback_stopped(gint argc, gchar **argv)
-{
-	if (!audacious_remote_is_playing(dbus_proxy) && !audacious_remote_is_paused(dbus_proxy))
-	{
-		exit(0);
-	}
-	else
-	{
-		exit(1);
-	}
-}
-
-void playback_status(gint argc, gchar **argv)
-{
-	if (audacious_remote_is_paused(dbus_proxy))
-	{
-		g_print("paused\n");
-		return;
-	}
-	else if (audacious_remote_is_playing(dbus_proxy))
-	{
-		g_print("playing\n");
-		return;
-	}
-	else
-	{
-		g_print("stopped\n");
-		return;
-	}
-}
-
-void playback_seek(gint argc, gchar **argv)
-{
-	if (argc < 2)
-	{
-		g_print("%s: invalid parameters for playback-seek.\n", argv[0]);
-		g_print("%s: syntax: %s playback-seek <position>\n", argv[0], argv[0]);
-		return;
-	}
-
-	audacious_remote_jump_to_time(dbus_proxy, atoi(argv[1]) * 1000);
-}
-
-void playback_seek_relative(gint argc, gchar **argv)
-{
-	gint oldtime, newtime, diff;
-
-	if (argc < 2)
-	{
-		g_print("%s: invalid parameters for playback-seek-relative.\n", argv[0]);
-		g_print("%s: syntax: %s playback-seek <position>\n", argv[0], argv[0]);
-		return;
-	}
-
-	oldtime = audacious_remote_get_output_time(dbus_proxy);
-	diff = atoi(argv[1]) * 1000;
-	newtime = oldtime + diff;
-
-	audacious_remote_jump_to_time(dbus_proxy, newtime);
-}
-
 void playqueue_add(gint argc, gchar **argv)
 {
 	gint i;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audtool/audtool_handlers_playback.c	Fri Jun 29 08:10:38 2007 -0500
@@ -0,0 +1,143 @@
+/*
+ * Audtool2
+ * Copyright (c) 2007 Audacious development team
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <mowgli.h>
+#include <locale.h>
+#include "libaudclient/audctrl.h"
+#include "audtool.h"
+
+void playback_play(gint argc, gchar **argv)
+{
+	audacious_remote_play(dbus_proxy);
+}
+
+void playback_pause(gint argc, gchar **argv)
+{
+	audacious_remote_pause(dbus_proxy);
+}
+
+void playback_playpause(gint argc, gchar **argv)
+{
+	if (audacious_remote_is_playing(dbus_proxy))
+	{
+		audacious_remote_pause(dbus_proxy);
+	}
+	else
+	{
+		audacious_remote_play(dbus_proxy);
+	}
+}
+
+void playback_stop(gint argc, gchar **argv)
+{
+	audacious_remote_stop(dbus_proxy);
+}
+
+void playback_playing(gint argc, gchar **argv)
+{
+	if (!audacious_remote_is_paused(dbus_proxy))
+	{
+		exit(!audacious_remote_is_playing(dbus_proxy));
+	}
+	else
+	{
+		exit(1);
+	}
+}
+
+void playback_paused(gint argc, gchar **argv)
+{
+	exit(!audacious_remote_is_paused(dbus_proxy));
+}
+
+void playback_stopped(gint argc, gchar **argv)
+{
+	if (!audacious_remote_is_playing(dbus_proxy) && !audacious_remote_is_paused(dbus_proxy))
+	{
+		exit(0);
+	}
+	else
+	{
+		exit(1);
+	}
+}
+
+void playback_status(gint argc, gchar **argv)
+{
+	if (audacious_remote_is_paused(dbus_proxy))
+	{
+		g_print("paused\n");
+		return;
+	}
+	else if (audacious_remote_is_playing(dbus_proxy))
+	{
+		g_print("playing\n");
+		return;
+	}
+	else
+	{
+		g_print("stopped\n");
+		return;
+	}
+}
+
+void playback_seek(gint argc, gchar **argv)
+{
+	if (argc < 2)
+	{
+		g_print("%s: invalid parameters for playback-seek.\n", argv[0]);
+		g_print("%s: syntax: %s playback-seek <position>\n", argv[0], argv[0]);
+		return;
+	}
+
+	audacious_remote_jump_to_time(dbus_proxy, atoi(argv[1]) * 1000);
+}
+
+void playback_seek_relative(gint argc, gchar **argv)
+{
+	gint oldtime, newtime, diff;
+
+	if (argc < 2)
+	{
+		g_print("%s: invalid parameters for playback-seek-relative.\n", argv[0]);
+		g_print("%s: syntax: %s playback-seek <position>\n", argv[0], argv[0]);
+		return;
+	}
+
+	oldtime = audacious_remote_get_output_time(dbus_proxy);
+	diff = atoi(argv[1]) * 1000;
+	newtime = oldtime + diff;
+
+	audacious_remote_jump_to_time(dbus_proxy, newtime);
+}