summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authornicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-04-07 08:51:26 +0000
committernicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-04-07 08:51:26 +0000
commitacb512df1000a2734c29ddd21cf9ffb7db73b512 (patch)
tree4d3346c308cf509ddf70130d8b1432d53a2b97ad /libmpdemux
parent118422ccf0848afceda4830a90827873e5bcf4f8 (diff)
downloadmpv-acb512df1000a2734c29ddd21cf9ffb7db73b512.tar.bz2
mpv-acb512df1000a2734c29ddd21cf9ffb7db73b512.tar.xz
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22927 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/muxer_mpeg.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/libmpdemux/muxer_mpeg.c b/libmpdemux/muxer_mpeg.c
index c9946ed38a..9398f513d2 100644
--- a/libmpdemux/muxer_mpeg.c
+++ b/libmpdemux/muxer_mpeg.c
@@ -1460,6 +1460,8 @@ static int flush_buffers(muxer_t *muxer, int finalize)
muxer_stream_t *s, *vs, *as;
muxer_headers_t *vpriv = NULL, *apriv = NULL;
muxer_priv_t *priv = (muxer_priv_t *) muxer->priv;
+ double duration;
+ uint64_t iduration, iaduration;
/*
analyzes all streams and decides what to flush
@@ -1495,11 +1497,30 @@ static int flush_buffers(muxer_t *muxer, int finalize)
mp_msg(MSGT_MUXER, MSGL_DBG2, "\nVIDEO, FLUSH %d frames (of %d), 0 to %d\n", n, vpriv->framebuf_used, n-1);
vpriv = (muxer_headers_t*) vs->priv;
-
- if(as != NULL) apriv = (muxer_headers_t*) as->priv;
- if(as != NULL && (apriv->size == 0))
+
+ duration = 0;
+ iduration = 0;
+ for(i = 0; i < n; i++)
+ iduration += vpriv->framebuf[i].idur;
+ duration = (double) (iduration / 27000000.0);
+
+ if(as != NULL)
{
apriv = (muxer_headers_t*) as->priv;
+ iaduration = 0;
+ for(i = 0; i < apriv->framebuf_used; i++)
+ {
+ iaduration += apriv->framebuf[i].idur;
+ }
+ if(iaduration < iduration)
+ {
+ mp_msg(MSGT_MUXER, MSGL_DBG2, "Not enough audio data exit\n");
+ return 0;
+ }
+ }
+
+ if(as != NULL && (apriv->size == 0))
+ {
init_delay = vpriv->framebuf[0].pts - vpriv->framebuf[0].dts;
for(i = 0; i < apriv->framebuf_cnt; i++)