changeset 31272:e340fa125680

Fix ds_get_next_pts to also work for the first packet of a stream.
author reimar
date Sun, 06 Jun 2010 13:59:44 +0000
parents 4e02cedf338e
children 0f9c3f446fc6
files libmpdemux/demuxer.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Sun Jun 06 13:53:18 2010 +0000
+++ b/libmpdemux/demuxer.c	Sun Jun 06 13:59:44 2010 +0000
@@ -812,7 +812,9 @@
 double ds_get_next_pts(demux_stream_t *ds)
 {
     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
             || demux->audio->bytes >= MAX_PACK_BYTES) {
             mp_msg(MSGT_DEMUXER, MSGL_ERR, MSGTR_TooManyAudioInBuffer,
@@ -830,6 +832,9 @@
         if (!demux_fill_buffer(demux, ds))
             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;
 }