]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/shoutcast.c
(p?)gettext -> vlc_\1gettext
[vlc] / modules / demux / playlist / shoutcast.c
index b0cb0e9b525da2e67d799696ed556a426a3b2380..e5257de3dd1d61b001f0f744e7b36e9367017d6e 100644 (file)
@@ -30,7 +30,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_demux.h>
 
 #include "playlist.h"
@@ -38,7 +38,6 @@
 
 struct demux_sys_t
 {
-    playlist_t *p_playlist;
     input_item_t *p_current_input;
 
     xml_t *p_xml;
@@ -64,7 +63,7 @@ static int DemuxStation( demux_t *p_demux );
 /*****************************************************************************
  * Import_Shoutcast: main import function
  *****************************************************************************/
-int E_(Import_Shoutcast)( vlc_object_t *p_this )
+int Import_Shoutcast( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
 
@@ -72,7 +71,6 @@ int E_(Import_Shoutcast)( vlc_object_t *p_this )
         return VLC_EGENERIC;
 
     STANDARD_DEMUX_INIT_MSG( "using shoutcast playlist reader" );
-    p_demux->p_sys->p_playlist = NULL;
     p_demux->p_sys->p_xml = NULL;
     p_demux->p_sys->p_xml_reader = NULL;
 
@@ -87,13 +85,11 @@ int E_(Import_Shoutcast)( vlc_object_t *p_this )
 /*****************************************************************************
  * Deactivate: frees unused data
  *****************************************************************************/
-void E_(Close_Shoutcast)( vlc_object_t *p_this )
+void Close_Shoutcast( vlc_object_t *p_this )
 {
     demux_t *p_demux = (demux_t *)p_this;
     demux_sys_t *p_sys = p_demux->p_sys;
 
-    if( p_sys->p_playlist )
-        vlc_object_release( p_sys->p_playlist );
     if( p_sys->p_xml_reader )
         xml_ReaderDelete( p_sys->p_xml, p_sys->p_xml_reader );
     if( p_sys->p_xml )
@@ -108,7 +104,6 @@ static int Demux( demux_t *p_demux )
     xml_reader_t *p_xml_reader;
     char *psz_eltname = NULL;
     INIT_PLAYLIST_STUFF;
-    p_sys->p_playlist = p_playlist;
     p_sys->p_current_input = p_current_input;
 
     p_xml = p_sys->p_xml = xml_Create( p_demux );
@@ -150,7 +145,6 @@ static int Demux( demux_t *p_demux )
     }
 
     HANDLE_PLAY_AND_RELEASE;
-    p_sys->p_playlist = NULL;
     return 0; /* Needed for correct operation of go back */
 }
 
@@ -230,17 +224,16 @@ static int DemuxGenre( demux_t *p_demux )
                 if( !psz_eltname ) return -1;
                 if( !strcmp( psz_eltname, "genre" ) )
                 {
-                    char *psz_mrl = malloc( strlen( SHOUTCAST_BASE_URL )
-                            + strlen( "?genre=" ) + strlen( psz_name ) + 1 );
-                    sprintf( psz_mrl, SHOUTCAST_BASE_URL "?genre=%s",
-                             psz_name );
-                    p_input = input_ItemNewExt( p_sys->p_playlist, psz_mrl,
-                                                psz_name, 0, NULL, -1 );
-                    input_ItemCopyOptions( p_sys->p_current_input,
-                                                p_input );
-                    free( psz_mrl );
-                    input_ItemAddSubItem( p_sys->p_current_input, p_input );
-                    vlc_gc_decref( p_input );
+                    char* psz_mrl;
+                    if( asprintf( &psz_mrl, SHOUTCAST_BASE_URL "?genre=%s",
+                             psz_name ) != -1 )
+                    {
+                        p_input = input_item_New( p_demux, psz_mrl, psz_name );
+                        input_item_CopyOptions( p_sys->p_current_input, p_input );
+                        free( psz_mrl );
+                        input_item_AddSubItem( p_sys->p_current_input, p_input );
+                        vlc_gc_decref( p_input );
+                    }
                     FREENULL( psz_name );
                 }
                 FREENULL( psz_eltname );
@@ -324,9 +317,9 @@ static int DemuxStation( demux_t *p_demux )
                             xml_ReaderValue( p_sys->p_xml_reader );
                         if( !psz_attrname || !psz_attrvalue )
                         {
-                            free(psz_eltname);
-                            FREENULL(psz_attrname);
-                            FREENULL(psz_attrvalue);
+                            free( psz_eltname );
+                            free( psz_attrname );
+                            free( psz_attrvalue );
                             return -1;
                         }
 
@@ -350,9 +343,9 @@ static int DemuxStation( demux_t *p_demux )
                             xml_ReaderValue( p_sys->p_xml_reader );
                         if( !psz_attrname || !psz_attrvalue )
                         {
-                            free(psz_eltname);
-                            FREENULL(psz_attrname);
-                            FREENULL(psz_attrvalue);
+                            free( psz_eltname );
+                            free( psz_attrname );
+                            free( psz_attrvalue );
                             return -1;
                         }
 
@@ -375,7 +368,7 @@ static int DemuxStation( demux_t *p_demux )
                         free( psz_attrvalue );
                     }
                 }
-                free(psz_eltname);
+                free( psz_eltname );
                 break;
 
             case XML_READER_TEXT:
@@ -394,40 +387,36 @@ static int DemuxStation( demux_t *p_demux )
                     if( psz_rt || psz_load )
                     {
                         /* tv */
-                        psz_mrl = malloc( strlen( SHOUTCAST_TV_TUNEIN_URL )
-                                          + strlen( psz_id ) + 1 );
-                        sprintf( psz_mrl, SHOUTCAST_TV_TUNEIN_URL "%s",
-                                 psz_id );
+                        if( asprintf( &psz_mrl, SHOUTCAST_TV_TUNEIN_URL "%s",
+                                 psz_id ) == -1)
+                            psz_mrl = NULL;
                     }
                     else
                     {
                         /* radio */
-                        psz_mrl = malloc( strlen( SHOUTCAST_TUNEIN_BASE_URL )
-                            + strlen( psz_base ) + strlen( "?id=" )
-                            + strlen( psz_id ) + 1 );
-                        sprintf( psz_mrl, SHOUTCAST_TUNEIN_BASE_URL "%s?id=%s",
-                             psz_base, psz_id );
+                        if( asprintf( &psz_mrl, SHOUTCAST_TUNEIN_BASE_URL "%s?id=%s",
+                             psz_base, psz_id ) == -1 )
+                            psz_mrl = NULL;
                     }
-                    p_input = input_ItemNewExt( p_sys->p_playlist, psz_mrl,
-                                                psz_name , 0, NULL, -1 );
+                    p_input = input_item_New( p_demux, psz_mrl, psz_name );
+                    input_item_CopyOptions( p_sys->p_current_input, p_input );
                     free( psz_mrl );
 
-                    input_ItemCopyOptions( p_sys->p_current_input,
-                                                p_input );
-
-#define SADD_INFO( type, field ) if( field ) { input_ItemAddInfo( \
-                    p_input, _("Shoutcast"), _(type), "%s", field ) ; }
-                    SADD_INFO( "Mime type", psz_mt );
-                    SADD_INFO( "Bitrate", psz_br );
-                    SADD_INFO( "Listeners", psz_lc );
-                    SADD_INFO( "Load", psz_load );
+#define SADD_INFO( type, field ) \
+                    if( field ) \
+                        input_item_AddInfo( p_input, _("Shoutcast"), \
+                                            vlc_gettext(type), "%s", field )
+                    SADD_INFO( N_("Mime"), psz_mt );
+                    SADD_INFO( N_("Bitrate"), psz_br );
+                    SADD_INFO( N_("Listeners"), psz_lc );
+                    SADD_INFO( N_("Load"), psz_load );
                     if( psz_genre )
                         input_item_SetGenre( p_input, psz_genre );
                     if( psz_ct )
                         input_item_SetNowPlaying( p_input, psz_ct );
                     if( psz_rt )
                         input_item_SetRating( p_input, psz_rt );
-                    input_ItemAddSubItem( p_sys->p_current_input, p_input );
+                    input_item_AddSubItem( p_sys->p_current_input, p_input );
                     vlc_gc_decref( p_input );
                     FREENULL( psz_name );
                     FREENULL( psz_mt );