changeset 3064:43a336a7791b

crossfade-ng: Remove remaining TIMING_COMMENTS cruft.
author William Pitcock <nenolod@atheme.org>
date Fri, 24 Apr 2009 06:28:39 -0500
parents 6a6a731fdaf8
children a0ba6102131d
files src/crossfade/Makefile src/crossfade/cfgutil.c src/crossfade/crossfade.c src/crossfade/timing.c src/crossfade/timing.h
diffstat 5 files changed, 2 insertions(+), 284 deletions(-) [+]
line wrap: on
line diff
--- a/src/crossfade/Makefile	Fri Apr 24 06:24:24 2009 -0500
+++ b/src/crossfade/Makefile	Fri Apr 24 06:28:39 2009 -0500
@@ -10,8 +10,7 @@
        interface-2.0.c			\
        monitor.c			\
        player.c				\
-       support-2.0.c			\
-       timing.c				\
+       support-2.0.c
 
 include ../../buildsys.mk
 include ../../extra.mk
--- a/src/crossfade/cfgutil.c	Fri Apr 24 06:24:24 2009 -0500
+++ b/src/crossfade/cfgutil.c	Fri Apr 24 06:28:39 2009 -0500
@@ -466,8 +466,6 @@
 		xmms_cfg_write_int    (cfgfile, section, "op_max_used_ms",       config->op_max_used_ms);
 
 		/* config items introduced by v0.2.6 */
-		xmms_cfg_write_string (cfgfile, section, "effect_plugin",        config->ep_name ? config->ep_name : DEFAULT_EP_NAME);
-		xmms_cfg_write_boolean(cfgfile, section, "effect_enable",        config->ep_enable);
 		xmms_cfg_write_int    (cfgfile, section, "output_rate",          config->output_rate);
 
 		/* config items introduced by v0.2.7 */
--- a/src/crossfade/crossfade.c	Fri Apr 24 06:24:24 2009 -0500
+++ b/src/crossfade/crossfade.c	Fri Apr 24 06:28:39 2009 -0500
@@ -30,7 +30,6 @@
 #include "cfgutil.h"
 #include "format.h"
 #include "convert.h"
-#include "timing.h"
 
 #include "configure.h"
 #include "monitor.h"
@@ -902,10 +901,7 @@
 xfade_open_audio(AFormat fmt, int rate, int nch)
 {
 	gint pos;
-	gchar *file, *title, *comment;
-#if defined(HAVE_ID3LIB)
-	id3_t id3;
-#endif
+	gchar *file, *title;
 
 	struct timeval tv;
 	glong dt;
@@ -921,7 +917,6 @@
 	pos     = xfplaylist_get_position ();
 	file    = xfplaylist_get_filename (pos);
 	title   = xfplaylist_get_songtitle(pos);
-	comment = playlist_get_fadeinfo ? playlist_get_fadeinfo(pos) : NULL;
 
 	if (!file)
 		file = g_strdup(title);
@@ -952,17 +947,6 @@
 	}
 #endif
 
-	/* try to read comment from ID3 tag */
-#if defined(HAVE_ID3LIB)
-	if (!comment && get_id3(file, &id3))
-		comment = g_strdup(id3.comment);
-#endif
-
-	if (comment)
-		DEBUG(("[crossfade] open_audio: comment=\"%s\"\n", comment))
-	else
-		DEBUG(("[crossfade] open_audio: comment=NULL\n"));
-
 	/* is this an automatic crossfade? */
 	if (last_filename && (fade_config == &config->fc[FADE_CONFIG_XFADE]))
 	{
@@ -1010,114 +994,9 @@
 	g_free(last_filename);
 	last_filename = g_strdup(file);
 
-#if 0
-	/* FIXME: finish this */
-	/* Check if this is a short song. */
-	if (fade_config == &config->fc[FADE_CONFIG_XFADE])
-	{
-		DEBUG(("*** XFADE:\n"));
-		int current_length = playlist_get_current_length();
-		DEBUG(("*** length=%d\n", current_length));
-		if (current_length < 30 * 1000)
-			fade_config = &config->fc[FADE_CONFIG_ALBUM];
-	}
-#endif
-
-#ifdef TIMING_COMMENTS
-	last_timing = current_timing;
-	current_timing. in.enable = FALSE;
-	current_timing.out.enable = FALSE;
-	if (comment)
-	{
-		gchar *str;
-		if ((str = strstr(comment, "fadein=")))
-		{
-			current_timing.in.enable =
-			(3 == sscanf(str + 7, "%d,%d,%d",
-				&current_timing.in.len_ms,
-				&current_timing.in.volume,
-				&current_timing.in.skip_ms));
-			current_timing.in.ofs_ms = 0;  /* not used */
-		}
-
-		if ((str = strstr(comment, "fadeout=")))
-		{
-			current_timing.out.enable =
-			(4 == sscanf(str + 8, "%d,%d,%d,%d",
-				&current_timing.out.len_ms,
-				&current_timing.out.volume,
-				&current_timing.out.skip_ms,
-				&current_timing.out.ofs_ms));
-		}
-	}
-
-#if 0
-	//
-	// use the fade info only on a regular, non-manual songchange
-	//
-	if (fade_config && !((fade_config->config == FADE_CONFIG_XFADE) ||
-	                     (fade_config->config == FADE_CONFIG_ALBUM)))
-	      last_timing.out.enable = FALSE;
-#endif
-
-#if 1	
-	if (last_timing.out.enable || current_timing.in.enable)
-#else
-	if ((last_timing.out.enable || current_timing.in.enable) &&
-	   (!fade_config ||
-	    (fade_config->config == FADE_CONFIG_XFADE) ||
-	    (fade_config->config == FADE_CONFIG_ALBUM)))
-#endif
-	{
-		config->fc[FADE_CONFIG_TIMING].out_len_ms    = xfade_cfg_fadeout_len   (fade_config);
-		config->fc[FADE_CONFIG_TIMING].out_volume    = xfade_cfg_fadeout_volume(fade_config);
-		config->fc[FADE_CONFIG_TIMING].out_skip_ms   = 0;
-		config->fc[FADE_CONFIG_TIMING].ofs_custom_ms = xfade_cfg_offset        (fade_config);
-		config->fc[FADE_CONFIG_TIMING].in_skip_ms    = 0;
-		config->fc[FADE_CONFIG_TIMING].in_len_ms     = xfade_cfg_fadein_len    (fade_config);
-		config->fc[FADE_CONFIG_TIMING].in_volume     = xfade_cfg_fadein_volume (fade_config);
-		config->fc[FADE_CONFIG_TIMING].flush         = fade_config && fade_config->flush;
-
-		if (last_timing.out.enable && current_timing.in.enable)
-			config->fc[FADE_CONFIG_TIMING].ofs_custom_ms = 0;
-
-		if (last_timing.out.enable)
-		{
-			DEBUG(("[crossfade] open_audio: TIMING: out: enable=%d len=%d volume=%d skip=%d ofs=%d\n",
-				last_timing.out.enable,
-				last_timing.out.len_ms,
-				last_timing.out.volume,
-				last_timing.out.skip_ms,
-				last_timing.out.ofs_ms));
-
-			config->fc[FADE_CONFIG_TIMING].out_len_ms     = last_timing.out.len_ms;
-			config->fc[FADE_CONFIG_TIMING].out_volume     = last_timing.out.volume;
-			config->fc[FADE_CONFIG_TIMING].out_skip_ms    = last_timing.out.skip_ms;
-			config->fc[FADE_CONFIG_TIMING].ofs_custom_ms += last_timing.out.ofs_ms;
-		}
-		if (current_timing.in.enable)
-		{
-			DEBUG(("[crossfade] open_audio: TIMING:  in: enable=%d len=%d volume=%d skip=%d\n",
-				current_timing.in.enable,
-				current_timing.in.len_ms,
-				current_timing.in.volume,
-				current_timing.in.skip_ms));
-				
-			config->fc[FADE_CONFIG_TIMING].in_skip_ms     = current_timing.in.skip_ms;
-			config->fc[FADE_CONFIG_TIMING].in_len_ms      = current_timing.in.len_ms;
-			config->fc[FADE_CONFIG_TIMING].in_volume      = current_timing.in.volume;
-			config->fc[FADE_CONFIG_TIMING].ofs_custom_ms -= current_timing.in.ofs_ms; 
-			/* NOTE: in.ofs_ms is currently not used always 0 */
-		}
-		
-		fade_config = &config->fc[FADE_CONFIG_TIMING];
-	}
-#endif
-
 	/* cleanup */
 	g_free(file); file = NULL;
 	g_free(title); title = NULL;
-	g_free(comment); comment = NULL;
 
 	/* check for HTTP streaming */
 	if (config->enable_http_workaround && (0 == strncasecmp(file, "http://", 7)))
--- a/src/crossfade/timing.c	Fri Apr 24 06:24:24 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/* timing.c
- *
- * get timing info based on file name
- *
- * file name should have a comment like this:
- * R(RMS)-T(in):(out):(end)
- * where:
- * - RMS is an indication of the RMS value in between in and out
- *   (to be compared against maximum sample value, 32767 for 16 bit audio)
- * - in, out and end are floats, giving the mixing start and end points
- *   and the length of the file in seconds
- */
-
-#include "timing.h"
-#include "crossfade.h"
-#include "debug.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <locale.h>
-
-#if defined(HAVE_ID3LIB)
-#  include <id3.h>
-#endif
-
-#undef VERBOSE
-
-int
-get_timing_comment(char *filename, quantaudio_t *qa)
-/* 
- * check if the file given has a timing comment
- * return 1 if it does and 0 if it doesn't
- * store the relevant data in quantaudio
- */
-{
-	id3_t id3;
-	int nscanned;
-
-	setlocale(LC_NUMERIC, "C");
-
-	get_id3(filename, &id3);
-	if ((nscanned = sscanf(id3.comment, "R:%d-T:%f:%f:%f", &qa->RMS, &qa->mix_in, &qa->mix_out, &qa->length)) < 4)
-	{
-		/* tag not right */
-#ifdef VERBOSE
-		DEBUG(("[crossfade] get_timing_comment: no quantaudio comment\n"));
-		DEBUG(("[crossfade] get_timing_comment: nscanned=%d (\"%s\")\n", nscanned, id3.comment));
-		DEBUG(("[crossfade] get_timing_comment: in %.2f, out %.2f, length %.2f, RMS %d\n",
-			qa->mix_in, qa->mix_out, qa->length, qa->RMS));
-#endif
-		return 0;
-	}
-	else
-	{
-#ifdef VERBOSE
-		DEBUG(("[crossfade] get_timing_comment: in %.2f, out %.2f, length %.2f, RMS %d\n",
-			qa->mix_in, qa->mix_out, qa->length, qa->RMS));
-#endif
-		return 1;
-	}
-}
-
-int
-get_id3(char *filename, id3_t *id3)
-#if defined(HAVE_ID3LIB)
-/* get the id3 tag of this file.  Return 0 when failed or 1 when ok */
-{
-	int status = 0;
-	ID3Tag *tag;
-	memset(id3, 0, sizeof(*id3));
-
-	if ((tag = ID3Tag_New()) != NULL)
-	{
-		ID3Frame *frame;
-		(void) ID3Tag_Link(tag, filename);
-
-		if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_COMMENT)) != NULL)
-		{
-			ID3Field *field;
-			if ((field = ID3Frame_GetField(frame, ID3FN_TEXT)) != NULL)
-			{
-				(void) ID3Field_GetASCII(field, id3->comment, sizeof(id3->comment));
-				DEBUG(("[crossfade] get_id3: comment: %s\n", id3->comment));
-				status = 1;
-			}
-		}
-
-		if ((frame = ID3Tag_FindFrameWithID(tag, ID3FID_TRACKNUM)) != NULL)
-		{
-			ID3Field *field;
-			if ((field = ID3Frame_GetField(frame, ID3FN_TEXT)) != NULL)
-			{
-				char buf[32];
-				     buf[0] = 0;
-				(void) ID3Field_GetASCII(field, buf, sizeof(buf));
-				id3->track = atoi(buf);
-				DEBUG(("[crossfade] get_id3: track: %d\n", id3->track));
-				status = 1;
-			}
-		}
-		
-		ID3Tag_Delete(tag);
-	}
-
-	return status;
-}
-#else
-{
-	FILE *fp;
-	memset(id3, 0, sizeof(*id3));
-	
-	fp = fopen(filename, "r");	/* read only */
-	if (fp == NULL)
-	{
-		/* file didn't open */
-		DEBUG(("[crossfade] get_id3: file %s didn't open !\n", filename));
-		return 0;
-	}
-	if (fseek(fp, -128, SEEK_END) < 0)
-	{
-		/* problem rewinding */
-		DEBUG(("[crossfade] get_id3: problem rewinding on %s !\n", filename));
-		return 0;
-	}
-	else
-	{
-		/* we rewound successfully */
-		if (fread(id3, 128, 1, fp) < 0)
-		{
-			/* read error */
-			DEBUG(("[crossfade] get_id3: read error on %s !\n", filename));
-			return 0;
-		}
-	}
-
-	return 1;
-}
-#endif
--- a/src/crossfade/timing.h	Fri Apr 24 06:24:24 2009 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/* quantaudio parameters */
-typedef struct
-{
-	int RMS;
-	float mix_in;
-	float mix_out;
-	float length;
-}
-quantaudio_t;
-
-/* id3 stuff is taken from the id3 GPL program */
-typedef struct
-{
-	char comment[1024];
-	int track;
-}
-id3_t;
-
-int get_timing_comment(char *filename, quantaudio_t *qa);
-int get_id3(char *filename, id3_t *id3);