]> git.sesse.net Git - vlc/blobdiff - modules/codec/vorbis.c
* all: compilation warning fixes (mainly missings headers).
[vlc] / modules / codec / vorbis.c
index f21f1c6be30e1c8c7eaa638b6bb710946275e9b3..694085a2b1d4d39dc37cb40ada5615ca8e21701b 100644 (file)
@@ -2,7 +2,7 @@
  * vorbis.c: vorbis decoder/encoder/packetizer module making use of libvorbis.
  *****************************************************************************
  * Copyright (C) 2001-2003 VideoLAN
- * $Id: vorbis.c,v 1.27 2003/12/15 21:54:55 gbazin Exp $
+ * $Id: vorbis.c,v 1.32 2004/02/22 15:57:41 fenrir Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -10,7 +10,7 @@
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@@ -26,6 +26,8 @@
  *****************************************************************************/
 #include <vlc/vlc.h>
 #include <vlc/decoder.h>
+#include <vlc/input.h>
+#include "vlc_playlist.h"
 
 #include <ogg/ogg.h>
 
@@ -248,8 +250,8 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
         if( vorbis_synthesis_headerin( &p_sys->vi, &p_sys->vc,
                                        &oggpacket ) < 0 )
         {
-            msg_Err( p_dec, "This bitstream does not contain Vorbis "
-                     "audio data");
+            msg_Err( p_dec, "this bitstream does not contain Vorbis "
+                     "audio data.");
             block_Release( *pp_block );
             return NULL;
         }
@@ -283,7 +285,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             return NULL;
         }
         p_sys->i_headers++;
-    
+
         ParseVorbisComments( p_dec );
 
         return ProcessPacket( p_dec, &oggpacket, pp_block );
@@ -302,7 +304,7 @@ static void *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             return NULL;
         }
         p_sys->i_headers++;
-    
+
         if( !p_sys->b_packetizer )
         {
             /* Initialize the Vorbis packet->PCM decoder */
@@ -452,7 +454,10 @@ static void ParseVorbisComments( decoder_t *p_dec )
 {
     input_thread_t *p_input = (input_thread_t *)p_dec->p_parent;
     input_info_category_t *p_cat =
-        input_InfoCategory( p_input, _("Vorbis Comment") );
+        input_InfoCategory( p_input, _("Vorbis comment") );
+    playlist_t *p_playlist = vlc_object_find( p_dec, VLC_OBJECT_PLAYLIST,
+                                              FIND_ANYWHERE );
+    playlist_item_t *p_item;
     int i = 0;
     char *psz_name, *psz_value, *psz_comment;
     while ( i < p_dec->p_sys->vc.comments )
@@ -460,7 +465,7 @@ static void ParseVorbisComments( decoder_t *p_dec )
         psz_comment = strdup( p_dec->p_sys->vc.user_comments[i] );
         if( !psz_comment )
         {
-            msg_Warn( p_dec, "Out of memory" );
+            msg_Warn( p_dec, "out of memory" );
             break;
         }
         psz_name = psz_comment;
@@ -470,19 +475,33 @@ static void ParseVorbisComments( decoder_t *p_dec )
             *psz_value = '\0';
             psz_value++;
             input_AddInfo( p_cat, psz_name, psz_value );
+            vlc_mutex_lock( &p_playlist->object_lock );
+            p_item = playlist_ItemGetByPos( p_playlist, -1 );
+            vlc_mutex_unlock( &p_playlist->object_lock );
+            if( !p_item)
+            {
+                    msg_Err(p_dec, "unable to find item" );
+                    return;
+            }
+            vlc_mutex_lock( &p_item->lock );
+            playlist_ItemAddInfo( p_item, _("Vorbis comment") ,
+                            psz_name, psz_value );
+            vlc_mutex_unlock( &p_item->lock );
         }
         free( psz_comment );
         i++;
     }
+    if( p_playlist ) vlc_object_release( p_playlist );
 }
 
 /*****************************************************************************
  * Interleave: helper function to interleave channels
  *****************************************************************************/
+static void Interleave(
 #ifdef MODULE_NAME_IS_tremor
-static void Interleave( int32_t *p_out, const int32_t **pp_in,
+                        int32_t *p_out, const int32_t **pp_in,
 #else
-static void Interleave( float *p_out, const float **pp_in,
+                        float *p_out, const float **pp_in,
 #endif
                         int i_nb_channels, int i_samples )
 {
@@ -579,10 +598,13 @@ static int OpenEncoder( vlc_object_t *p_this )
     vorbis_info_init( &p_sys->vi );
 
     if( vorbis_encode_setup_managed( &p_sys->vi,
-           p_enc->fmt_in.audio.i_channels, p_enc->fmt_in.audio.i_rate,
+            p_enc->fmt_in.audio.i_channels, p_enc->fmt_in.audio.i_rate,
             -1, p_enc->fmt_out.i_bitrate, -1 ) ||
         vorbis_encode_ctl( &p_sys->vi, OV_ECTL_RATEMANAGE_AVG, NULL ) ||
-        vorbis_encode_setup_init( &p_sys->vi ) ){}
+        vorbis_encode_setup_init( &p_sys->vi ) )
+    {
+        ;
+    }
 
     /* add a comment */
     vorbis_comment_init( &p_sys->vc);