]> git.sesse.net Git - vlc/commitdiff
- Correction du bug de la synchro.
authorJean-Marc Dressler <polux@videolan.org>
Thu, 30 Mar 2000 12:54:29 +0000 (12:54 +0000)
committerJean-Marc Dressler <polux@videolan.org>
Thu, 30 Mar 2000 12:54:29 +0000 (12:54 +0000)
  Le probl�me provenait d'un d�calage d'une seconde qui avait �t� rajout�
  dans le calcul de la date dans audio_output.c :
  p_aout->date = -1000000 + mdate() + ( (((mtime_t)(l_bytes / 4)) * 1000000)
                                        / ((mtime_t)p_aout->l_rate) );
  C'est le -1000000 qui faisait retarder le son d'exactement une seconde.
  J'aimerais bien savoir pourquoi il a �t� rajout� car peut-�tre y-a-t-il
  d'autres bugs similaires qui ne sont pas visibles pour l'instant.

- Nettoyage d'une partie du code de audio_decoder_thread.c
  Il est vraiment tr�s dommage que les conventions de codage ne soient pas
  respect�es, si il y en a ce n'est pas pour rien. De plus le m�lange
  d'espaces et de tabulations rend le code tr�s peu lisible. Je le
  rappelle, nous n'utilisons que des indentations de 4 espaces et toute
  tabulation est proscrite. Il serait bien de changer le reste du code
  pour qu'il respecte les conventions et reste ainsi facilement lisible
  par tout le monde.

src/audio_decoder/audio_decoder_thread.c
src/audio_output/audio_output.c

index 3a99643d52851b8e8eabfd02f35037c9513b6eeb..83ae6c76257e0cd4937702e23b7b3c927875a9fe 100644 (file)
@@ -216,71 +216,79 @@ static void RunThread (adec_thread_t * p_adec)
     msleep (INPUT_PTS_DELAY);
 
     /* Initializing the audio decoder thread */
-    if (InitThread (p_adec)) {
+    if( InitThread (p_adec) )
+    {
         p_adec->b_error = 1;
     }
 
     sync = 0;
 
     /* Audio decoder thread's main loop */
-    while ((!p_adec->b_die) && (!p_adec->b_error)) {
-       s16 * buffer;
-       adec_sync_info_t sync_info;
-
-       if (!sync) {    /* have to find a synchro point */
-           adec_byte_stream_t * p_byte_stream;
-
-           printf ("sync\n");
-
-           p_adec->align = 0;
-
-           p_byte_stream = adec_byte_stream (&p_adec->audio_decoder);
-           do {
-               adec_byte_stream_next (p_byte_stream);
-           } while ((!p_adec->align) &&
-                    (!p_adec->b_die) && 
-                    (!p_adec->b_error));
-
-           sync = 1;
-       }
-
-       if (DECODER_FIFO_START(p_adec->fifo)->b_has_pts) {
-           p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_adec->fifo)->i_pts;
-           DECODER_FIFO_START(p_adec->fifo)->b_has_pts = 0;
-       } else {
-           p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
-       }
+    while( (!p_adec->b_die) && (!p_adec->b_error) )
+    {
+        s16 * buffer;
+        adec_sync_info_t sync_info;
+
+        if (!sync)
+        {      
+            /* have to find a synchro point */
+            adec_byte_stream_t * p_byte_stream;
+            
+            printf ("sync\n");
+            
+            p_adec->align = 0;
+            p_byte_stream = adec_byte_stream (&p_adec->audio_decoder);
+            do 
+            {
+                adec_byte_stream_next (p_byte_stream);
+            } while ((!p_adec->align) && (!p_adec->b_die) &&  (!p_adec->b_error));
+
+               sync = 1;
+           }
+
+        if( DECODER_FIFO_START(p_adec->fifo)->b_has_pts )
+        {
+            p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(p_adec->fifo)->i_pts;
+            DECODER_FIFO_START(p_adec->fifo)->b_has_pts = 0;
+        }
+        else
+        {
+            p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
+           }
 
-       if (adec_sync_frame (&p_adec->audio_decoder, &sync_info)) {
-           sync = 0;
-           goto bad_frame;
-       }
+        if( adec_sync_frame (&p_adec->audio_decoder, &sync_info) )
+        {
+            sync = 0;
+            goto bad_frame;
+           }
 
-       p_adec->p_aout_fifo->l_rate = sync_info.sample_rate;
+        p_adec->p_aout_fifo->l_rate = sync_info.sample_rate;
 
-       buffer = ((s16 *)p_adec->p_aout_fifo->buffer) + (p_adec->p_aout_fifo->l_end_frame * ADEC_FRAME_SIZE);
+        buffer = ((s16 *)p_adec->p_aout_fifo->buffer) + (p_adec->p_aout_fifo->l_end_frame * ADEC_FRAME_SIZE);
 
-       if (adec_decode_frame (&p_adec->audio_decoder, buffer)) {
-           sync = 0;
-           goto bad_frame;
-       }
+           if( adec_decode_frame (&p_adec->audio_decoder, buffer) )
+        {
+            sync = 0;
+            goto bad_frame;
+        }
 
-       vlc_mutex_lock (&p_adec->p_aout_fifo->data_lock);
+        vlc_mutex_lock (&p_adec->p_aout_fifo->data_lock);
 
-       p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
-       vlc_cond_signal (&p_adec->p_aout_fifo->data_wait);
-       vlc_mutex_unlock (&p_adec->p_aout_fifo->data_lock);
+        p_adec->p_aout_fifo->l_end_frame = (p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
+        vlc_cond_signal (&p_adec->p_aout_fifo->data_wait);
+        vlc_mutex_unlock (&p_adec->p_aout_fifo->data_lock);
 
-    bad_frame:
+        bad_frame:
     }
 
     /* If b_error is set, the audio decoder thread enters the error loop */
-    if (p_adec->b_error) {
-        ErrorThread (p_adec);
+    if( p_adec->b_error ) 
+    {
+        ErrorThread( p_adec );
     }
 
     /* End of the audio decoder thread */
-    EndThread (p_adec);
+    EndThread( p_adec );
 }
 
 /*****************************************************************************
index d5d89561a9ada1ee6f669606bb9fe3349e0d6fe8..d77c1022e7ce751fc016c2220527fc0a2e82b592 100644 (file)
@@ -1113,7 +1113,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
         }
 
         l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit );
-        p_aout->date = -1000000 + mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(s16) << (p_aout->b_stereo) == 4 */
+        p_aout->date = mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(s16) << (p_aout->b_stereo) == 4 */
         p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) );
         if ( l_bytes > (l_buffer_limit * sizeof(s16)) )
         {