summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-09-01 21:56:38 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-09-01 21:56:38 +0000
commitfc3af7a5b93200cabea2e0eb9c1f441a875c6ddd (patch)
tree1f981102cef5a2488c225070b629a970de766472 /src
parentb380ee8722d63c57a2b193fa2968ffd0ed633ccb (diff)
downloadxine-lib-fc3af7a5b93200cabea2e0eb9c1f441a875c6ddd.tar.gz
xine-lib-fc3af7a5b93200cabea2e0eb9c1f441a875c6ddd.tar.bz2
sometimes mpeg audio streams change parameters, other times libmad is simply wrong guess them and corrects it's guesses later - so let's take care of that
CVS patchset: 546 CVS date: 2001/09/01 21:56:38
Diffstat (limited to 'src')
-rw-r--r--src/libmad/xine_decoder.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/libmad/xine_decoder.c b/src/libmad/xine_decoder.c
index bc0ac59b6..6ca98cc85 100644
--- a/src/libmad/xine_decoder.c
+++ b/src/libmad/xine_decoder.c
@@ -17,7 +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: xine_decoder.c,v 1.3 2001/09/01 17:59:42 jkeil Exp $
+ * $Id: xine_decoder.c,v 1.4 2001/09/01 21:56:38 guenter Exp $
*
* stuff needed to turn libmad into a xine decoder plugin
*/
@@ -43,9 +43,10 @@ typedef struct mad_decoder_s {
struct mad_stream stream;
struct mad_frame frame;
- ao_instance_t *audio_out;
+ ao_instance_t *audio_out;
int output_sampling_rate;
int output_open;
+ int output_mode;
int16_t samples[MAX_NUM_SAMPLES];
@@ -158,18 +159,26 @@ static void mad_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) {
}
} else {
+ int mode = (this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? AO_CAP_MODE_MONO : AO_CAP_MODE_STEREO;
- if (!this->output_open) {
+ if (!this->output_open
+ || (this->output_sampling_rate != this->frame.header.samplerate)
+ || (this->output_mode != mode)) {
- printf ("libmad: audio sample rate %d mode %d\n",
+ printf ("libmad: audio sample rate %d mode %08x\n",
this->frame.header.samplerate,
- this->frame.header.mode);
+ mode);
+
+ if (this->output_open)
+ this->audio_out->close (this->audio_out);
this->audio_out->open(this->audio_out,
16, this->frame.header.samplerate,
- (this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? AO_CAP_MODE_MONO : AO_CAP_MODE_STEREO);
+ mode);
+
this->output_open = 1;
this->output_sampling_rate = this->frame.header.samplerate;
+ this->output_mode = mode;
}
mad_synth_frame (&this->synth, &this->frame);