0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

demuxer.c: Make ds_get_next_pts work for the first packet of a stream

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31338 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2010-06-06 13:59:44 +00:00 committed by Uoti Urpala
parent f604df4f76
commit c1b0498c1f

View File

@ -801,7 +801,9 @@ int ds_get_packet_sub(demux_stream_t *ds, unsigned char **start)
double ds_get_next_pts(demux_stream_t *ds) double ds_get_next_pts(demux_stream_t *ds)
{ {
demuxer_t *demux = ds->demuxer; demuxer_t *demux = ds->demuxer;
while (!ds->first) { // if we have not read from the "current" packet, consider it
// as the next, otherwise we never get the pts for the first packet.
while (!ds->first && (!ds->current || ds->buffer_pos)) {
if (demux->audio->packs >= MAX_PACKS if (demux->audio->packs >= MAX_PACKS
|| demux->audio->bytes >= MAX_PACK_BYTES) { || demux->audio->bytes >= MAX_PACK_BYTES) {
mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "\nToo many audio packets in the buffer: (%d in %d bytes).\n", mp_tmsg(MSGT_DEMUXER, MSGL_ERR, "\nToo many audio packets in the buffer: (%d in %d bytes).\n",
@ -819,6 +821,9 @@ double ds_get_next_pts(demux_stream_t *ds)
if (!demux_fill_buffer(demux, ds)) if (!demux_fill_buffer(demux, ds))
return MP_NOPTS_VALUE; return MP_NOPTS_VALUE;
} }
// take pts from "current" if we never read from it.
if (ds->current && !ds->buffer_pos)
return ds->current->pts;
return ds->first->pts; return ds->first->pts;
} }