[vlc-commits] spatialaudio: reset PTS after a pause

Thomas Guillem git at videolan.org
Thu Mar 1 10:29:05 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Mar  1 09:31:54 2018 +0100| [e583b2d676fd3099d36caf1b660cf458cf68dd70] | committer: Thomas Guillem

spatialaudio: reset PTS after a pause

This fixes stuffer on pause/unpause

Fixes #19406

(cherry picked from commit 1f246d2604822174812a2cab63111d95ad6ea27a)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 modules/audio_filter/channel_mixer/spatialaudio.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/modules/audio_filter/channel_mixer/spatialaudio.cpp b/modules/audio_filter/channel_mixer/spatialaudio.cpp
index d80e24a3ce..c34e402527 100644
--- a/modules/audio_filter/channel_mixer/spatialaudio.cpp
+++ b/modules/audio_filter/channel_mixer/spatialaudio.cpp
@@ -58,6 +58,7 @@
 static int OpenBinauralizer(vlc_object_t *p_this);
 static int Open( vlc_object_t * );
 static void Close( vlc_object_t * );
+static void Flush( filter_t * );
 
 vlc_module_begin()
     set_shortname("Spatialaudio")
@@ -86,6 +87,7 @@ struct filter_sys_t
     filter_sys_t()
         : speakers(NULL)
         , i_inputPTS(0)
+        , i_last_input_pts(0)
         , inBuf(NULL)
         , outBuf(NULL)
     {}
@@ -120,6 +122,7 @@ struct filter_sys_t
 
     std::vector<float> inputSamples;
     mtime_t i_inputPTS;
+    mtime_t i_last_input_pts;
     unsigned i_order;
 
     float** inBuf;
@@ -164,6 +167,13 @@ static block_t *Mix( filter_t *p_filter, block_t *p_buf )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
+    /* Detect discontinuity due to a pause */
+    static const mtime_t rounding_error = 10;
+    if( p_sys->i_inputPTS != 0
+     && p_buf->i_pts - p_sys->i_last_input_pts - p_buf->i_length > rounding_error )
+        Flush( p_filter );
+    p_sys->i_last_input_pts = p_buf->i_pts;
+
     const size_t i_prevSize = p_sys->inputSamples.size();
     p_sys->inputSamples.resize(i_prevSize + p_buf->i_nb_samples * p_sys->i_inputNb);
     memcpy((char*)(p_sys->inputSamples.data() + i_prevSize), (char*)p_buf->p_buffer, p_buf->i_buffer);
@@ -256,7 +266,7 @@ static void Flush( filter_t *p_filter )
 {
     filter_sys_t *p_sys = p_filter->p_sys;
     p_sys->inputSamples.clear();
-    p_sys->i_inputPTS = 0;
+    p_sys->i_last_input_pts = p_sys->i_inputPTS = 0;
 }
 
 static void ChangeViewpoint( filter_t *p_filter, const vlc_viewpoint_t *p_vp)



More information about the vlc-commits mailing list