[vlc-devel] commit: Do not access input object from decoders. (Laurent Aimar )

git version control git at videolan.org
Tue Dec 9 21:40:20 CET 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Dec  6 18:59:49 2008 +0100| [fa84b4cfe5aa39d27aca4a81a5b42a9c34812b83] | committer: Laurent Aimar 

Do not access input object from decoders.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fa84b4cfe5aa39d27aca4a81a5b42a9c34812b83
---

 modules/codec/faad.c   |   20 ++++++--------------
 modules/codec/kate.c   |   12 ++++++------
 modules/codec/speex.c  |   31 +++++++++++--------------------
 modules/codec/theora.c |   12 ++++++------
 modules/codec/vorbis.c |   40 ++++++----------------------------------
 5 files changed, 35 insertions(+), 80 deletions(-)

diff --git a/modules/codec/faad.c b/modules/codec/faad.c
index 521b272..fd5636e 100644
--- a/modules/codec/faad.c
+++ b/modules/codec/faad.c
@@ -365,27 +365,19 @@ static aout_buffer_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             = pi_channels_guessed[frame.channels];
 
         /* Adjust stream info when dealing with SBR/PS */
-        if( (p_sys->b_sbr != frame.sbr || p_sys->b_ps != frame.ps) &&
-            p_dec->p_parent->i_object_type == VLC_OBJECT_INPUT )
+        if( p_sys->b_sbr != frame.sbr || p_sys->b_ps != frame.ps )
         {
-            input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
-            char *psz_cat;
             const char *psz_ext = (frame.sbr && frame.ps) ? "SBR+PS" :
                                     frame.sbr ? "SBR" : "PS";
 
             msg_Dbg( p_dec, "AAC %s (channels: %u, samplerate: %lu)",
                     psz_ext, frame.channels, frame.samplerate );
 
-            if( asprintf( &psz_cat, _("Stream %d"), p_dec->fmt_in.i_id ) != -1 )
-            {
-                input_Control( p_input, INPUT_ADD_INFO, psz_cat,
-                            _("AAC extension"), "%s", psz_ext );
-                input_Control( p_input, INPUT_ADD_INFO, psz_cat,
-                            _("Channels"), "%d", frame.channels );
-                input_Control( p_input, INPUT_ADD_INFO, psz_cat,
-                            _("Sample rate"), _("%d Hz"), frame.samplerate );
-                free( psz_cat );
-            }
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, _("AAC extension"), psz_ext );
+
             p_sys->b_sbr = frame.sbr; p_sys->b_ps = frame.ps;
         }
 
diff --git a/modules/codec/kate.c b/modules/codec/kate.c
index ced41c9..2f2be9e 100644
--- a/modules/codec/kate.c
+++ b/modules/codec/kate.c
@@ -702,16 +702,13 @@ static subpicture_t *DecodePacket( decoder_t *p_dec, kate_packet *p_kp, block_t
 }
 
 /*****************************************************************************
- * ParseKateComments: FIXME should be done in demuxer
+ * ParseKateComments:
  *****************************************************************************/
 static void ParseKateComments( decoder_t *p_dec )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     char *psz_name, *psz_value, *psz_comment;
     int i = 0;
 
-    if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
-
     while ( i < p_dec->p_sys->kc.comments )
     {
         psz_comment = strdup( p_dec->p_sys->kc.user_comments[i] );
@@ -723,8 +720,11 @@ static void ParseKateComments( decoder_t *p_dec )
         {
             *psz_value = '\0';
             psz_value++;
-            input_Control( p_input, INPUT_ADD_INFO, _("Kate comment"),
-                           psz_name, "%s", psz_value );
+
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
         }
         free( psz_comment );
         i++;
diff --git a/modules/codec/speex.c b/modules/codec/speex.c
index c67379d..547448c 100644
--- a/modules/codec/speex.c
+++ b/modules/codec/speex.c
@@ -812,7 +812,7 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
 }
 
 /*****************************************************************************
- * ParseSpeexComments: FIXME should be done in demuxer
+ * ParseSpeexComments:
  *****************************************************************************/
 #define readint(buf, base) (((buf[base+3]<<24)&0xff000000)| \
                            ((buf[base+2]<<16)&0xff0000)| \
@@ -821,40 +821,31 @@ static block_t *SendPacket( decoder_t *p_dec, block_t *p_block )
 
 static void ParseSpeexComments( decoder_t *p_dec, ogg_packet *p_oggpacket )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     decoder_sys_t *p_sys = p_dec->p_sys;
-
-    char *p_buf = (char *)p_oggpacket->packet;
     const SpeexMode *p_mode;
-    int i_len;
-
-    if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
 
     assert( p_sys->p_header->mode < SPEEX_NB_MODES );
 
     p_mode = speex_mode_list[p_sys->p_header->mode];
     assert( p_mode != NULL );
 
-    input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), _("Mode"),
-                   "%s%s", p_mode->modeName,
-                   p_sys->p_header->vbr ? " VBR" : "" );
-
-    if( p_oggpacket->bytes < 8 )
+    if( !p_dec->p_description )
     {
-        msg_Err( p_dec, "invalid/corrupted comments" );
-        return;
+        p_dec->p_description = vlc_meta_New();
+        if( !p_dec->p_description )
+            return;
     }
 
-    i_len = readint( p_buf, 0 ); p_buf += 4;
-    if( i_len > p_oggpacket->bytes - 4 )
+    /* */
+    char *psz_mode;
+    if( asprintf( &psz_mode, "%s%s", p_mode->modeName, p_sys->p_header->vbr ? " VBR" : "" ) >= 0 )
     {
-        msg_Err( p_dec, "invalid/corrupted comments" );
-        return;
+        vlc_meta_AddExtra( p_dec->p_description, _("Mode"), psz_mode );
+        free( psz_mode );
     }
 
-    input_Control( p_input, INPUT_ADD_INFO, _("Speex comment"), p_buf, "" );
-
     /* TODO: finish comments parsing */
+    VLC_UNUSED( p_oggpacket );
 }
 
 /*****************************************************************************
diff --git a/modules/codec/theora.c b/modules/codec/theora.c
index 2380b23..5817bf0 100644
--- a/modules/codec/theora.c
+++ b/modules/codec/theora.c
@@ -506,16 +506,13 @@ static picture_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
 }
 
 /*****************************************************************************
- * ParseTheoraComments: FIXME should be done in demuxer
+ * ParseTheoraComments:
  *****************************************************************************/
 static void ParseTheoraComments( decoder_t *p_dec )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     char *psz_name, *psz_value, *psz_comment;
     int i = 0;
 
-    if( p_input->i_object_type != VLC_OBJECT_INPUT ) return;
-
     while ( i < p_dec->p_sys->tc.comments )
     {
         psz_comment = strdup( p_dec->p_sys->tc.user_comments[i] );
@@ -527,8 +524,11 @@ static void ParseTheoraComments( decoder_t *p_dec )
         {
             *psz_value = '\0';
             psz_value++;
-            input_Control( p_input, INPUT_ADD_INFO, _("Theora comment"),
-                           psz_name, "%s", psz_value );
+
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
         }
         free( psz_comment );
         i++;
diff --git a/modules/codec/vorbis.c b/modules/codec/vorbis.c
index f7a9078..4d079dc 100644
--- a/modules/codec/vorbis.c
+++ b/modules/codec/vorbis.c
@@ -605,16 +605,9 @@ static block_t *SendPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
  *****************************************************************************/
 static void ParseVorbisComments( decoder_t *p_dec )
 {
-    input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     char *psz_name, *psz_value, *psz_comment;
-    input_item_t *p_item;
     int i = 0;
 
-    if( p_input->i_object_type != VLC_OBJECT_INPUT )
-        return;
-
-    p_item = input_GetItem( p_input );
-
     while( i < p_dec->p_sys->vc.comments )
     {
         psz_comment = strdup( p_dec->p_sys->vc.user_comments[i] );
@@ -626,33 +619,12 @@ static void ParseVorbisComments( decoder_t *p_dec )
         {
             *psz_value = '\0';
             psz_value++;
-            input_Control( p_input, INPUT_ADD_INFO, _("Vorbis comment"),
-                           psz_name, "%s", psz_value );
-/*TODO: dot he test at the beginning and save time !! */
-#ifndef HAVE_TAGLIB
-            if( psz_value && ( *psz_value != '\0' ) )
-            {
-                if( !strcasecmp( psz_name, "artist" ) )
-                    input_item_SetArtist( p_item, psz_value );
-                else if( !strcasecmp( psz_name, "title" ) )
-                {
-                    input_item_SetTitle( p_item, psz_value );
-                    p_item->psz_name = strdup( psz_value );
-                }
-                else if( !strcasecmp( psz_name, "album" ) )
-                {
-                    input_item_SetAlbum( p_item, psz_value );
-                }
-                else if( !strcasecmp( psz_name, "musicbrainz_trackid" ) )
-                    input_item_SetTrackID( p_item, psz_value );
-#if 0 //not used
-                else if( !strcasecmp( psz_name, "musicbrainz_artistid" ) )
-                    vlc_meta_SetArtistID( p_item, psz_value );
-                else if( !strcasecmp( psz_name, "musicbrainz_albumid" ) )
-                    input_item_SetAlbumID( p_item, psz_value );
-#endif
-            }
-#endif
+
+            if( !p_dec->p_description )
+                p_dec->p_description = vlc_meta_New();
+            if( p_dec->p_description )
+                vlc_meta_AddExtra( p_dec->p_description, psz_name, psz_value );
+
             if( !strcasecmp( psz_name, "REPLAYGAIN_TRACK_GAIN" ) ||
                      !strcasecmp( psz_name, "RG_RADIO" ) )
             {




More information about the vlc-devel mailing list