[vlc-commits] Add pause callback for audio output (aout_output_t.pf_pause)

Rémi Denis-Courmont git at videolan.org
Fri Jul 8 20:01:41 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jul  8 20:58:50 2011 +0300| [1d7fcd8c7325986d1ffcda68cf1eda8902c314ea] | committer: Rémi Denis-Courmont

Add pause callback for audio output (aout_output_t.pf_pause)

This is required for PulseAudio synchronization and to pause/resume
with low-latency. This should also be useful for other buffered
 audio outputs such as ALSA or CoreAudio.

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

 include/vlc_aout.h                      |    5 +++--
 modules/audio_output/alsa.c             |    1 +
 modules/audio_output/amem.c             |    1 +
 modules/audio_output/audioqueue.c       |    1 +
 modules/audio_output/auhal.c            |    1 +
 modules/audio_output/directx.c          |    1 +
 modules/audio_output/file.c             |    1 +
 modules/audio_output/jack.c             |    1 +
 modules/audio_output/opensles_android.c |    1 +
 modules/audio_output/oss.c              |    1 +
 modules/audio_output/portaudio.c        |    1 +
 modules/audio_output/pulse.c            |    1 +
 modules/audio_output/sdl.c              |    1 +
 modules/audio_output/waveout.c          |    3 +--
 modules/misc/dummy/aout.c               |    1 +
 src/audio_output/aout_internal.h        |    1 +
 src/audio_output/dec.c                  |    1 +
 src/audio_output/output.c               |   13 +++++++++++++
 18 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index b7dc314..f03aa83 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -165,8 +165,9 @@ typedef struct aout_output_t
 
     struct module_t *       p_module;
     struct aout_sys_t *     p_sys;
-    void                 (* pf_play)( aout_instance_t * );
-    int                  (* pf_volume_set )( aout_instance_t *, audio_volume_t, bool );
+    void (*pf_play)( aout_instance_t * );
+    void (* pf_pause)( aout_instance_t *, bool, mtime_t );
+    int (* pf_volume_set )( aout_instance_t *, audio_volume_t, bool );
     int                     i_nb_samples;
 } aout_output_t;
 
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index 7ff939a..2ea4b25 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -366,6 +366,7 @@ static int Open (vlc_object_t *obj)
     }
 
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
 
     snd_pcm_hw_params_t *p_hw;
     snd_pcm_sw_params_t *p_sw;
diff --git a/modules/audio_output/amem.c b/modules/audio_output/amem.c
index 23fed53..776c609 100644
--- a/modules/audio_output/amem.c
+++ b/modules/audio_output/amem.c
@@ -132,6 +132,7 @@ static int Open (vlc_object_t *obj)
     aout->output.output.i_rate = rate;
 
     aout->output.pf_play = Play;
+    aout->output.pf_pause = NULL;
     if (sys->set_volume != NULL)
         aout->output.pf_volume_set = VolumeSet;
     else
diff --git a/modules/audio_output/audioqueue.c b/modules/audio_output/audioqueue.c
index 19e0830..64c28c6 100644
--- a/modules/audio_output/audioqueue.c
+++ b/modules/audio_output/audioqueue.c
@@ -123,6 +123,7 @@ static int Open ( vlc_object_t *p_this )
     p_aout->output.output.i_rate = 44100;
     p_aout->output.i_nb_samples = FRAME_SIZE;
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
 
     msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status);
     status = AudioQueueStart(p_sys->audioQueue, NULL);
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 0ed0c52..b9cb8a3 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -188,6 +188,7 @@ static int Open( vlc_object_t * p_this )
     memset( p_sys->p_remainder_buffer, 0, sizeof(uint8_t) * BUFSIZE );
 
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
 
     aout_FormatPrint( p_aout, "VLC is looking for:", (audio_sample_format_t *)&p_aout->output.output );
 
diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c
index 97e659d..d8f0a00 100644
--- a/modules/audio_output/directx.c
+++ b/modules/audio_output/directx.c
@@ -174,6 +174,7 @@ static int OpenAudio( vlc_object_t *p_this )
     p_aout->output.p_sys->b_playing = 0;
 
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
     aout_VolumeSoftInit( p_aout );
 
     /* Retrieve config values */
diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c
index 8151a0d..5e13362 100644
--- a/modules/audio_output/file.c
+++ b/modules/audio_output/file.c
@@ -163,6 +163,7 @@ static int Open( vlc_object_t * p_this )
     }
 
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
 
     /* Audio format */
     psz_format = var_CreateGetString( p_this, "audiofile-format" );
diff --git a/modules/audio_output/jack.c b/modules/audio_output/jack.c
index aeebfb2..343a0de 100644
--- a/modules/audio_output/jack.c
+++ b/modules/audio_output/jack.c
@@ -134,6 +134,7 @@ static int Open( vlc_object_t *p_this )
     jack_set_graph_order_callback ( p_sys->p_jack_client, GraphChange, p_aout );
 
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
     aout_VolumeSoftInit( p_aout );
 
     /* JACK only supports fl32 format */
diff --git a/modules/audio_output/opensles_android.c b/modules/audio_output/opensles_android.c
index 038778d..3e809f7 100644
--- a/modules/audio_output/opensles_android.c
+++ b/modules/audio_output/opensles_android.c
@@ -260,6 +260,7 @@ static int Open( vlc_object_t * p_this )
     p_aout->output.i_nb_samples                 = 2048;
     p_aout->output.output.i_physical_channels   = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
     p_aout->output.pf_play                      = Play;
+    p_aout->output.pf_pause = NULL;
 
     aout_FormatPrepare( &p_aout->output.output );
 
diff --git a/modules/audio_output/oss.c b/modules/audio_output/oss.c
index 34c540e..03ef538 100644
--- a/modules/audio_output/oss.c
+++ b/modules/audio_output/oss.c
@@ -299,6 +299,7 @@ static int Open( vlc_object_t *p_this )
     free( psz_device );
 
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
 
     if ( var_Type( p_aout, "audio-device" ) == 0 )
     {
diff --git a/modules/audio_output/portaudio.c b/modules/audio_output/portaudio.c
index 7909495..8441fd0 100644
--- a/modules/audio_output/portaudio.c
+++ b/modules/audio_output/portaudio.c
@@ -183,6 +183,7 @@ static int Open( vlc_object_t * p_this )
     p_sys->p_stream = 0;
     p_aout->output.p_sys = p_sys;
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
 
     /* Retrieve output device id from config */
     p_sys->i_device_id = var_CreateGetInteger( p_aout, "portaudio-audio-device" );
diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c
index e2ee419..1e1c0f0 100644
--- a/modules/audio_output/pulse.c
+++ b/modules/audio_output/pulse.c
@@ -581,6 +581,7 @@ static int Open(vlc_object_t *obj)
     pa_threaded_mainloop_unlock(mainloop);
 
     aout->output.pf_play = Play;
+    aout->output.pf_pause = NULL;
     aout->output.pf_volume_set = VolumeSet;
     return VLC_SUCCESS;
 
diff --git a/modules/audio_output/sdl.c b/modules/audio_output/sdl.c
index f88f124..3acd8cc 100644
--- a/modules/audio_output/sdl.c
+++ b/modules/audio_output/sdl.c
@@ -215,6 +215,7 @@ static int Open ( vlc_object_t *p_this )
     p_aout->output.output.i_rate = obtained.freq;
     p_aout->output.i_nb_samples = obtained.samples;
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
 
     return VLC_SUCCESS;
 }
diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c
index ffba414..e82b01c 100644
--- a/modules/audio_output/waveout.c
+++ b/modules/audio_output/waveout.c
@@ -154,8 +154,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_ENOMEM;
 
     p_aout->output.pf_play = Play;
-    p_aout->b_die = false;
-
+    p_aout->output.pf_pause = NULL;
 
     /*
      initialize/update Device selection List
diff --git a/modules/misc/dummy/aout.c b/modules/misc/dummy/aout.c
index 1f3f619..087115a 100644
--- a/modules/misc/dummy/aout.c
+++ b/modules/misc/dummy/aout.c
@@ -51,6 +51,7 @@ int OpenAudio ( vlc_object_t * p_this )
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
 
     p_aout->output.pf_play = Play;
+    p_aout->output.pf_pause = NULL;
     aout_VolumeSoftInit( p_aout );
 
     if( AOUT_FMT_NON_LINEAR( &p_aout->output.output )
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 5018054..0aa81ca 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -116,6 +116,7 @@ void aout_MixerRun( aout_instance_t * p_aout, float );
 int aout_OutputNew( aout_instance_t * p_aout,
                     const audio_sample_format_t * p_format );
 void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer );
+void aout_OutputPause( aout_instance_t * p_aout, bool, mtime_t );
 void aout_OutputDelete( aout_instance_t * p_aout );
 
 
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 8bf692e..3f6565c 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -278,6 +278,7 @@ void aout_DecChangePause( aout_instance_t *p_aout, aout_input_t *p_input, bool b
         }
         aout_unlock_mixer( p_aout );
     }
+    aout_OutputPause( p_aout, b_paused, i_date );
 }
 
 void aout_DecFlush( aout_instance_t *p_aout, aout_input_t *p_input )
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index d2626c3..fe4461a 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -239,6 +239,19 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
     aout_unlock_output_fifo( p_aout );
 }
 
+/**
+ * Notifies the audio output (if any) of pause/resume events.
+ * This enables the output to expedite pause, instead of waiting for its
+ * buffers to drain.
+ */
+void aout_OutputPause( aout_instance_t *aout, bool pause, mtime_t date )
+{
+    aout_lock_output_fifo( aout );
+    if( aout->output.pf_pause != NULL )
+        aout->output.pf_pause( aout, pause, date );
+    aout_unlock_output_fifo( aout );
+}
+
 /*****************************************************************************
  * aout_OutputNextBuffer : give the audio output plug-in the right buffer
  *****************************************************************************



More information about the vlc-commits mailing list