changeset 24469:afbab72dbf2c

Do not misuse a_streams for private info, demuxer->priv is for that!
author reimar
date Fri, 14 Sep 2007 18:40:57 +0000
parents 8b63c9487612
children 656a62a00e94
files libmpdemux/demux_ty.c
diffstat 1 files changed, 7 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ty.c	Fri Sep 14 18:32:34 2007 +0000
+++ b/libmpdemux/demux_ty.c	Fri Sep 14 18:40:57 2007 +0000
@@ -485,22 +485,12 @@
    unsigned char    lastCC[ 16 ];
    unsigned char    lastXDS[ 16 ];
 
-   TiVoInfo         *tivo = 0;
+   TiVoInfo         *tivo = demux->priv;
 
    if ( demux->stream->type == STREAMTYPE_DVD )
 		return 0;
 
    mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:ty processing\n" );
-   if ( demux->a_streams[ MAX_A_STREAMS - 1 ] == 0 )
-   {
-      demux->a_streams[ MAX_A_STREAMS - 1 ] = malloc( sizeof( TiVoInfo ) );
-      tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
-      memset( tivo, 0, sizeof( TiVoInfo ) );
-      tivo->firstAudioPTS = MP_NOPTS_VALUE;
-      tivo->firstVideoPTS = MP_NOPTS_VALUE;
-   }
-   else
-      tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
 
    if( demux->stream->eof ) return 0;
  
@@ -1044,17 +1034,13 @@
    sh_video_t     *sh_video = d_video->sh;
    off_t          newpos;
    off_t          res;
-   TiVoInfo       *tivo = 0;
+   TiVoInfo       *tivo = demuxer->priv;
 
    mp_msg( MSGT_DEMUX, MSGL_DBG3, "ty:Seeking to %7.1f\n", rel_seek_secs );
 
-   if ( demuxer->a_streams[ MAX_A_STREAMS - 1 ] != 0 )
-   {
-      tivo = demuxer->a_streams[ MAX_A_STREAMS - 1 ];
       tivo->lastAudioEnd = 0;
       tivo->lastAudioPTS = MP_NOPTS_VALUE;
       tivo->lastVideoPTS = MP_NOPTS_VALUE;
-   }
    //
    //================= seek in MPEG ==========================
    demuxer->filepos = stream_tell( demuxer->stream );
@@ -1145,20 +1131,19 @@
 
 static void demux_close_ty( demuxer_t *demux )
 {
-   TiVoInfo         *tivo = 0;
+   TiVoInfo         *tivo = demux->priv;
 
-   if ( demux->a_streams[ MAX_A_STREAMS - 1 ] != 0 )
-   {
-      tivo = demux->a_streams[ MAX_A_STREAMS - 1 ];
       free( tivo );
-      demux->a_streams[ MAX_A_STREAMS - 1 ] = 0;
 	   sub_justify = 0;
-   }
 }
 
 
 static int ty_check_file(demuxer_t* demuxer)
 {
+  TiVoInfo *tivo = calloc(1, sizeof(TiVoInfo));
+  tivo->firstAudioPTS = MP_NOPTS_VALUE;
+  tivo->firstVideoPTS = MP_NOPTS_VALUE;
+  demuxer->priv = tivo;
   return ds_fill_buffer(demuxer->video) ? DEMUXER_TYPE_MPEG_TY : 0;
 }