[xiph-commits] r7381 - icecast/trunk/ices0/src

brendan at dactyl.lonelymoon.com brendan
Tue Jul 27 15:25:28 PDT 2004


Author: brendan
Date: Tue Jul 27 15:25:28 2004
New Revision: 7381

Removed:
icecast/trunk/ices0/src/plugin.h
Modified:
icecast/trunk/ices0/src/Makefile.am
icecast/trunk/ices0/src/crossfade.c
icecast/trunk/ices0/src/definitions.h
icecast/trunk/ices0/src/icestypes.h
icecast/trunk/ices0/src/stream.c
Log:
Pass input stream to plugin during new_track call.
Don't crossfade tracks that are less than twice the fade duration in length
(if we can guess the length).


Modified: icecast/trunk/ices0/src/Makefile.am
===================================================================
--- icecast/trunk/ices0/src/Makefile.am	2004-07-27 21:44:28 UTC (rev 7380)
+++ icecast/trunk/ices0/src/Makefile.am	2004-07-27 22:25:26 UTC (rev 7381)
@@ -6,7 +6,7 @@

noinst_HEADERS = icestypes.h definitions.h setup.h log.h stream.h util.h \
cue.h metadata.h in_vorbis.h mp3.h id3.h signals.h reencode.h \
-	ices_config.h plugin.h
+	ices_config.h

ices_SOURCES = ices.c log.c setup.c stream.c util.c mp3.c cue.c metadata.c \
id3.c signals.c crossfade.c

Modified: icecast/trunk/ices0/src/crossfade.c
===================================================================
--- icecast/trunk/ices0/src/crossfade.c	2004-07-27 21:44:28 UTC (rev 7380)
+++ icecast/trunk/ices0/src/crossfade.c	2004-07-27 22:25:26 UTC (rev 7381)
@@ -20,9 +20,8 @@
*/

#include "definitions.h"
-#include "plugin.h"

-static void cf_new_track(void);
+static void cf_new_track(input_stream_t *source);
static int cf_process(int ilen, int16_t* il, int16_t* ir);

static ices_plugin_t Crossfader = {
@@ -35,12 +34,12 @@
};

static int NewTrack = 0;
-static int FadeSecs = 3;
static int FadeSamples;
static int16_t* FL;
static int16_t* FR;
static int fpos = 0;
static int flen = 0;
+static int skipnext = 0;

/* public functions */
ices_plugin_t *crossfade_plugin(int secs) {
@@ -53,7 +52,24 @@
}

/* private functions */
-static void cf_new_track(void) {
+static void cf_new_track(input_stream_t *source) {
+  int filesecs;
+
+  /* turn off crossfading for tracks less than twice the length of the fade */
+  if (skipnext) {
+    skipnext = 0;
+    return;
+  }
+
+  if (source->filesize && source->bitrate) {
+    filesecs = source->filesize / (source->bitrate * 128);
+    if (filesecs < FadeSamples * 2 / 44100) {
+      ices_log_debug("crossfade: not fading short track of %d secs", filesecs);
+      skipnext = 1;
+      return;
+    }
+  }
+
NewTrack = FadeSamples;
}


Modified: icecast/trunk/ices0/src/definitions.h
===================================================================
--- icecast/trunk/ices0/src/definitions.h	2004-07-27 21:44:28 UTC (rev 7380)
+++ icecast/trunk/ices0/src/definitions.h	2004-07-27 22:25:26 UTC (rev 7381)
@@ -109,7 +109,6 @@
#include "reencode.h"
#include "ices_config.h"
#include "playlist/playlist.h"
-#include "plugin.h"

#define BUFSIZE 8192
#define ICES_DEFAULT_HOST "127.0.0.1"

Modified: icecast/trunk/ices0/src/icestypes.h
===================================================================
--- icecast/trunk/ices0/src/icestypes.h	2004-07-27 21:44:28 UTC (rev 7380)
+++ icecast/trunk/ices0/src/icestypes.h	2004-07-27 22:25:26 UTC (rev 7381)
@@ -22,8 +22,6 @@
#ifndef _ICES_ICESTYPES_H
#define _ICES_ICESTYPES_H

-#include "plugin.h"
-
typedef enum {
icy_protocol_e,
xaudiocast_protocol_e,
@@ -77,19 +75,6 @@
void (*shutdown) (void);
} playlist_module_t;

-typedef struct {
-  int daemon;
-  int verbose;
-  int reencode;
-  char *configfile;
-  char *base_directory;
-  FILE *logfile;
-
-  ices_stream_t* streams;
-  playlist_module_t pm;
-  ices_plugin_t *plugin;
-} ices_config_t;
-
/* -- input stream types -- */
typedef enum {
ICES_INPUT_VORBIS,
@@ -116,4 +101,26 @@
int16_t* right);
int (*close)(struct _input_stream_t* self);
} input_stream_t;
+
+typedef struct _ices_plugin {
+  const char *name;
+
+  void (*new_track)(input_stream_t *source);
+  int (*process)(int ilen, int16_t *il, int16_t *ir);
+
+  struct _ices_plugin *next;
+} ices_plugin_t;
+
+typedef struct {
+  int daemon;
+  int verbose;
+  int reencode;
+  char *configfile;
+  char *base_directory;
+  FILE *logfile;
+
+  ices_stream_t* streams;
+  playlist_module_t pm;
+  ices_plugin_t *plugin;
+} ices_config_t;
#endif

Deleted: icecast/trunk/ices0/src/plugin.h
===================================================================
--- icecast/trunk/ices0/src/plugin.h	2004-07-27 21:44:28 UTC (rev 7380)
+++ icecast/trunk/ices0/src/plugin.h	2004-07-27 22:25:26 UTC (rev 7381)
@@ -1,36 +0,0 @@
-/* plugin.h
- * Audio plugin API
- * Copyright (c) 2004 Brendan Cully <brendan at xiph.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * $Id$
- */
-
-#ifndef _ICES_PLUGIN_H_
-#define _ICES_PLUGIN_H_ 1
-
-typedef struct _ices_plugin {
-  const char *name;
-
-  void (*new_track)(void);
-  int (*process)(int ilen, int16_t *il, int16_t *ir);
-
-  struct _ices_plugin *next;
-} ices_plugin_t;
-
-ices_plugin_t *crossfade_plugin(int secs);
-
-#endif

Modified: icecast/trunk/ices0/src/stream.c
===================================================================
--- icecast/trunk/ices0/src/stream.c	2004-07-27 21:44:28 UTC (rev 7380)
+++ icecast/trunk/ices0/src/stream.c	2004-07-27 22:25:26 UTC (rev 7381)
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*
+ * $Id$
*/

#include "definitions.h"
@@ -166,7 +167,7 @@
if (config->plugin) {
decode = 1;
for (plugin = config->plugin; plugin; plugin = plugin->next)
-	config->plugin->new_track();
+	config->plugin->new_track(source);
} else
for (stream = config->streams; stream; stream = stream->next)
if (stream->reencode && stream_needs_reencoding (source, stream)) {



More information about the commits mailing list