]> git.sesse.net Git - vlc/commitdiff
Allocation of New buffers seems alright now.
authorJean-Paul Saman <jpsaman@videolan.org>
Sat, 10 Aug 2002 17:54:49 +0000 (17:54 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Sat, 10 Aug 2002 17:54:49 +0000 (17:54 +0000)
modules/codec/mad/decoder.c
modules/codec/mad/libmad.c

index 3d48c69040cc8e22b537f39bc517864a125a1297..a9b07f19707591f4dfd54bd4090a6d77f4f9cb8e 100644 (file)
@@ -219,14 +219,9 @@ static int InitThread( mad_adec_thread_t * p_mad_adec )
 static void EndThread (mad_adec_thread_t * p_mad_adec)
 {
     /* If the audio output fifo was created, we destroy it */
-    if (p_mad_adec->p_aout_fifo != NULL)
+    if (p_mad_adec->p_aout_input != NULL)
     {
         aout_InputDelete( p_mad_adec->p_aout, p_mad_adec->p_aout_input );
-
-        /* Make sure the output thread leaves the NextFrame() function */
-        vlc_mutex_lock (&(p_mad_adec->p_aout_fifo->data_lock));
-        vlc_cond_signal (&(p_mad_adec->p_aout_fifo->data_wait));
-        vlc_mutex_unlock (&(p_mad_adec->p_aout_fifo->data_lock));
     }
 
     /* mad_decoder_finish releases the memory allocated inside the struct */
index f569a45e1d2ad8cbdf2329005c7e820de2a29921..3f0735f7bfdaa354ff7a8123cd2177169ff1437e 100644 (file)
@@ -401,7 +401,7 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
      * is right for the entire audio track.
      */
     if( (p_mad_adec->p_aout_input != NULL) &&
-        ( (p_mad_adec->output_format.i_rate != p_libmad_pcm->samplerate)
+        (p_mad_adec->output_format.i_rate != p_libmad_pcm->samplerate) )
     {
         /* Parameters changed - this should not happen. */
         aout_InputDelete( p_mad_adec->p_aout, p_mad_adec->p_aout_input );
@@ -422,24 +422,27 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
            p_mad_adec->p_fifo->b_error = 1;
            return MAD_FLOW_BREAK;
         }
-        msg_Dbg( p_mad_adec->p_fifo, "aout3 buffer created");
+        msg_Dbg( p_mad_adec->p_fifo, "aout3 input created");
     }
 
-    if (p_mad_adec->output_format->i_rate != p_libmad_pcm->samplerate)
+    if (p_mad_adec->output_format.i_rate != p_libmad_pcm->samplerate)
     {
         msg_Warn( p_mad_adec->p_fifo, "samplerate is changing from [%d] Hz "
                   "to [%d] Hz, sample size [%d], error_code [%0x]",
-                  p_mad_adec->p_aout_fifo->i_rate, p_libmad_pcm->samplerate,
+                  p_mad_adec->output_format.i_rate, p_libmad_pcm->samplerate,
                   p_libmad_pcm->length,
                   p_mad_adec->libmad_decoder->sync->stream.error );
         p_mad_adec->output_format.i_rate = p_libmad_pcm->samplerate;
     }
 
     /* Set the Presentation Time Stamp */
-    p_buffer = aout_BufferNew( p_mad_adec->p_aout, p_mad_adec->p_aout_input,
-                               (p_libmad_pcm->length*4) );
+    p_buffer = aout_BufferNew( p_mad_adec->p_aout,
+                               p_mad_adec->p_aout_input,
+                               (p_libmad_pcm->length*2) );
+
     if ( p_buffer == NULL )
     {
+        msg_Dbg( p_mad_adec->p_fifo, "allocating new buffer failed");
         return MAD_FLOW_BREAK;
     }
     /* Add accurate PTS to buffer. */
@@ -451,9 +454,9 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
     {
         p_buffer->start_date = LAST_MDATE;
     }
-    p_mad_adec->last_date += (mtime_t)(p_libmad_pcm->length*4)
+    p_mad_adec->last_date += (mtime_t)(p_libmad_pcm->length*2)
                              / p_mad_adec->output_format.i_rate;
-    p_buffer->end_date = p_mad_adec->last_date;
+    p_buffer->end_date = p_mad_adec->i_next_pts; // last_date;
 
     /* Interleave and keep buffers in mad_fixed_t format */
     while (nsamples--)
@@ -461,11 +464,11 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
         /* left audio channel */
         sample = *left_ch++;
 #ifndef WORDS_BIGENDIAN
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 0);
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 8);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
 #else
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 8);
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 0);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
 #endif
         /* right audio channel */
         if (p_libmad_pcm->channels == 2)
@@ -473,11 +476,11 @@ enum mad_flow libmad_output3(void *data, struct mad_header const *p_libmad_heade
            sample = *right_ch++;
         } /* else reuse left audio channel */
 #ifndef WORDS_BIGENDIAN
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 0);
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 8);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
 #else
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 8);
-        p_buffer->p_buffer++ = (mad_fixed_t) (sample >> 0);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 8);
+        *(p_buffer->p_buffer)++ = (byte_t) (sample >> 0);
 #endif
     }