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 ...@@ -67,7 +67,7 @@ MODULE_CONFIG_STOP
MODULE_INIT_START MODULE_INIT_START
SET_DESCRIPTION( "Libmad MPEG 1/2/3 audio decoder library" ) SET_DESCRIPTION( "Libmad MPEG 1/2/3 audio decoder library" )
ADD_CAPABILITY( DECODER, 950 ) ADD_CAPABILITY( DECODER, 50 )
ADD_SHORTCUT( "mad" ) ADD_SHORTCUT( "mad" )
MODULE_INIT_STOP MODULE_INIT_STOP
...@@ -190,19 +190,20 @@ static int InitThread( mad_adec_thread_t * p_mad_adec ) ...@@ -190,19 +190,20 @@ static int InitThread( mad_adec_thread_t * p_mad_adec )
/* /*
* Initialize the output properties * Initialize the output properties
*/ */
p_mad_adec->p_aout_fifo=NULL;
/* Creating the audio output fifo */ /* Creating the audio output fifo */
p_mad_adec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, /* fifo type */ // p_mad_adec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, /* fifo type */
2, /* nr. of channels */ // 2, /* nr. of channels */
48000, /* frame rate in Hz ?*/ // 48000, /* frame rate in Hz ?*/
0, /* units */ // 0, /* units */
ADEC_FRAME_SIZE/2, /* frame size */ // ADEC_FRAME_SIZE/2, /* frame size */
NULL ); /* buffer */ // NULL ); /* buffer */
//
if ( p_mad_adec->p_aout_fifo == NULL ) // if ( p_mad_adec->p_aout_fifo == NULL )
{ // {
return( -1 ); // return( -1 );
} // }
intf_ErrMsg("mad_adec debug: mad decoder thread %p initialized", p_mad_adec); 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 ...@@ -224,6 +224,24 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
static struct audio_dither dither; static struct audio_dither dither;
#endif #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 */ /* Set timestamp to synchronize audio and video decoder fifo's */
vlc_mutex_lock (&p_mad_adec->p_aout_fifo->data_lock); vlc_mutex_lock (&p_mad_adec->p_aout_fifo->data_lock);
p_mad_adec->p_aout_fifo->l_rate = p_libmad_header->samplerate; p_mad_adec->p_aout_fifo->l_rate = p_libmad_header->samplerate;
...@@ -231,8 +249,6 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header ...@@ -231,8 +249,6 @@ 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); 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 #ifdef MPG321_ROUTINES
...@@ -248,6 +264,8 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header ...@@ -248,6 +264,8 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
*buffer++ = (byte_t) (sample >> 8); *buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample); *buffer++ = (byte_t) (sample);
#endif #endif
if (p_libmad_pcm->channels == 2) {
/* right audio channel */ /* right audio channel */
#ifdef MPG321_ROUTINES #ifdef MPG321_ROUTINES
sample = audio_linear_dither(16, *right_ch++, &dither); sample = audio_linear_dither(16, *right_ch++, &dither);
...@@ -256,27 +274,8 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header ...@@ -256,27 +274,8 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
#endif #endif
#ifndef WORDS_BIGENDIAN #ifndef WORDS_BIGENDIAN
*buffer++ = (byte_t) (sample); *buffer++ = (byte_t) (sample) & 0xFF;
*buffer++ = (byte_t) (sample >> 8); *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 #else
*buffer++ = (byte_t) (sample >> 8); *buffer++ = (byte_t) (sample >> 8);
*buffer++ = (byte_t) (sample); *buffer++ = (byte_t) (sample);
......
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