/*****************************************************************************
* Preamble
*****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include <vlc/vlc.h>
#include <vlc_demux.h>
#include <vlc_codec.h>
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
es_format_t fmt;
- uint8_t *p_peek;
+ const uint8_t *p_peek;
uint8_t p_header[22];
uint8_t *p_seektable;
int i_seektable_size = 0, i;
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
-
+ if( !p_sys )
+ return VLC_ENOMEM;
+
/* Read the metadata */
es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC( 'T', 'T', 'A', '1' ) );
fmt.audio.i_channels = GetWLE( &p_header[6] );
i_seektable_size = sizeof(uint32_t)*p_sys->i_totalframes;
p_seektable = (uint8_t *)malloc( i_seektable_size );
+ if( !p_seektable )
+ {
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
+
stream_Read( p_demux->s, p_seektable, i_seektable_size );
- p_sys->pi_seektable = (uint32_t *)malloc(i_seektable_size);
+ p_sys->pi_seektable = (uint32_t *)malloc( i_seektable_size );
+ if( !p_sys->pi_seektable )
+ {
+ free( p_seektable );
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
for( i = 0; i < p_sys->i_totalframes; i++ )
p_sys->pi_seektable[i] = GetDWLE( &p_seektable[i*4] );
/* Store the header and Seektable for avcodec */
fmt.i_extra = 22 + (p_sys->i_totalframes * 4) + 4;
fmt.p_extra = malloc( fmt.i_extra );
+ if( !fmt.p_extra )
+ {
+ free( p_sys->pi_seektable );
+ free( p_seektable );
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
memcpy( (uint8_t*)fmt.p_extra, p_header, 22 );
memcpy( (uint8_t*)fmt.p_extra+22, p_seektable, fmt.i_extra -22 );
p_sys->p_es = es_out_Add( p_demux->out, &fmt );
free( p_seektable );
p_sys->i_start = stream_Tell( p_demux->s );
-
-#if 0
- /* Parse possible id3 header */
- if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
- {
- p_sys->p_meta = (vlc_meta_t *)p_demux->p_private;
- p_demux->p_private = NULL;
- module_Unneed( p_demux, p_id3 );
- }
- if( !p_sys->p_meta )
- p_sys->p_meta = vlc_meta_New();
-#endif
return VLC_SUCCESS;
}
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
+ free( p_sys->pi_seektable );
free( p_sys );
}
return VLC_SUCCESS;
}
return VLC_EGENERIC;
-
+
case DEMUX_GET_LENGTH:
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = I64C(1000000) * p_sys->i_totalframes * TTA_FRAMETIME;
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = I64C(1000000) * p_sys->i_currentframe * TTA_FRAMETIME;
return VLC_SUCCESS;
-
+
default:
return VLC_EGENERIC;
}