[vlc-commits] soxr: implement Flush/Drain

Thomas Guillem git at videolan.org
Tue Nov 3 16:26:45 CET 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Nov  3 15:29:14 2015 +0100| [c47f787422f1a882044a962e00bc94c91f3d88e4] | committer: Thomas Guillem

soxr: implement Flush/Drain

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

 modules/audio_filter/resampler/soxr.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/modules/audio_filter/resampler/soxr.c b/modules/audio_filter/resampler/soxr.c
index 5bbd9a1..a1e610f 100644
--- a/modules/audio_filter/resampler/soxr.c
+++ b/modules/audio_filter/resampler/soxr.c
@@ -90,6 +90,8 @@ struct filter_sys_t
 };
 
 static block_t *Resample( filter_t *, block_t * );
+static block_t *Drain( filter_t * );
+static void     Flush( filter_t * );
 
 static bool
 SoXR_GetFormat( vlc_fourcc_t i_format, soxr_datatype_t *p_type )
@@ -190,6 +192,8 @@ Open( vlc_object_t *p_obj, bool b_change_ratio )
 
     p_filter->p_sys = p_sys;
     p_filter->pf_audio_filter = Resample;
+    p_filter->pf_audio_flush = Flush;
+    p_filter->pf_audio_drain = Drain;
     return VLC_SUCCESS;
 }
 
@@ -364,3 +368,28 @@ Resample( filter_t *p_filter, block_t *p_in )
         return p_out;
     }
 }
+
+static block_t *
+Drain( filter_t *p_filter )
+{
+    filter_sys_t *p_sys = p_filter->p_sys;
+
+    if( p_sys->last_soxr && p_sys->i_last_olen )
+        return SoXR_Resample( p_filter, p_sys->last_soxr, NULL,
+                              p_sys->i_last_olen );
+    else
+        return NULL;
+}
+
+static void
+Flush( filter_t *p_filter )
+{
+    filter_sys_t *p_sys = p_filter->p_sys;
+
+    if( p_sys->last_soxr )
+    {
+        soxr_clear( p_sys->last_soxr );
+        p_sys->i_last_olen = 0;
+        p_sys->last_soxr = NULL;
+    }
+}



More information about the vlc-commits mailing list