changeset 36740:d29468059da8

Make sure that demuxer priv is allocated early enough. Fixes not being able to switch audio streams any more.
author reimar
date Fri, 14 Feb 2014 22:29:36 +0000
parents 690ca924c15a
children f690ce5daaee
files libmpdemux/demux_mpg.c
diffstat 1 files changed, 4 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mpg.c	Fri Feb 14 22:29:35 2014 +0000
+++ b/libmpdemux/demux_mpg.c	Fri Feb 14 22:29:36 2014 +0000
@@ -189,14 +189,13 @@
 /// Open an mpg physical stream
 static demuxer_t* demux_mpg_open(demuxer_t* demuxer) {
   stream_t *s = demuxer->stream;
-  mpg_demuxer_t* mpg_d;
+  mpg_demuxer_t* mpg_d = calloc(1,sizeof(*mpg_d));
+  if (!mpg_d)
+    return NULL;
+  demuxer->priv = mpg_d;
 
   while (demuxer->video->packs + demuxer->audio->packs < 2)
     if (!ds_fill_buffer(demuxer->video)) return 0;
-  mpg_d = calloc(1,sizeof(mpg_demuxer_t));
-  if(mpg_d)
-  {
-    demuxer->priv = mpg_d;
     mpg_d->last_pts = -1.0;
     mpg_d->first_pts = -1.0;
 
@@ -245,7 +244,6 @@
       stream_seek(s,pos);
       ds_fill_buffer(demuxer->video);
     } // if ( demuxer->seekable )
-  } // if ( mpg_d )
   return demuxer;
 }