[vlc-commits] aout: move sync date from input to aout structure

Rémi Denis-Courmont git at videolan.org
Sat Aug 6 21:53:22 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug  6 21:58:02 2011 +0300| [94b75f19cacef6a68d338a925bf3028ea0e54dec] | committer: Rémi Denis-Courmont

aout: move sync date from input to aout structure

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=94b75f19cacef6a68d338a925bf3028ea0e54dec
---

 src/audio_output/aout_internal.h |   10 ++++++----
 src/audio_output/dec.c           |   21 +++++++++++----------
 src/audio_output/input.c         |   18 +++++-------------
 3 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 80c218d..e03dd32 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -85,9 +85,6 @@ struct aout_input_t
     /* */
     bool                b_recycle_vout;
     aout_request_vout_t request_vout;
-
-    /* */
-    date_t                  date;
 };
 
 typedef struct
@@ -98,6 +95,11 @@ typedef struct
 
     struct
     {
+        date_t date;
+    } sync;
+
+    struct
+    {
         vlc_mutex_t lock;
         float multiplier; /**< Software volume amplification multiplier */
         struct audio_mixer *mixer; /**< Software volume plugin */
@@ -131,7 +133,7 @@ static inline aout_owner_t *aout_owner (audio_output_t *aout)
 int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_request_vout_t * );
 int aout_InputDelete( audio_output_t * p_aout, aout_input_t * p_input );
 block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
-                         block_t *p_buffer, int i_input_rate );
+                         block_t *p_buffer, int i_input_rate, date_t * );
 void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input );
 
 /* From filters.c : */
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 5a83978..0f3adda 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -109,6 +109,9 @@ int aout_DecNew( audio_output_t *p_aout,
         goto error;
     }
 
+    date_Init (&owner->sync.date, owner->mixer_format.i_rate, 1);
+    date_Set (&owner->sync.date, VLC_TS_INVALID);
+
     owner->input = p_input;
     aout_InputNew( p_aout, p_input, p_request_vout );
     aout_unlock( p_aout );
@@ -244,10 +247,12 @@ int aout_DecPlay (audio_output_t *p_aout, block_t *p_buffer, int i_input_rate)
     aout_InputCheckAndRestart( p_aout, p_input );
 
     /* Input */
-    p_buffer = aout_InputPlay( p_aout, p_input, p_buffer, i_input_rate );
-
+    p_buffer = aout_InputPlay (p_aout, p_input, p_buffer, i_input_rate,
+                               &owner->sync.date);
     if( p_buffer != NULL )
     {
+        date_Increment (&owner->sync.date, p_buffer->i_nb_samples);
+
         /* Mixer */
         float amp = owner->volume.multiplier * p_input->multiplier;
         aout_MixerRun (owner->volume.mixer, p_buffer, amp);
@@ -277,12 +282,10 @@ int aout_DecGetResetLost (audio_output_t *aout)
 void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
 {
     aout_owner_t *owner = aout_owner (aout);
-    aout_input_t *p_input = owner->input;
 
     aout_lock (aout);
-
-    /* XXX: Should the input date be offset by the pause duration instead? */
-    date_Set (&p_input->date, VLC_TS_INVALID);
+    /* XXX: Should the date be offset by the pause duration instead? */
+    date_Set (&owner->sync.date, VLC_TS_INVALID);
     aout_OutputPause (aout, paused, date);
     aout_unlock (aout);
 }
@@ -290,10 +293,9 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
 void aout_DecFlush (audio_output_t *aout)
 {
     aout_owner_t *owner = aout_owner (aout);
-    aout_input_t *input = owner->input;
 
     aout_lock (aout);
-    date_Set (&input->date, VLC_TS_INVALID);
+    date_Set (&owner->sync.date, VLC_TS_INVALID);
     aout_OutputFlush (aout, false);
     aout_unlock (aout);
 }
@@ -301,12 +303,11 @@ void aout_DecFlush (audio_output_t *aout)
 bool aout_DecIsEmpty (audio_output_t *aout)
 {
     aout_owner_t *owner = aout_owner (aout);
-    aout_input_t *input = owner->input;
     mtime_t end_date;
 
     aout_lock (aout);
     /* FIXME: tell output to drain */
-    end_date = date_Get (&input->date);
+    end_date = date_Get (&owner->sync.date);
     aout_unlock (aout);
     return end_date == VLC_TS_INVALID || end_date <= mdate();
 }
diff --git a/src/audio_output/input.c b/src/audio_output/input.c
index 715b88f..a6c6f95 100644
--- a/src/audio_output/input.c
+++ b/src/audio_output/input.c
@@ -79,9 +79,6 @@ int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_r
 
     p_input->i_nb_resamplers = p_input->i_nb_filters = 0;
 
-    date_Init (&p_input->date, owner->mixer_format.i_rate, 1);
-    date_Set (&p_input->date, VLC_TS_INVALID);
-
     /* */
     if( p_request_vout )
     {
@@ -461,13 +458,9 @@ void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input
     if( !p_input->b_restart )
         return;
 
-    /* A little trick to avoid loosing our input properties */
-    date_t date = p_input->date;
-
     aout_InputDelete( p_aout, p_input );
     aout_InputNew( p_aout, p_input, &p_input->request_vout );
 
-    p_input->date = date;
     p_input->b_restart = false;
 }
 /*****************************************************************************
@@ -477,8 +470,8 @@ void aout_InputCheckAndRestart( audio_output_t * p_aout, aout_input_t * p_input
  *****************************************************************************/
 /* XXX Do not activate it !! */
 //#define AOUT_PROCESS_BEFORE_CHEKS
-block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
-                         block_t *p_buffer, int i_input_rate )
+block_t *aout_InputPlay(audio_output_t *p_aout, aout_input_t *p_input,
+                        block_t *p_buffer, int i_input_rate, date_t *date )
 {
     mtime_t start_date;
 
@@ -531,7 +524,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
     /* We don't care if someone changes the start date behind our back after
      * this. We'll deal with that when pushing the buffer, and compensate
      * with the next incoming buffer. */
-    start_date = date_Get (&p_input->date);
+    start_date = date_Get (date);
 
     if ( start_date != VLC_TS_INVALID && start_date < now )
     {
@@ -564,7 +557,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
     if( start_date == VLC_TS_INVALID )
     {
         start_date = p_buffer->i_pts;
-        date_Set (&p_input->date, start_date);
+        date_Set (date, start_date);
     }
 
     mtime_t drift = start_date - p_buffer->i_pts;
@@ -579,7 +572,7 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
         inputResamplingStop( p_input );
         p_buffer->i_flags |= BLOCK_FLAG_DISCONTINUITY;
         start_date = p_buffer->i_pts;
-        date_Set (&p_input->date, start_date);
+        date_Set (date, start_date);
         drift = 0;
     }
     else
@@ -686,7 +679,6 @@ block_t *aout_InputPlay( audio_output_t *p_aout, aout_input_t *p_input,
 #endif
 
     p_buffer->i_pts = start_date;
-    date_Increment (&p_input->date, p_buffer->i_nb_samples);
     return p_buffer;
 }
 



More information about the vlc-commits mailing list