]> git.sesse.net Git - vlc/blobdiff - modules/demux/mod.c
http access: Use EnsureUTF8() on the ICY strings. Avoids "illegal byte sequence"...
[vlc] / modules / demux / mod.c
index 6b081e51d5ba2ff1796bca832ea955b5bdc13536..126119927982e59ddd794ffef96e1981934ec43e 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * mod.c: MOD file demuxer (using libmodplug)
  *****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004 the VideoLAN team
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
 
-#include <vlc/vlc.h>
-#include <vlc/input.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_demux.h>
 
 #include <libmodplug/modplug.h>
 
 static int  Open    ( vlc_object_t * );
 static void Close  ( vlc_object_t * );
 
+#define NOISE_LONGTEXT N_("Enable noise reduction algorithm.")
+#define REVERB_LONGTEXT N_("Enable reverberation" )
+#define REVERB_LEVEL_LONGTEXT N_( "Reverberation level (from 0 " \
+                "to 100, default value is 0)." )
+#define REVERB_DELAY_LONGTEXT N_("Reverberation delay, in ms." \
+                " Usual values are from to 40 to 200ms." )
+#define MEGABASS_LONGTEXT N_( "Enable megabass mode" )
+#define MEGABASS_LEVEL_LONGTEXT N_("Megabass mode level (from 0 to 100, " \
+                "default value is 0)." )
+#define MEGABASS_RANGE_LONGTEXT N_("Megabass mode cutoff frequency, in Hz. " \
+                "This is the maximum frequency for which the megabass " \
+                "effect applies. Valid values are from 10 to 100 Hz." )
+#define SURROUND_LEVEL_LONGTEXT N_( "Surround effect level (from 0 to 100, " \
+                "default value is 0)." )
+#define SURROUND_DELAY_LONGTEXT N_("Surround delay, in ms. Usual values are " \
+                "from 5 to 40 ms." )
+
 vlc_module_begin();
-    set_description( _("MOD demuxer (libmodplug)" ) );
-    set_capability( "demux2", 10 );
+    set_shortname( "MOD");
+    set_description( N_("MOD demuxer (libmodplug)" ) );
+    set_capability( "demux", 10 );
     set_category( CAT_INPUT );
     set_subcategory( SUBCAT_INPUT_DEMUX );
 
-    add_bool( "mod-noisereduction", VLC_TRUE, NULL, N_("Noise reduction"), N_("Noise reduction"), VLC_FALSE );
-
-    add_bool( "mod-reverb", VLC_FALSE, NULL, N_("Reverb"), N_("Reverb"), VLC_FALSE );
-    add_integer_with_range( "mod-reverb-level", 0, 0, 100, NULL, N_("Reverb level (0-100)"), N_("Reverb level (0-100 defaults to 0)"), VLC_FALSE );
-    add_integer_with_range( "mod-reverb-delay", 40, 0, 1000, NULL, N_("Reverb delay (ms)"), N_("Reverb delay in ms (usually 40-200ms)"), VLC_FALSE );
-
-    add_bool( "mod-megabass", VLC_FALSE, NULL, N_("Mega bass"), N_("Mega bass"), VLC_FALSE );
-    add_integer_with_range( "mod-megabass-level", 0, 0, 100, NULL, N_("Mega bass level (0-100)"), N_("Mega bass level (0-100 defaults to 0)"), VLC_FALSE );
-    add_integer_with_range( "mod-megabass-range", 10, 10, 100, NULL, N_("Mega bass cut off (Hz)"), N_("Mega bass cut off (10-100Hz)"), VLC_FALSE );
-
-    add_bool( "mod-surround", VLC_FALSE, NULL, N_("Surround"), N_("Surround"), VLC_FALSE );
-    add_integer_with_range( "mod-surround-level", 0, 0, 100, NULL, N_("Surround level (0-100)"), N_("Surround level (0-100 defaults to 0)"), VLC_FALSE );
-    add_integer_with_range( "mod-surround-delay", 5, 0, 1000, NULL, N_("Surround delay (ms)"), N_("Surround delay in ms (usually 5-40ms)"), VLC_FALSE );
+    add_bool( "mod-noisereduction", true, NULL, N_("Noise reduction"),
+              NOISE_LONGTEXT, false );
+
+    add_bool( "mod-reverb", false, NULL, N_("Reverb"),
+              REVERB_LONGTEXT, false );
+    add_integer_with_range( "mod-reverb-level", 0, 0, 100, NULL,
+             N_("Reverberation level"), REVERB_LEVEL_LONGTEXT, true );
+    add_integer_with_range( "mod-reverb-delay", 40, 0, 1000, NULL,
+             N_("Reverberation delay"), REVERB_DELAY_LONGTEXT, true );
+
+    add_bool( "mod-megabass", false, NULL, N_("Mega bass"),
+                    MEGABASS_LONGTEXT, false );
+    add_integer_with_range( "mod-megabass-level", 0, 0, 100, NULL,
+              N_("Mega bass level"), MEGABASS_LEVEL_LONGTEXT, true );
+    add_integer_with_range( "mod-megabass-range", 10, 10, 100, NULL,
+              N_("Mega bass cutoff"), MEGABASS_RANGE_LONGTEXT, true );
+
+    add_bool( "mod-surround", false, NULL, N_("Surround"), N_("Surround"),
+               false );
+    add_integer_with_range( "mod-surround-level", 0, 0, 100, NULL,
+              N_("Surround level"), SURROUND_LEVEL_LONGTEXT, true );
+    add_integer_with_range( "mod-surround-delay", 5, 0, 1000, NULL,
+              N_("Surround delay (ms)"), SURROUND_DELAY_LONGTEXT, true );
 
     set_callbacks( Open, Close );
     add_shortcut( "mod" );
@@ -102,19 +134,17 @@ static int Open( vlc_object_t *p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
-    char        *ext;
-    int         i;
     ModPlug_Settings settings;
     vlc_value_t val;
 
-    /* We accept file based on extention match */
-    if( strcasecmp( p_demux->psz_demux, "mod" ) )
+    /* We accept file based on extension match */
+    if( !p_demux->b_force )
     {
-        if( ( ext = strchr( p_demux->psz_path, '.' ) ) == NULL || stream_Size( p_demux->s ) == 0 )
-        {
-            msg_Warn( p_demux, "MOD module discarded (path=%s)", p_demux->psz_path );
-            return VLC_EGENERIC;
-        }
+        char *ext;
+        int i;
+        if( ( ext = strrchr( p_demux->psz_path, '.' ) ) == NULL ||
+            stream_Size( p_demux->s ) == 0 ) return VLC_EGENERIC;
+
         ext++;  /* skip . */
         for( i = 0; mod_ext[i] != NULL; i++ )
         {
@@ -123,11 +153,7 @@ static int Open( vlc_object_t *p_this )
                 break;
             }
         }
-        if( mod_ext[i] == NULL )
-        {
-            msg_Warn( p_demux, "MOD module discarded (extention '%s' unknown)", ext );
-            return VLC_EGENERIC;
-        }
+        if( mod_ext[i] == NULL ) return VLC_EGENERIC;
         msg_Dbg( p_demux, "running MOD demuxer (ext=%s)", mod_ext[i] );
     }
 
@@ -207,7 +233,7 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_time  = 1;
     p_sys->i_length = ModPlug_GetLength( p_sys->f ) * (int64_t)1000;
 
-    msg_Dbg( p_demux, "MOD loaded name=%s lenght="I64Fd"ms",
+    msg_Dbg( p_demux, "MOD loaded name=%s lenght=%"PRId64"ms",
              ModPlug_GetName( p_sys->f ),
              p_sys->i_length );