]> git.sesse.net Git - vlc/blobdiff - modules/demux/mpeg/mpga.c
Added const wheen needed for stream_Peek (demuxer/access)
[vlc] / modules / demux / mpeg / mpga.c
index ec5cb291eba88ae1f351ec36892b1aa2591b948f..a7c9f5753627dad19aa9e8094b7c4442e7030892 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 
 #include <vlc/vlc.h>
 #include <vlc_demux.h>
 #include <vlc_codec.h>
-#include <vlc_meta.h>
+#include <vlc_input.h>
 
 #define MPGA_PACKET_SIZE 1024
 
@@ -121,18 +120,12 @@ static int Open( vlc_object_t * p_this )
     vlc_bool_t   b_forced = VLC_FALSE;
 
     uint32_t     header;
-    uint8_t     *p_peek;
+    const uint8_t     *p_peek;
     module_t    *p_id3;
     block_t     *p_block_in, *p_block_out;
 
-    if( p_demux->psz_path )
-    {
-        int  i_len = strlen( p_demux->psz_path );
-        if( i_len > 4 && !strcasecmp( &p_demux->psz_path[i_len - 4], ".mp3" ) )
-        {
-            b_forced = VLC_TRUE;
-        }
-    }
+    if( demux2_IsPathExtension( p_demux, ".mp3" ) )
+        b_forced = VLC_TRUE;
 
     if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
 
@@ -157,7 +150,7 @@ static int Open( vlc_object_t * p_this )
         if( !b_ok && !p_demux->b_force ) return VLC_EGENERIC;
     }
 
-    STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
+    DEMUX_INIT_COMMON(); p_sys = p_demux->p_sys;
     memset( p_sys, 0, sizeof( demux_sys_t ) );
     p_sys->p_es = 0;
     p_sys->b_start = VLC_TRUE;
@@ -172,7 +165,7 @@ static int Open( vlc_object_t * p_this )
     if( HeaderCheck( header ) )
     {
         int i_xing, i_skip;
-        uint8_t *p_xing;
+        const uint8_t *p_xing;
 
         if( ( i_xing = stream_Peek( p_demux->s, &p_xing, 1024 ) ) < 21 )
             return VLC_SUCCESS; /* No header */
@@ -245,9 +238,6 @@ static int Open( vlc_object_t * p_this )
     else
         p_sys->b_initial_sync_failed = VLC_FALSE;
 
-    p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
-    p_sys->p_es = es_out_Add( p_demux->out,
-                              &p_sys->p_packetizer->fmt_out);
     p_sys->i_bitrate_avg = p_sys->p_packetizer->fmt_out.i_bitrate;
 
     if( p_sys->i_xing_bytes && p_sys->i_xing_frames &&
@@ -269,6 +259,12 @@ static int Open( vlc_object_t * p_this )
         module_Unneed( p_demux, p_id3 );
     }
 
+    /* */
+    p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
+    vlc_audio_replay_gain_MergeFromMeta( &p_sys->p_packetizer->fmt_out.audio_replay_gain,
+                                         p_sys->meta );
+    p_sys->p_es = es_out_Add( p_demux->out,
+                              &p_sys->p_packetizer->fmt_out);
     return VLC_SUCCESS;
 }