]> git.sesse.net Git - vlc/blobdiff - modules/demux/tta.c
Preferences: don't show empty boxes ('zoom' box bug)
[vlc] / modules / demux / tta.c
index ec9bb42d8c9412066cd00e6ce9001224fdf8a5fd..42fda085f9708d3cad36a4218b3826b07e7b6d66 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_demux.h>
 #include <vlc_codec.h>
 #include <math.h>
@@ -37,10 +42,10 @@ static void Close ( vlc_object_t * );
 
 vlc_module_begin();
     set_shortname( "TTA" );
-    set_description( _("TTA demuxer") );
+    set_description( N_("TTA demuxer") );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_DEMUX );
-    set_capability( "demux2", 145 );
+    set_capability( "demux", 145 );
 
     set_callbacks( Open, Close );
     add_shortcut( "tta" );
@@ -105,6 +110,8 @@ static int Open( vlc_object_t * p_this )
     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' ) );
@@ -121,8 +128,20 @@ static int Open( vlc_object_t * p_this )
 
     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] );
@@ -132,6 +151,13 @@ static int Open( vlc_object_t * p_this )
     /* 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 );
 
@@ -139,24 +165,6 @@ static int Open( vlc_object_t * p_this )
     free( p_seektable );
     p_sys->i_start = stream_Tell( p_demux->s );
 
-#if 0
-    /* Parse possible id3 header */
-    p_demux->p_private = malloc( sizeof( demux_meta_t ) );
-    if( !p_demux->p_private )
-        return VLC_ENOMEM;
-    if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
-    {
-        demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
-        p_sys->p_meta = p_demux_meta->p_meta;
-        p_demux->p_private = NULL;
-        module_Unneed( p_demux, p_id3 );
-        TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
-    }
-    free( p_demux->p_private );
-
-    if( !p_sys->p_meta )
-        p_sys->p_meta = vlc_meta_New();
-#endif
     return VLC_SUCCESS;
 }
 
@@ -168,6 +176,7 @@ static void Close( vlc_object_t * p_this )
     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 );
 }
 
@@ -186,7 +195,7 @@ static int Demux( demux_t *p_demux )
 
     p_data = stream_Block( p_demux->s, p_sys->pi_seektable[p_sys->i_currentframe] );
     if( p_data == NULL ) return 0;
-    p_data->i_dts = p_data->i_pts = (int64_t)(1 + I64C(1000000) * p_sys->i_currentframe) * TTA_FRAMETIME;
+    p_data->i_dts = p_data->i_pts = (int64_t)(1 + INT64_C(1000000) * p_sys->i_currentframe) * TTA_FRAMETIME;
 
     p_sys->i_currentframe++;
 
@@ -237,17 +246,17 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
                 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_C(1000000) * p_sys->i_totalframes * TTA_FRAMETIME;
             return VLC_SUCCESS;
 
         case DEMUX_GET_TIME:
             pi64 = (int64_t*)va_arg( args, int64_t * );
-            *pi64 = I64C(1000000) * p_sys->i_currentframe * TTA_FRAMETIME;
+            *pi64 = INT64_C(1000000) * p_sys->i_currentframe * TTA_FRAMETIME;
             return VLC_SUCCESS;
+
         default:
             return VLC_EGENERIC;
     }