]> git.sesse.net Git - vlc/blobdiff - src/ac3_decoder/ac3_decoder_thread.c
* Mandatory step for video output IV and the audio output quality
[vlc] / src / ac3_decoder / ac3_decoder_thread.c
index b37c1af132bf0a27a8d3184c0817dd46cf78e612..278942cb0a422930e32a272c9763d653b877ca5d 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_decoder_thread.c: ac3 decoder thread
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: ac3_decoder_thread.c,v 1.28 2001/04/20 12:14:34 reno Exp $
+ * $Id: ac3_decoder_thread.c,v 1.31 2001/05/01 04:18:18 sam Exp $
  *
  * Authors: Michel Lespinasse <walken@zoy.org>
  *
@@ -97,7 +97,6 @@ vlc_thread_t ac3dec_CreateThread( adec_config_t * p_config )
     /*
      * Initialize the output properties
      */
-    p_ac3dec_t->p_aout = p_config->p_aout;
     p_ac3dec_t->p_aout_fifo = NULL;
 
     /* Spawn the ac3 decoder thread */
@@ -120,36 +119,21 @@ vlc_thread_t ac3dec_CreateThread( adec_config_t * p_config )
  *****************************************************************************/
 static int InitThread (ac3dec_thread_t * p_ac3dec_t)
 {
-    aout_fifo_t         aout_fifo;
-
     intf_DbgMsg("ac3dec debug: initializing ac3 decoder thread %p",p_ac3dec_t);
 
     p_ac3dec_t->p_config->decoder_config.pf_init_bit_stream(
             &p_ac3dec_t->ac3_decoder.bit_stream,
-            p_ac3dec_t->p_config->decoder_config.p_decoder_fifo );
-    p_ac3dec_t->ac3_decoder.bit_stream.pf_bitstream_callback=BitstreamCallback;
-    p_ac3dec_t->ac3_decoder.bit_stream.p_callback_arg = (void *) p_ac3dec_t;
-
-    
-    aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO;
-    aout_fifo.i_channels = 2;
-    aout_fifo.b_stereo = 1;
-
-    aout_fifo.l_frame_size = AC3DEC_FRAME_SIZE;
+            p_ac3dec_t->p_config->decoder_config.p_decoder_fifo,
+            BitstreamCallback, (void *) p_ac3dec_t );
 
     /* Creating the audio output fifo */
-    if ((p_ac3dec_t->p_aout_fifo = aout_CreateFifo(p_ac3dec_t->p_aout, &aout_fifo)) == NULL)
+    p_ac3dec_t->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, 2, 0, 0,
+                                               AC3DEC_FRAME_SIZE, NULL  );
+    if ( p_ac3dec_t->p_aout_fifo == NULL )
     {
         return -1;
     }
 
-    /* InitBitstream has normally begun to read a PES packet, get its
-     * PTS/DTS */
-     if( !p_ac3dec_t->p_fifo->b_die )
-     {
-        BitstreamCallback( &p_ac3dec_t->ac3_decoder.bit_stream, 1 );
-     }
-
     intf_DbgMsg("ac3dec debug: ac3 decoder thread %p initialized", p_ac3dec_t);
     return 0;
 }
@@ -178,13 +162,22 @@ static void RunThread (ac3dec_thread_t * p_ac3dec_t)
     {
         s16 * buffer;
         ac3_sync_info_t sync_info;
-                        
+        int ptr;
+
         if (!sync) {
             do {
                 GetBits(&p_ac3dec_t->ac3_decoder.bit_stream,8);
             } while ((!p_ac3dec_t->sync_ptr) && (!p_ac3dec_t->p_fifo->b_die)
                     && (!p_ac3dec_t->p_fifo->b_error));
-
+            
+            ptr = p_ac3dec_t->sync_ptr;
+
+            while(ptr-- && (!p_ac3dec_t->p_fifo->b_die)
+                && (!p_ac3dec_t->p_fifo->b_error))
+            {
+                p_ac3dec_t->ac3_decoder.bit_stream.p_byte++;
+            }
+                        
             /* we are in sync now */
             sync = 1;
         }