Commit 38573f3b authored by Jean-Paul Saman's avatar Jean-Paul Saman

Removed aout_CreateFifo from mad_adec.c InitThread() and added it to mad_libmad.c in mad_libmad.c

parent 37759cf5
......@@ -67,7 +67,7 @@ MODULE_CONFIG_STOP
MODULE_INIT_START
SET_DESCRIPTION( "Libmad MPEG 1/2/3 audio decoder library" )
ADD_CAPABILITY( DECODER, 950 )
ADD_CAPABILITY( DECODER, 50 )
ADD_SHORTCUT( "mad" )
MODULE_INIT_STOP
......@@ -190,19 +190,20 @@ static int InitThread( mad_adec_thread_t * p_mad_adec )
/*
* Initialize the output properties
*/
p_mad_adec->p_aout_fifo=NULL;
/* Creating the audio output fifo */
p_mad_adec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, /* fifo type */
2, /* nr. of channels */
48000, /* frame rate in Hz ?*/
0, /* units */
ADEC_FRAME_SIZE/2, /* frame size */
NULL ); /* buffer */
if ( p_mad_adec->p_aout_fifo == NULL )
{
return( -1 );
}
// p_mad_adec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, /* fifo type */
// 2, /* nr. of channels */
// 48000, /* frame rate in Hz ?*/
// 0, /* units */
// ADEC_FRAME_SIZE/2, /* frame size */
// NULL ); /* buffer */
//
// if ( p_mad_adec->p_aout_fifo == NULL )
// {
// return( -1 );
// }
intf_ErrMsg("mad_adec debug: mad decoder thread %p initialized", p_mad_adec);
......
......@@ -224,6 +224,24 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
static struct audio_dither dither;
#endif
/* Creating the audio output fifo */
if (p_mad_adec->p_aout_fifo==NULL) {
p_mad_adec->p_aout_fifo = aout_CreateFifo(
AOUT_ADEC_STEREO_FIFO, /* fifo type */
p_libmad_pcm->channels, /* nr. of channels */
p_libmad_pcm->samplerate, /* frame rate in Hz ?*/
0, /* units */
ADEC_FRAME_SIZE/2, /* frame size */
NULL ); /* buffer */
if ( p_mad_adec->p_aout_fifo == NULL )
{
return( -1 );
}
intf_ErrMsg("mad_adec debug: in libmad_output aout fifo created");
}
/* Set timestamp to synchronize audio and video decoder fifo's */
vlc_mutex_lock (&p_mad_adec->p_aout_fifo->data_lock);
p_mad_adec->p_aout_fifo->l_rate = p_libmad_header->samplerate;
......@@ -231,23 +249,23 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
buffer = ((byte_t *)p_mad_adec->p_aout_fifo->buffer) + (p_mad_adec->p_aout_fifo->l_end_frame * ADEC_FRAME_SIZE);
if (p_libmad_pcm->channels == 2)
while (nsamples--)
{
while (nsamples--)
{
#ifdef MPG321_ROUTINES
sample = audio_linear_dither(16, *left_ch++, &dither);
sample = audio_linear_dither(16, *left_ch++, &dither);
#else
sample = s24_to_s16_pcm(*left_ch++);
sample = s24_to_s16_pcm(*left_ch++);
#endif
#ifndef WORDS_BIGENDIAN
*buffer++ = (byte_t) (sample) & 0xFF;
*buffer++ = (byte_t) (sample >> 8) & 0xFF;
*buffer++ = (byte_t) (sample) & 0xFF;
*buffer++ = (byte_t) (sample >> 8) & 0xFF;
#else
*buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample);
*buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample);
#endif
if (p_libmad_pcm->channels == 2) {
/* right audio channel */
#ifdef MPG321_ROUTINES
sample = audio_linear_dither(16, *right_ch++, &dither);
......@@ -256,32 +274,13 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
#endif
#ifndef WORDS_BIGENDIAN
*buffer++ = (byte_t) (sample);
*buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample) & 0xFF;
*buffer++ = (byte_t) (sample >> 8) & 0xFF;
#else
*buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample);
#endif
}
}
else
{
while (nsamples--)
{
#ifdef MPG321_ROUTINES
sample = audio_linear_dither(16, *left_ch++, &dither);
#else
sample = s24_to_s16_pcm(*left_ch++);
#endif
#ifndef WORDS_BIGENDIAN
*buffer++ = (byte_t) (sample);
*buffer++ = (byte_t) (sample >> 8);
#else
*buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample);
#endif
}
}
// vlc_mutex_lock (&p_mad_adec->p_aout_fifo->data_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment