changeset 26926:1e6241274552

added and reused demux_flush() instead of emptying the demux_stream buffers; patch by Bryan Henderson - giraffedata gmail com
author nicodvb
date Mon, 02 Jun 2008 10:17:48 +0000
parents 3f6d2ca29727
children ff446aa58931
files libmpdemux/demuxer.c libmpdemux/demuxer.h
diffstat 2 files changed, 11 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Sun Jun 01 19:08:16 2008 +0000
+++ b/libmpdemux/demuxer.c	Mon Jun 02 10:17:48 2008 +0000
@@ -943,6 +943,12 @@
 }
 
 
+void demux_flush(demuxer_t *demuxer) {
+    ds_free_packs(demuxer->video);
+    ds_free_packs(demuxer->audio);
+    ds_free_packs(demuxer->sub);
+}
+
 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags){
     demux_stream_t *d_audio=demuxer->audio;
     demux_stream_t *d_video=demuxer->video;
@@ -963,11 +969,9 @@
     return 0;
 }
 
+    demux_flush(demuxer);
     // clear demux buffers:
-    if(sh_audio){ ds_free_packs(d_audio);sh_audio->a_buffer_len=0;}
-    ds_free_packs(d_video);
-    ds_free_packs(demuxer->sub);
-    
+    if(sh_audio) sh_audio->a_buffer_len=0;
     demuxer->stream->eof=0; // clear eof flag
     demuxer->video->eof=0;
     demuxer->audio->eof=0;
@@ -1197,14 +1201,7 @@
             chapter += current;
         }
 
-        if(demuxer->video->sh)
-            ds_free_packs(demuxer->video);
-
-        if(demuxer->audio->sh)
-            ds_free_packs(demuxer->audio);
-
-        if(demuxer->sub->id >= 0)
-            ds_free_packs(demuxer->sub);
+        demux_flush(demuxer);
 
         ris = stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_CHAPTER, &chapter);
         if(ris != STREAM_UNSUPPORTED)
@@ -1369,14 +1366,7 @@
     angles = demuxer_angles_count(demuxer);
     if((angles < 1) || (angle > angles)) return -1;
 
-    if(demuxer->video->sh)
-        ds_free_packs(demuxer->video);
-
-    if(demuxer->audio->sh)
-        ds_free_packs(demuxer->audio);
-
-    if(demuxer->sub->id >= 0)
-        ds_free_packs(demuxer->sub);
+    demux_flush(demuxer);
 
     ris = stream_control(demuxer->stream, STREAM_CTRL_SET_ANGLE, &angle);
     if(ris == STREAM_UNSUPPORTED) return -1;
--- a/libmpdemux/demuxer.h	Sun Jun 01 19:08:16 2008 +0000
+++ b/libmpdemux/demuxer.h	Mon Jun 02 10:17:48 2008 +0000
@@ -369,6 +369,7 @@
 }
 
 demuxer_t* demux_open(stream_t *stream,int file_format,int aid,int vid,int sid,char* filename);
+void demux_flush(demuxer_t *demuxer);
 int demux_seek(demuxer_t *demuxer,float rel_seek_secs,float audio_delay,int flags);
 demuxer_t*  new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd);