core: make initial audio sync more robust against bad demuxers
commit9d53790ed2814cce59b487e20054ee27251cf062
authorUoti Urpala <uau@glyph.nonexistent.invalid>
Sun, 21 Nov 2010 17:25:18 +0000 (21 19:25 +0200)
committerUoti Urpala <uau@glyph.nonexistent.invalid>
Sun, 21 Nov 2010 17:47:00 +0000 (21 19:47 +0200)
tree228d7fa1fa1b7ebaf64a5c42ba2293389c6430ff
parent37dbe7f5d07c8b1c4bb8529b87ddca7287ae8bae
core: make initial audio sync more robust against bad demuxers

ogg/ogm demuxers can give first audio packets without timestamp after
a seek. Due to some backwards compatibility code this results in the
sync code getting audio timestamp 0. In this case a lot of audio was
dropped unnecessarily when seeking to a position later in the file, as
the code saw audio starting from 0, video from something larger.

Make the code more robust in two ways. First, add a special case to
not try syncing if we get audio timestamp <= 0 (hopefully there aren't
many files where we'd really get audio starting from 0 and video from
a later timestamp). Second, when throwing audio away, make the code
recalculate from scratch the amount of bytes that still need to be
thrown away after every decode call. This limits the amount of damage
initial too-small timestamps can do, as the code will see the better
timestamps after a while.
mplayer.c