[xiph-cvs] cvs commit: ices/src setup.c reencode.c icestypes.h
Brendan
brendan at xiph.org
Thu Mar 13 11:29:25 PST 2003
brendan 03/03/13 14:29:25
Modified: src setup.c reencode.c icestypes.h
Log:
Reset the encoder at every track change no matter what. Appears to do wonders
for stability.
I'll try just doing a full reset on sample rate/bit rate change once I'm sure
this makes everything totally stable.
Remove redundant encoder_init variable.
Revision Changes Path
1.43 +0 -1 ices/src/setup.c
Index: setup.c
===================================================================
RCS file: /cvs/ice/ices/src/setup.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- setup.c 12 Mar 2003 21:21:26 -0000 1.42
+++ setup.c 13 Mar 2003 19:29:24 -0000 1.43
@@ -191,7 +191,6 @@
stream->out_samplerate = -1;
stream->encoder_state = NULL;
- stream->encoder_initialised = 0;
stream->connect_delay = 0;
stream->next = NULL;
<p><p>1.18 +29 -57 ices/src/reencode.c
Index: reencode.c
===================================================================
RCS file: /cvs/ice/ices/src/reencode.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- reencode.c 5 Mar 2003 16:15:44 -0000 1.17
+++ reencode.c 13 Mar 2003 19:29:24 -0000 1.18
@@ -29,9 +29,6 @@
extern ices_config_t ices_config;
-/* -- local prototypes -- */
-static void reencode_lame_init (void);
-
/* Global function definitions */
/* Initialize the reencoding engine in ices, initialize
@@ -51,33 +48,52 @@
if (! ices_config.reencode)
return;
- reencode_lame_init ();
-
ices_log_debug ("Using LAME version %s\n", get_lame_version ());
}
-/* For each song, reset the liblame engine, otherwize it craps out if
+/* For each song, reset the liblame engine, otherwise it craps out if
* the bitrate or sample rate changes */
void
ices_reencode_reset (input_stream_t* source)
{
ices_stream_t* stream;
lame_global_flags* lame;
+ static int decoder_init = 0;
+
+ if (decoder_init) {
+ if (lame_decode_exit () < 0) {
+ ices_log ("LAME: error resetting decoder");
+ ices_setup_shutdown ();
+ }
+ decoder_init = 0;
+ }
if (lame_decode_init () < 0) {
- ices_log ("Error: initialization of liblame's decoder failed!");
+ ices_log ("LAME: error initialising decoder");
ices_setup_shutdown ();
}
+ decoder_init = 1;
- /* notify lame if incoming sample rate changes */
for (stream = ices_config.streams; stream; stream = stream->next) {
if (! stream->reencode)
continue;
+ if (stream->encoder_state)
+ lame_close ((lame_global_flags*)stream->encoder_state);
+
+ if (! (stream->encoder_state = lame_init ())) {
+ ices_log ("LAME: error resetting encoder.");
+ ices_setup_shutdown ();
+ }
+
lame = (lame_global_flags*)stream->encoder_state;
- if (lame_get_in_samplerate (lame) == source->samplerate)
- continue;
+ lame_set_brate (lame, stream->bitrate);
+ if (stream->out_numchannels == 1)
+ lame_set_mode (lame, MONO);
+ if (stream->out_samplerate > 0)
+ lame_set_out_samplerate (lame, stream->out_samplerate);
+ lame_set_original (lame, 0);
lame_set_in_samplerate (lame, source->samplerate);
/* lame_init_params isn't more specific about the problem */
@@ -96,8 +112,10 @@
ices_stream_t* stream;
for (stream = ices_config.streams; stream; stream = stream->next)
- if (stream->encoder_initialised)
+ if (stream->encoder_state) {
lame_close ((lame_global_flags*) stream->encoder_state);
+ stream->encoder_state = NULL;
+ }
}
/* decode buffer, of length buflen, into left and right. Stream-independent
@@ -128,53 +146,7 @@
lame_global_flags* lame = (lame_global_flags*) stream->encoder_state;
int rc;
- /* nogap will cause problems if the next track isn't being reencoded */
-# if 0
- rc = lame_encode_flush_nogap (lame, (char *)outbuf, maxlen);
-# else
rc = lame_encode_flush (lame, (char *)outbuf, maxlen);
-# endif
return rc;
-}
-
-/* Resets the lame engine. Depending on which version of LAME we have, we must
- * do this either only at startup or between each song */
-static void
-reencode_lame_init ()
-{
- ices_stream_t* stream;
- lame_global_flags* lame;
-
- if (! ices_config.reencode)
- return;
-
- for (stream = ices_config.streams; stream; stream = stream->next) {
- if (! stream->reencode)
- continue;
-
- if (! (stream->encoder_state = lame_init ())) {
- ices_log ("LAME: error initializing encoder.");
- ices_setup_shutdown ();
- }
-
- lame = (lame_global_flags*) stream->encoder_state;
-
- lame_set_brate (lame, stream->bitrate);
- if (stream->out_numchannels == 1)
- lame_set_mode (lame, MONO);
- if (stream->out_samplerate > 0)
- lame_set_out_samplerate (lame, stream->out_samplerate);
- lame_set_original (lame, 0);
-
- /* lame_init_params isn't more specific about the problem */
- if (lame_init_params (lame) < 0) {
- ices_log ("LAME: Error setting parameters. Check bitrate, channels, and "
- "sample rate.");
- lame_close (lame);
- ices_setup_shutdown ();
- }
-
- stream->encoder_initialised = 1;
- }
}
<p><p>1.21 +0 -1 ices/src/icestypes.h
Index: icestypes.h
===================================================================
RCS file: /cvs/ice/ices/src/icestypes.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- icestypes.h 12 Mar 2003 21:21:26 -0000 1.20
+++ icestypes.h 13 Mar 2003 19:29:24 -0000 1.21
@@ -39,7 +39,6 @@
time_t connect_delay;
int errs;
void* encoder_state;
- int encoder_initialised;
char *host;
int port;
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list