summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-16 21:26:12 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-20 19:02:24 +0200
commitb4564c2d4fdc14f1fcb6987b8f57a2c27a08bf54 (patch)
tree714946d9c340a402c6a08c05e3354b92ba3506c5
parentf0649f13d698eb6aeffeaacd6801b666c4366caf (diff)
downloadmpv-b4564c2d4fdc14f1fcb6987b8f57a2c27a08bf54.tar.bz2
mpv-b4564c2d4fdc14f1fcb6987b8f57a2c27a08bf54.tar.xz
core: audio: make ogg missing audio timing workaround more complex
After the addition of exact seeking the code to work around missing audio timestamps with ogg/ogm needs improvement. Now it's normal to need adjustment at stream start time 0 (seeking to a position after start of video but before second keyframe) with any video format, and for exact seeks with ogg it's now more important not to skip the sync. Make the check to detect the problem case more precise to avoid affecting most other formats, and try to decode a second of audio (hoping to get timestamps for those packets) before giving up.
-rw-r--r--mplayer.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/mplayer.c b/mplayer.c
index f209ca0214..87490152af 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -2129,6 +2129,7 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
return res;
int bytes;
+ bool did_retry = false;
while (1) {
double written_pts = written_audio_pts(mpctx);
double ptsdiff = written_pts - mpctx->video_pts - mpctx->delay
@@ -2136,8 +2137,20 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
bytes = ptsdiff * ao_data.bps / mpctx->opts.playback_speed;
bytes -= bytes % (ao_data.channels * af_fmt2bits(ao_data.format) / 8);
- if (fabs(ptsdiff) > 300 // pts reset or just broken?
- || written_pts <= 0) // ogg demuxers give packets without timing
+ // ogg demuxers give packets without timing
+ if (written_pts <= 1 && sh_audio->pts == MP_NOPTS_VALUE) {
+ if (!did_retry) {
+ // Try to read more data to see packets that have pts
+ int res = decode_audio(sh_audio, ao_data.bps);
+ if (res < 0)
+ return res;
+ did_retry = true;
+ continue;
+ }
+ bytes = 0;
+ }
+
+ if (fabs(ptsdiff) > 300) // pts reset or just broken?
bytes = 0;
if (bytes > 0)