changeset 33237:a8619bfabf84

Add a alloc_demuxer function that ensures all the critical stuff is initialized and use it also in demux_demuxers.c. This fixes the OSD counter being stuck at 0.
author reimar
date Sun, 24 Apr 2011 23:06:38 +0000
parents 889bde9a7c11
children b09a5d9ff050
files libmpdemux/demux_demuxers.c libmpdemux/demuxer.c libmpdemux/demuxer.h
diffstat 3 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_demuxers.c	Sun Apr 24 21:32:36 2011 +0000
+++ b/libmpdemux/demux_demuxers.c	Sun Apr 24 23:06:38 2011 +0000
@@ -35,11 +35,10 @@
 extern const demuxer_desc_t demuxer_desc_demuxers;
 
 demuxer_t*  new_demuxers_demuxer(demuxer_t* vd, demuxer_t* ad, demuxer_t* sd) {
-  demuxer_t* ret;
+  // Video is the most important :-)
+  demuxer_t* ret = alloc_demuxer(vd->stream, DEMUXER_TYPE_DEMUXERS, vd->filename);
   dd_priv_t* priv;
 
-  ret = calloc(1,sizeof(demuxer_t));
-
   priv = malloc(sizeof(dd_priv_t));
   priv->vd = vd;
   priv->ad = ad;
@@ -47,8 +46,6 @@
   ret->priv = priv;
 
   ret->type = ret->file_format = DEMUXER_TYPE_DEMUXERS;
-  // Video is the most important :-)
-  ret->stream = vd->stream;
   ret->seekable = vd->seekable && ad->seekable && sd->seekable;
 
   ret->video = vd->video;
--- a/libmpdemux/demuxer.c	Sun Apr 24 21:32:36 2011 +0000
+++ b/libmpdemux/demuxer.c	Sun Apr 24 23:06:38 2011 +0000
@@ -225,9 +225,7 @@
     return NULL;
 }
 
-
-demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
-                       int s_id, char *filename)
+demuxer_t *alloc_demuxer(stream_t *stream, int type, const char *filename)
 {
     demuxer_t *d = calloc(1, sizeof(*d));
     d->stream = stream;
@@ -238,9 +236,6 @@
     d->seekable = 1;
     d->synced = 0;
     d->filepos = -1;
-    d->audio = new_demuxer_stream(d, a_id);
-    d->video = new_demuxer_stream(d, v_id);
-    d->sub = new_demuxer_stream(d, s_id);
     d->type = type;
     if (type)
         if (!(d->desc = get_demuxer_desc_from_type(type)))
@@ -249,6 +244,16 @@
                    "big troubles ahead.");
     if (filename) // Filename hack for avs_check_file
         d->filename = strdup(filename);
+    return d;
+}
+
+demuxer_t *new_demuxer(stream_t *stream, int type, int a_id, int v_id,
+                       int s_id, char *filename)
+{
+    demuxer_t *d = alloc_demuxer(stream, type, filename);
+    d->audio = new_demuxer_stream(d, a_id);
+    d->video = new_demuxer_stream(d, v_id);
+    d->sub = new_demuxer_stream(d, s_id);
     stream->eof = 0;
     stream_seek(stream, stream->start_pos);
     return d;
--- a/libmpdemux/demuxer.h	Sun Apr 24 21:32:36 2011 +0000
+++ b/libmpdemux/demuxer.h	Sun Apr 24 23:06:38 2011 +0000
@@ -358,6 +358,7 @@
 }
 
 demux_stream_t* new_demuxer_stream(struct demuxer *demuxer,int id);
+demuxer_t *alloc_demuxer(stream_t *stream, int type, const char *filename);
 demuxer_t* new_demuxer(stream_t *stream,int type,int a_id,int v_id,int s_id,char *filename);
 void free_demuxer_stream(demux_stream_t *ds);
 void free_demuxer(demuxer_t *demuxer);