[MPlayer-dev-eng] [PATCH] demuxers: move resync_audio_stream call to demuxer.c

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Oct 14 21:38:46 CEST 2005


Hi,
the attached patch adds a call to resync_audio_stream to demuxer.c after
seeking and switch_audio. IMHO this is where it belongs, not the
individual demuxers.
demuxer.c is still missing the prototype for the resync_audio_stream.
Would you find a special prototype or #include "libmpcodecs/dec_audio.h"
preferable?
I don't think so, but it might be that this has a a negative effect on
A-V sync after seeking, please check.

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpdemux/demux_aac.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_aac.c,v
retrieving revision 1.5
diff -u -r1.5 demux_aac.c
--- libmpdemux/demux_aac.c	13 Oct 2005 18:33:56 -0000	1.5
+++ libmpdemux/demux_aac.c	14 Oct 2005 19:26:15 -0000
@@ -14,8 +14,6 @@
 #include "bswap.h"
 #include "ms_hdr.h"
 
-extern void resync_audio_stream(sh_audio_t *sh_audio);
-
 typedef struct {
 	uint8_t *buf;
 	uint64_t size;	/// amount of time of data packets pushed to demuxer->audio (in bytes)
@@ -248,7 +246,6 @@
 		}
 	}
 	sh_audio->delay = priv->last_pts - (ds_tell_pts(demuxer->audio)-sh_audio->a_in_buffer_len)/(float)priv->bitrate;
-	resync_audio_stream(sh_audio);
 }
 
 
Index: libmpdemux/demux_asf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_asf.c,v
retrieving revision 1.34
diff -u -r1.34 demux_asf.c
--- libmpdemux/demux_asf.c	2 Sep 2005 08:32:31 -0000	1.34
+++ libmpdemux/demux_asf.c	14 Oct 2005 19:26:17 -0000
@@ -359,7 +359,6 @@
 
 #include "stheader.h"
 
-extern void resync_audio_stream(sh_audio_t *sh_audio);
 extern void skip_audio_frame(sh_audio_t *sh_audio);
 
 static void demux_seek_asf(demuxer_t *demuxer,float rel_seek_secs,int flags){
@@ -390,7 +389,6 @@
     ds_fill_buffer(d_video);
     if(sh_audio){
       ds_fill_buffer(d_audio);
-      resync_audio_stream(sh_audio);
     }
     
     if (d_video->id < 0)
Index: libmpdemux/demux_audio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_audio.c,v
retrieving revision 1.39
diff -u -r1.39 demux_audio.c
--- libmpdemux/demux_audio.c	9 Sep 2005 20:05:42 -0000	1.39
+++ libmpdemux/demux_audio.c	14 Oct 2005 19:26:19 -0000
@@ -44,7 +44,6 @@
 } mp3_hdr_t;
 
 extern void free_sh_audio(sh_audio_t* sh);
-extern void resync_audio_stream(sh_audio_t *sh_audio);
 extern void print_wave_header(WAVEFORMATEX *h);
 
 int hr_mp3_seek = 0;
@@ -496,7 +509,6 @@
     if(len > 0)
       high_res_mp3_seek(demuxer,len);
     sh_audio->delay = priv->last_pts -  (ds_tell_pts(demuxer->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
-    resync_audio_stream(sh_audio);
     return;
   }
 
@@ -525,9 +537,6 @@
   }
 
   stream_seek(s,pos);
-
-  resync_audio_stream(sh_audio);
-
 }
 
 static void demux_close_audio(demuxer_t* demuxer) {
Index: libmpdemux/demux_avi.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_avi.c,v
retrieving revision 1.67
diff -u -r1.67 demux_avi.c
--- libmpdemux/demux_avi.c	13 Sep 2005 18:12:48 -0000	1.67
+++ libmpdemux/demux_avi.c	14 Oct 2005 19:26:22 -0000
@@ -617,7 +617,6 @@
 }
 
 //extern float initial_pts_delay;
-extern void resync_audio_stream(sh_audio_t *sh_audio);
 
 void demux_seek_avi(demuxer_t *demuxer,float rel_seek_secs,int flags){
     avi_priv_t *priv=demuxer->priv;
@@ -806,7 +805,6 @@
             demux_read_data(d_audio,NULL,skip_audio_bytes);
             //d_audio->pts=0; // PTS is outdated because of the raw data skipping
           }
-	  resync_audio_stream(sh_audio);
 
 //          sh_audio->timer=-skip_audio_secs;
 
Index: libmpdemux/demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.49
diff -u -r1.49 demux_mkv.c
--- libmpdemux/demux_mkv.c	13 Oct 2005 18:33:56 -0000	1.49
+++ libmpdemux/demux_mkv.c	14 Oct 2005 19:26:33 -0000
@@ -3106,7 +3106,6 @@
   free_cached_dps (demuxer);
   if (!(flags & 2))  /* time in secs */
     {
-      void resync_audio_stream(sh_audio_t *sh_audio);
       mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
       stream_t *s = demuxer->stream;
       int64_t target_timecode = 0, diff, min_diff=0xFFFFFFFL;
@@ -3217,15 +3216,11 @@
         clear_subtitles(demuxer, 0, 1);
 
       demux_mkv_fill_buffer(demuxer, NULL);
-
-      if(demuxer->audio->sh != NULL)
-        resync_audio_stream((sh_audio_t *) demuxer->audio->sh); 
     }
   else if ((demuxer->movi_end <= 0) || !(flags & 1))
     mp_msg (MSGT_DEMUX, MSGL_V, "[mkv] seek unsupported flags\n");
   else
     {
-      void resync_audio_stream(sh_audio_t *sh_audio);
       mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
       stream_t *s = demuxer->stream;
       uint64_t target_filepos;
@@ -3263,9 +3258,6 @@
         clear_subtitles(demuxer, 0, 1);
 
       demux_mkv_fill_buffer(demuxer, NULL);
-
-      if(demuxer->audio->sh != NULL)
-        resync_audio_stream((sh_audio_t *) demuxer->audio->sh); 
     }
 }
 
Index: libmpdemux/demux_mpc.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpc.c,v
retrieving revision 1.11
diff -u -r1.11 demux_mpc.c
--- libmpdemux/demux_mpc.c	12 Oct 2005 21:55:55 -0000	1.11
+++ libmpdemux/demux_mpc.c	14 Oct 2005 19:26:33 -0000
@@ -181,7 +181,6 @@
   if (!sh_audio) return;
   sh_audio->delay = priv->last_pts - (ds_tell_pts(demuxer->audio) -
                      sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps;
-  resync_audio_stream(sh_audio);
 }
 
 static void demux_close_mpc(demuxer_t* demuxer) {
Index: libmpdemux/demux_mpg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mpg.c,v
retrieving revision 1.64
diff -u -r1.64 demux_mpg.c
--- libmpdemux/demux_mpg.c	3 Sep 2005 08:58:34 -0000	1.64
+++ libmpdemux/demux_mpg.c	14 Oct 2005 19:26:37 -0000
@@ -669,7 +669,6 @@
   return 1;
 }
 
-extern void resync_audio_stream(sh_audio_t *sh_audio);
 extern void skip_audio_frame(sh_audio_t *sh_audio);
 
 void demux_seek_mpg(demuxer_t *demuxer,float rel_seek_secs,int flags){
@@ -733,7 +732,6 @@
 	ds_fill_buffer(d_video);
 	if(sh_audio){
 	  ds_fill_buffer(d_audio);
-	  resync_audio_stream(sh_audio);
 	}
 
 	while(1){
Index: libmpdemux/demux_ogg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ogg.c,v
retrieving revision 1.80
diff -u -r1.80 demux_ogg.c
--- libmpdemux/demux_ogg.c	13 Oct 2005 18:33:56 -0000	1.80
+++ libmpdemux/demux_ogg.c	14 Oct 2005 19:26:46 -0000
@@ -1390,8 +1390,6 @@
 
 }
 
-extern void resync_audio_stream(sh_audio_t *sh_audio);
-
 static void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags) {
   ogg_demuxer_t* ogg_d = demuxer->priv;
   ogg_sync_state* sync = &ogg_d->sync;
@@ -1558,8 +1556,6 @@
         vo_osd_changed(OSDTYPE_SUBTITLE);
         clear_sub = -1;
 	demux_ogg_add_packet(ds,os,ds->id,&op);
-	if(sh_audio)
-	  resync_audio_stream(sh_audio); 
 	return;
       }
      }
Index: libmpdemux/demux_rawaudio.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_rawaudio.c,v
retrieving revision 1.13
diff -u -r1.13 demux_rawaudio.c
--- libmpdemux/demux_rawaudio.c	25 Sep 2005 17:29:45 -0000	1.13
+++ libmpdemux/demux_rawaudio.c	14 Oct 2005 19:26:46 -0000
@@ -30,8 +30,6 @@
 };
 
 
-extern void resync_audio_stream(sh_audio_t *sh_audio);
-
 static demuxer_t* demux_rawaudio_open(demuxer_t* demuxer) {
   sh_audio_t* sh_audio;
   WAVEFORMATEX* w;
@@ -95,7 +93,6 @@
   pos -= (pos % (sh_audio->channels * sh_audio->samplesize) );
   stream_seek(s,pos);
   sh_audio->delay= (pos-ds_tell_pts(demuxer->audio)-sh_audio->a_in_buffer_len) / (float)(sh_audio->wf->nAvgBytesPerSec);
-  resync_audio_stream(sh_audio);
 //  printf("demux_rawaudio: streamtell=%d\n",(int)stream_tell(demuxer->stream));
 }
 
Index: libmpdemux/demux_real.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_real.c,v
retrieving revision 1.73
diff -u -r1.73 demux_real.c
--- libmpdemux/demux_real.c	2 Sep 2005 08:32:32 -0000	1.73
+++ libmpdemux/demux_real.c	14 Oct 2005 19:26:53 -0000
@@ -1748,8 +1748,6 @@
     return;
 }
 
-extern void resync_audio_stream(sh_audio_t * sh_audio);
-
 /* please upload RV10 samples WITH INDEX CHUNK */
 static int demux_seek_real(demuxer_t *demuxer, float rel_seek_secs, int flags)
 {
@@ -1840,8 +1838,6 @@
         stream_seek(demuxer->stream, next_offset);
 
     demux_real_fill_buffer(demuxer, NULL);
-    if (sh_audio)
-        resync_audio_stream(sh_audio);
     return 1;
 }
 
Index: libmpdemux/demux_ts.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ts.c,v
retrieving revision 1.36
diff -u -r1.36 demux_ts.c
--- libmpdemux/demux_ts.c	13 Oct 2005 18:33:56 -0000	1.36
+++ libmpdemux/demux_ts.c	14 Oct 2005 19:27:02 -0000
@@ -223,7 +223,6 @@
 #define IS_VIDEO(x) (((x) == VIDEO_MPEG1) || ((x) == VIDEO_MPEG2) || ((x) == VIDEO_MPEG4) || ((x) == VIDEO_H264) || ((x) == VIDEO_AVC))
 
 static int ts_parse(demuxer_t *demuxer, ES_stream_t *es, unsigned char *packet, int probe);
-extern void resync_audio_stream( sh_audio_t *sh_audio );
 
 static uint8_t get_packet_size(const unsigned char *buf, int size)
 {
@@ -2991,7 +2990,6 @@
 }
 
 
-extern void resync_audio_stream(sh_audio_t *sh_audio);
 extern void skip_audio_frame(sh_audio_t *sh_audio);
 
 static void reset_fifos(ts_priv_t* priv, int a, int v, int s)
@@ -3096,7 +3094,6 @@
 	if(sh_audio != NULL)
 	{
 		ds_fill_buffer(d_audio);
-		resync_audio_stream(sh_audio);
 	}
 
 	while(sh_video != NULL)
Index: libmpdemux/demux_ty.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ty.c,v
retrieving revision 1.9
diff -u -r1.9 demux_ty.c
--- libmpdemux/demux_ty.c	13 Oct 2005 18:33:56 -0000	1.9
+++ libmpdemux/demux_ty.c	14 Oct 2005 19:27:06 -0000
@@ -45,7 +45,6 @@
 #include "stheader.h"
 #include "../sub_cc.h"
 
-extern void resync_audio_stream( sh_audio_t *sh_audio );
 extern void skip_audio_frame( sh_audio_t *sh_audio );
 extern int sub_justify;
 
@@ -1313,7 +1312,6 @@
 	if( sh_audio )
    {
 	  ds_fill_buffer( d_audio );
-	  resync_audio_stream( sh_audio );
 	}
 
 	while( 1 )
Index: libmpdemux/demux_vqf.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_vqf.c,v
retrieving revision 1.4
diff -u -r1.4 demux_vqf.c
--- libmpdemux/demux_vqf.c	13 Oct 2005 18:33:56 -0000	1.4
+++ libmpdemux/demux_vqf.c	14 Oct 2005 19:27:07 -0000
@@ -9,8 +9,6 @@
 #include "stheader.h"
 #include "../libmpcodecs/vqf.h"
 
-extern void resync_audio_stream(sh_audio_t *sh_audio);
-
 static int demux_probe_vqf(demuxer_t* demuxer) 
 {
   char buf[KEYWORD_BYTES];
@@ -195,7 +193,6 @@
 
   pos -= (pos % (sh_audio->channels * sh_audio->samplesize) );
   stream_seek(s,pos);
-  resync_audio_stream(sh_audio);
 #endif
 }
 
Index: libmpdemux/demux_xmms.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_xmms.c,v
retrieving revision 1.12
diff -u -r1.12 demux_xmms.c
--- libmpdemux/demux_xmms.c	2 Sep 2005 08:32:32 -0000	1.12
+++ libmpdemux/demux_xmms.c	14 Oct 2005 19:27:08 -0000
@@ -199,8 +199,6 @@
 
 // ============================ mplayer demuxer stuff ===============
 
-//extern void resync_audio_stream(sh_audio_t *sh_audio);
-
 static int demux_xmms_open(demuxer_t* demuxer) {
   InputPlugin* ip = NULL;
   sh_audio_t* sh_audio;
Index: libmpdemux/demuxer.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demuxer.c,v
retrieving revision 1.207
diff -u -r1.207 demuxer.c
--- libmpdemux/demuxer.c	23 Sep 2005 22:35:03 -0000	1.207
+++ libmpdemux/demuxer.c	14 Oct 2005 19:27:12 -0000
@@ -856,6 +856,8 @@
 if (demuxer->desc->seek)
     demuxer->desc->seek(demuxer,rel_seek_secs,flags);
 
+    if (sh_audio) resync_audio_stream(sh_audio);
+
 return 1;
 }
 
@@ -957,5 +959,6 @@
     int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index);
     if (res == DEMUXER_CTRL_NOTIMPL)
       index = demuxer->audio->id;
+    if (demuxer->audio) resync_audio_stream(demuxer->audio);
     return index;
 }


More information about the MPlayer-dev-eng mailing list