changeset 1462:77971f2ab4bc trunk

[svn] - cuesheet plugin. Incomplete, but can do the following: - load and populate a playlist from a cuesheet (can't do anything else yet though, including build tuples)
author nenolod
date Wed, 02 Aug 2006 17:44:15 -0700
parents 2c1f074a8a63
children 47c7695095d4
files ChangeLog Plugins/Input/cue/Makefile Plugins/Input/cue/cuesheet.c
diffstat 3 files changed, 296 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Aug 02 16:18:16 2006 -0700
+++ b/ChangeLog	Wed Aug 02 17:44:15 2006 -0700
@@ -1,3 +1,38 @@
+2006-08-02 23:18:16 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1836]
+  - update PO files
+  
+
+  Changes:        Modified:
+  +97 -73         trunk/po/audacious.pot  
+  +99 -73         trunk/po/br.po  
+  +104 -73        trunk/po/cs.po  
+  +101 -73        trunk/po/cy.po  
+  +105 -73        trunk/po/de.po  
+  +583 -667       trunk/po/el.po  
+  +105 -73        trunk/po/es.po  
+  +101 -73        trunk/po/fi.po  
+  +101 -73        trunk/po/fr.po  
+  +101 -73        trunk/po/hi.po  
+  +120 -73        trunk/po/hu.po  
+  +105 -73        trunk/po/it.po  
+  +105 -73        trunk/po/ja.po  
+  +101 -73        trunk/po/ka.po  
+  +101 -73        trunk/po/ko.po  
+  +101 -73        trunk/po/lt.po  
+  +101 -73        trunk/po/mk.po  
+  +132 -92        trunk/po/nl.po  
+  +101 -73        trunk/po/pl.po  
+  +101 -73        trunk/po/pt_BR.po  
+  +101 -73        trunk/po/ro.po  
+  +101 -73        trunk/po/ru.po  
+  +101 -73        trunk/po/sk.po  
+  +101 -73        trunk/po/sv.po  
+  +101 -73        trunk/po/uk.po  
+  +102 -76        trunk/po/zh_CN.po  
+  +101 -73        trunk/po/zh_TW.po  
+
+
 2006-08-02 23:06:49 +0000  Derek Pomery <nemo@m8y.org>
   revision [1834]
   fine
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Input/cue/Makefile	Wed Aug 02 17:44:15 2006 -0700
@@ -0,0 +1,16 @@
+include ../../../mk/rules.mk
+include ../../../mk/objective.mk
+
+OBJECTIVE_LIBS = libcuesheet.so
+
+LIBDIR = $(plugindir)/$(INPUT_PLUGIN_DIR)
+
+SOURCES = cuesheet.c
+
+OBJECTS = ${SOURCES:.c=.o}
+
+CFLAGS += -fPIC -DPIC $(GTK_CFLAGS) $(ARCH_DEFINES) -I../../../intl -I../../..
+
+CXXFLAGS = $(CFLAGS)
+
+LIBADD = $(GTK_LIBS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/Input/cue/cuesheet.c	Wed Aug 02 17:44:15 2006 -0700
@@ -0,0 +1,245 @@
+/* Audacious: An advanced media player.
+ * cuesheet.c: Support cuesheets as a media container.
+ *
+ * Copyright (C) 2006 William Pitcock <nenolod -at- nenolod.net>.
+ *
+ * This file was hacked out of of xmms-cueinfo,
+ * Copyright (C) 2003  Oskar Liljeblad
+ *
+ * This software is copyrighted work licensed under the terms of the
+ * GNU General Public License. Please consult the file "COPYING" for
+ * details.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <audacious/plugin.h>
+#include <audacious/playlist.h>
+#include <libaudacious/beepctrl.h>
+
+#define MAX_CUE_LINE_LENGTH 1000
+#define MAX_CUE_TRACKS 1000
+
+#define EMPTIZE(x) ((x)==NULL ? "":(x))
+
+static void init(void);
+static void cache_cue_file(FILE *file);
+static void free_cue_info(void);
+static void fix_cue_argument(char *line);
+static gboolean is_our_file(gchar *filespec);
+
+static gchar *cue_performer = NULL;
+static gchar *cue_title = NULL;
+static gchar *cue_file = NULL;
+static gint last_cue_track = 0;
+static gint cur_cue_track = 0;
+static gint entry_lock = 0;
+static struct {
+	gchar *performer;
+	gchar *title;
+	gint index;
+} cue_tracks[MAX_CUE_TRACKS];
+static gint previous_song = -1;
+static gint previous_length = -2;
+static gint timeout_tag = 0;
+
+static InputPlugin *real_ip = NULL;
+
+InputPlugin cue_ip =
+{
+	NULL,			/* handle */
+	NULL,			/* filename */
+	NULL,			/* description */
+	NULL,	       	/* init */
+	NULL,	       	/* about */
+	NULL,	  	   	/* configure */
+	is_our_file,
+	NULL,		/* audio cd */
+#if 0
+	play,
+	stop,
+	pause,
+	seek,
+	NULL,		/* set eq */
+	get_time,
+	NULL,
+	NULL,
+	NULL,		/* cleanup */
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL,		/* XXX get_song_info iface */
+	NULL,
+	NULL,
+	get_tuple,
+	NULL
+#endif
+};
+
+static gboolean is_our_file(gchar *filename)
+{
+	gchar *ext;
+	gboolean ret = FALSE;
+	
+	/* is it a cue:// URI? */
+	if (!strncasecmp(filename, "cue://", 6))
+		return TRUE;
+
+	ext = strrchr(filename, '.');
+
+	if (!strncasecmp(ext, ".cue", 4))
+	{
+		gint i;
+		FILE *f = fopen(filename, "rb");
+		ret = TRUE;
+
+		/* add the files, build cue urls, etc. */
+		cache_cue_file(f);
+
+		for (i = 0; i < last_cue_track; i++)
+		{
+			gchar _buf[65535];
+
+			g_snprintf(_buf, 65535, "%s?%d", filename, i);
+			playlist_add_url(_buf);
+		}
+
+		fclose(f);
+		free_cue_info();
+	}
+
+	return ret;
+}
+
+InputPlugin *get_iplugin_info(void)
+{
+	cue_ip.description = g_strdup_printf("Cuesheet Container Plugin");
+	return &cue_ip;
+}
+
+/******************************************************** cuefile */
+
+static void free_cue_info(void)
+{
+	g_free(cue_performer);
+	cue_performer = NULL;
+	g_free(cue_title);
+	cue_title = NULL;
+	for (; last_cue_track > 0; last_cue_track--) {
+		g_free(cue_tracks[last_cue_track-1].performer);
+		g_free(cue_tracks[last_cue_track-1].title);
+	}
+}
+
+static void cache_cue_file(FILE *file)
+{
+	gchar line[MAX_CUE_LINE_LENGTH+1];
+
+	while (TRUE) {
+		gint p;
+		gint q;
+
+		if (fgets(line, MAX_CUE_LINE_LENGTH+1, file) == NULL)
+			return;
+
+		for (p = 0; line[p] && isspace(line[p]); p++);
+		if (!line[p])
+			continue;
+		for (q = p; line[q] && !isspace(line[q]); q++);
+		if (!line[q])
+			continue;
+		line[q] = '\0';
+		for (q++; line[q] && isspace(line[q]); q++);
+
+		if (strcasecmp(line+p, "PERFORMER") == 0) {
+			fix_cue_argument(line+q);
+			if (last_cue_track == 0) {
+				if (!g_utf8_validate(line + q, -1, NULL)) {
+					cue_performer = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL);
+				} else
+					cue_performer = g_strdup(line+q);
+			} else {
+				if (!g_utf8_validate(line + q, -1, NULL)) {
+					cue_tracks[last_cue_track-1].performer = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL);
+				} else
+					cue_tracks[last_cue_track-1].performer = g_strdup(line+q);
+			}
+		}
+		else if (strcasecmp(line+p, "FILE") == 0) {
+			fix_cue_argument(line+q);
+			cue_file = g_strdup(line+q);		/* XXX: yaz might need to UTF validate this?? -nenolod */
+		}
+		else if (strcasecmp(line+p, "TITLE") == 0) {
+			fix_cue_argument(line+q);
+			if (last_cue_track == 0) {
+				if (!g_utf8_validate(line + q, -1, NULL)) {
+					cue_title = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL);
+				} else
+					cue_title = g_strdup(line+q);
+			} else {
+				if (!g_utf8_validate(line + q, -1, NULL)) {
+					cue_tracks[last_cue_track-1].title = g_locale_to_utf8 (line + q, -1, NULL, NULL, NULL);
+				} else
+					cue_tracks[last_cue_track-1].title = g_strdup(line+q);
+			}
+		}
+		else if (strcasecmp(line+p, "TRACK") == 0) {
+			gint track;
+
+			fix_cue_argument(line+q);
+			for (p = q; line[p] && isdigit(line[p]); p++);
+			line[p] = '\0';
+			for (; line[q] && line[q] == '0'; q++);
+			if (!line[q])
+				continue;
+			track = atoi(line+q);
+			if (track >= MAX_CUE_TRACKS)
+				continue;
+			last_cue_track = track;
+			cue_tracks[last_cue_track-1].index = 0;
+			cue_tracks[last_cue_track-1].performer = NULL;
+			cue_tracks[last_cue_track-1].title = NULL;
+		}
+		else if (strcasecmp(line+p, "INDEX") == 0) {
+			for (p = q; line[p] && !isspace(line[p]); p++);
+			if (!line[p])
+				continue;
+			for (p++; line[p] && isspace(line[p]); p++);
+			for (q = p; line[q] && !isspace(line[q]); q++);
+			if (q-p >= 8 && line[p+2] == ':' && line[p+5] == ':') {
+				cue_tracks[last_cue_track-1].index =
+						((line[p+0]-'0')*10 + (line[p+1]-'0')) * 60000 +
+						((line[p+3]-'0')*10 + (line[p+4]-'0')) * 1000 +
+						((line[p+6]-'0')*10 + (line[p+7]-'0')) * 10;
+			}
+		}
+	}
+}
+
+static void fix_cue_argument(char *line)
+{
+	if (line[0] == '"') {
+		gchar *l2;
+		for (l2 = line+1; *l2 && *l2 != '"'; l2++)
+				*(l2-1) = *l2;
+			*(l2-1) = *l2;
+		for (; *line && *line != '"'; line++) {
+			if (*line == '\\' && *(line+1)) {
+				for (l2 = line+1; *l2 && *l2 != '"'; l2++)
+					*(l2-1) = *l2;
+				*(l2-1) = *l2;
+			}
+		}
+		*line = '\0';
+	}
+	else {
+		for (; *line && *line != '\r' && *line != '\n'; line++);
+		*line = '\0';
+	}
+}