]> git.sesse.net Git - vlc/blobdiff - modules/access_output/shout.c
Remove uneeded warining (and often impossible to send)
[vlc] / modules / access_output / shout.c
index 91bb86b86d18e81675d85b9928d9c661cac53f24..5a73958666648492a5e91e98fb4c959482f76bca 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_sout.h>
 #include <vlc_block.h>
 
@@ -102,40 +107,40 @@ static void Close( vlc_object_t * );
                            "shoutcast. Requires Ogg streaming for icecast." )
 
 vlc_module_begin();
-    set_description( _("IceCAST output") );
+    set_description( N_("IceCAST output") );
     set_shortname( "Shoutcast" );
     set_capability( "sout access", 50 );
     set_category( CAT_SOUT );
     set_subcategory( SUBCAT_SOUT_ACO );
     add_shortcut( "shout" );
     add_string( SOUT_CFG_PREFIX "name", "VLC media player - Live stream", NULL,
-                NAME_TEXT, NAME_LONGTEXT, VLC_FALSE );
+                NAME_TEXT, NAME_LONGTEXT, false );
     add_string( SOUT_CFG_PREFIX "description",
                  "Live stream from VLC media player", NULL,
-                DESCRIPTION_TEXT, DESCRIPTION_LONGTEXT, VLC_FALSE );
-    add_bool(   SOUT_CFG_PREFIX "mp3", VLC_FALSE, NULL,
-                MP3_TEXT, MP3_LONGTEXT, VLC_TRUE );
+                DESCRIPTION_TEXT, DESCRIPTION_LONGTEXT, false );
+    add_bool(   SOUT_CFG_PREFIX "mp3", false, NULL,
+                MP3_TEXT, MP3_LONGTEXT, true );
     add_string( SOUT_CFG_PREFIX "genre", "Alternative", NULL,
-                GENRE_TEXT, GENRE_LONGTEXT, VLC_FALSE );
+                GENRE_TEXT, GENRE_LONGTEXT, false );
     add_string( SOUT_CFG_PREFIX "url", "http://www.videolan.org/vlc", NULL,
-                URL_TEXT, URL_LONGTEXT, VLC_FALSE );
+                URL_TEXT, URL_LONGTEXT, false );
     add_string( SOUT_CFG_PREFIX "bitrate", "", NULL,
-                BITRATE_TEXT, BITRATE_LONGTEXT, VLC_FALSE );
+                BITRATE_TEXT, BITRATE_LONGTEXT, false );
     add_string( SOUT_CFG_PREFIX "samplerate", "", NULL,
-                SAMPLERATE_TEXT, SAMPLERATE_LONGTEXT, VLC_FALSE );
+                SAMPLERATE_TEXT, SAMPLERATE_LONGTEXT, false );
     add_string( SOUT_CFG_PREFIX "channels", "", NULL,
-                CHANNELS_TEXT, CHANNELS_LONGTEXT, VLC_FALSE );
+                CHANNELS_TEXT, CHANNELS_LONGTEXT, false );
     add_string( SOUT_CFG_PREFIX "quality", "", NULL,
-                QUALITY_TEXT, QUALITY_LONGTEXT, VLC_FALSE );
-    add_bool(   SOUT_CFG_PREFIX "public", VLC_FALSE, NULL,
-                PUBLIC_TEXT, PUBLIC_LONGTEXT, VLC_TRUE );
+                QUALITY_TEXT, QUALITY_LONGTEXT, false );
+    add_bool(   SOUT_CFG_PREFIX "public", false, NULL,
+                PUBLIC_TEXT, PUBLIC_LONGTEXT, true );
     set_callbacks( Open, Close );
 vlc_module_end();
 
 /*****************************************************************************
  * Exported prototypes
  *****************************************************************************/
-static const char *ppsz_sout_options[] = {
+static const char *const ppsz_sout_options[] = {
     "name", "description", "mp3", "genre", "url", "bitrate", "samplerate",
     "channels", "quality", "public", NULL
 };
@@ -144,9 +149,9 @@ static const char *ppsz_sout_options[] = {
 /*****************************************************************************
  * Exported prototypes
  *****************************************************************************/
-static int Write( sout_access_out_t *, block_t * );
+static ssize_t Write( sout_access_out_t *, block_t * );
 static int Seek ( sout_access_out_t *, off_t  );
-static int Read ( sout_access_out_t *, block_t * );
+static int Control( sout_access_out_t *, int, va_list );
 
 struct sout_access_out_sys_t
 {
@@ -179,8 +184,6 @@ static int Open( vlc_object_t *p_this )
 
     config_ChainParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );
 
-    psz_accessname = psz_parser = strdup( p_access->psz_path );
-
     if( !p_access->psz_path )
     {
         msg_Err( p_access,
@@ -188,6 +191,10 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
+    psz_accessname = psz_parser = strdup( p_access->psz_path );
+    if( !psz_parser )
+        return VLC_ENOMEM;
+
     /* Parse connection data user:pwd@host:port/mountpoint */
     psz_user = psz_parser;
     while( psz_parser[0] && psz_parser[0] != ':' ) psz_parser++;
@@ -208,7 +215,6 @@ static int Open( vlc_object_t *p_this )
     p_sys = p_access->p_sys = malloc( sizeof( sout_access_out_sys_t ) );
     if( !p_sys )
     {
-        msg_Err( p_access, "out of memory" );
         free( psz_accessname );
         return VLC_ENOMEM;
     }
@@ -257,16 +263,20 @@ static int Open( vlc_object_t *p_this )
                  psz_host, i_port, psz_mount );
         free( p_access->p_sys );
         free( psz_accessname );
+        free( psz_name );
+        free( psz_description );
+        free( psz_genre );
+        free( psz_url );
         return VLC_EGENERIC;
     }
 
-    if( psz_name ) free( psz_name );
-    if( psz_description ) free( psz_description );
-    if( psz_genre ) free( psz_genre );
-    if( psz_url ) free( psz_url );
+    free( psz_name );
+    free( psz_description );
+    free( psz_genre );
+    free( psz_url );
 
     var_Get( p_access, SOUT_CFG_PREFIX "mp3", &val );
-    if( val.b_bool == VLC_TRUE )
+    if( val.b_bool == true )
         i_ret = shout_set_format( p_shout, SHOUT_FORMAT_MP3 );
     else
         i_ret = shout_set_format( p_shout, SHOUT_FORMAT_OGG );
@@ -288,6 +298,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about the bitrate" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -313,6 +324,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about the samplerate" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -328,6 +340,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about the number of channels" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -343,6 +356,7 @@ static int Open( vlc_object_t *p_this )
         if( i_ret != SHOUTERR_SUCCESS )
         {
             msg_Err( p_access, "failed to set the information about Ogg Vorbis quality" );
+            free( val.psz_string );
             free( p_access->p_sys );
             free( psz_accessname );
             return VLC_EGENERIC;
@@ -352,7 +366,7 @@ static int Open( vlc_object_t *p_this )
         free( val.psz_string );
 
     var_Get( p_access, SOUT_CFG_PREFIX "public", &val );
-    if( val.b_bool == VLC_TRUE )
+    if( val.b_bool == true )
     {
         i_ret = shout_set_public( p_shout, 1 );
         if( i_ret != SHOUTERR_SUCCESS )
@@ -445,18 +459,11 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_access->pf_write = Write;
-    p_access->pf_read  = Read;
     p_access->pf_seek  = Seek;
+    p_access->pf_control = Control;
 
     msg_Dbg( p_access, "shout access output opened (%s@%s:%i/%s)",
              psz_user, psz_host, i_port, psz_mount );
-
-    /* Update pace control flag */
-    if( p_access->psz_access && !strcmp( p_access->psz_access, "stream" ) )
-    {
-        p_access->p_sout->i_out_pace_nocontrol++;
-    }
-
     free( psz_accessname );
 
     return VLC_SUCCESS;
@@ -475,29 +482,30 @@ static void Close( vlc_object_t * p_this )
         shout_shutdown();
     }
     free( p_access->p_sys );
-
-    /* Update pace control flag */
-    if( p_access->psz_access && !strcmp( p_access->psz_access, "stream" ) )
-    {
-        p_access->p_sout->i_out_pace_nocontrol--;
-    }
-
     msg_Dbg( p_access, "shout access output closed" );
 }
 
-/*****************************************************************************
- * Read: standard read -- not supported
- *****************************************************************************/
-static int Read( sout_access_out_t *p_access, block_t *p_buffer )
+static int Control( sout_access_out_t *p_access, int i_query, va_list args )
 {
-    msg_Err( p_access, "cannot read from shout" );
-    return VLC_EGENERIC;
+    switch( i_query )
+    {
+        case ACCESS_OUT_CONTROLS_PACE:
+        {
+            bool *pb = va_arg( args, bool * );
+            *pb = strcmp( p_access->psz_access, "stream" );
+            break;
+        }
+
+        default:
+            return VLC_EGENERIC;
+    }
+    return VLC_SUCCESS;
 }
 
 /*****************************************************************************
  * Write: standard write
  *****************************************************************************/
-static int Write( sout_access_out_t *p_access, block_t *p_buffer )
+static ssize_t Write( sout_access_out_t *p_access, block_t *p_buffer )
 {
     size_t i_write = 0;
 
@@ -532,6 +540,8 @@ static int Write( sout_access_out_t *p_access, block_t *p_buffer )
             else
             {
                 msg_Err( p_access, "failed to reconnect to server" );
+                block_ChainRelease (p_buffer);
+                return VLC_EGENERIC;
             }
 
         }