[vlc-devel] [PATCH 10/11] demux: wav: don't increment pts past data chunk bundary

Thomas Guillem thomas at gllm.fr
Thu Mar 12 15:05:51 CET 2020


---
 modules/demux/wav.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/modules/demux/wav.c b/modules/demux/wav.c
index 12c39688b39..3d71711791f 100644
--- a/modules/demux/wav.c
+++ b/modules/demux/wav.c
@@ -90,6 +90,8 @@ static int Demux( demux_t *p_demux )
     block_t     *p_block;
     const int64_t i_pos = vlc_stream_Tell( p_demux->s );
     unsigned int i_read_size = p_sys->i_frame_size;
+    uint32_t i_read_samples = p_sys->i_frame_samples;
+
 
     if( p_sys->i_data_size > 0 )
     {
@@ -99,7 +101,11 @@ static int Demux( demux_t *p_demux )
 
         /* Don't read past data chunk boundary */
         if ( i_end < i_pos + i_read_size )
+        {
             i_read_size = i_end - i_pos;
+            i_read_samples = ( p_sys->i_frame_size - i_read_size )
+                           * p_sys->i_frame_samples / p_sys->i_frame_size;
+        }
     }
 
     if( ( p_block = vlc_stream_Block( p_demux->s, i_read_size ) ) == NULL )
@@ -122,7 +128,7 @@ static int Demux( demux_t *p_demux )
 
     es_out_Send( p_demux->out, p_sys->p_es, p_block );
 
-    date_Increment( &p_sys->pts, p_sys->i_frame_samples );
+    date_Increment( &p_sys->pts, i_read_samples );
 
     return VLC_DEMUXER_SUCCESS;
 }
-- 
2.20.1



More information about the vlc-devel mailing list