]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/sdl.c
* include/vlc_common.h:
[vlc] / modules / audio_output / sdl.c
index 806e1f431e6db861a6e90897e6f2abee0cd7a3b4..7695bfd35383d687c33a0722234c6d71fbf8a3e3 100644 (file)
@@ -2,18 +2,18 @@
  * sdl.c : SDL audio output plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2002 VideoLAN
- * $Id: sdl.c,v 1.16 2002/12/07 15:25:26 gbazin Exp $
+ * $Id: sdl.c,v 1.23 2003/10/25 00:49:13 sam Exp $
  *
  * Authors: Michel Kaempf <maxx@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
  *          Pierre Baillet <oct@zoy.org>
  *          Christophe Massiot <massiot@via.ecp.fr>
- *      
+ *
  * This program is free software; you can redistribute it and/or modify
  * 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
@@ -48,7 +48,7 @@
  * It describes the specific properties of an audio device.
  *****************************************************************************/
 struct aout_sys_t
-{   
+{
     mtime_t next_date;
     mtime_t buffer_time;
 };
@@ -65,7 +65,7 @@ static void SDLCallback ( void *, byte_t *, int );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("Simple DirectMedia Layer audio module") );
+    set_description( _("Simple DirectMedia Layer audio output") );
     set_capability( "audio output", 40 );
     add_shortcut( "sdl" );
     set_callbacks( Open, Close );
@@ -79,9 +79,10 @@ static int Open ( vlc_object_t *p_this )
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
     SDL_AudioSpec desired, obtained;
     int i_nb_channels;
+    vlc_value_t val, text;
 
     /* Check that no one uses the DSP. */
-    Uint32 i_flags = SDL_INIT_AUDIO;
+    uint32_t i_flags = SDL_INIT_AUDIO;
     if( SDL_WasInit( i_flags ) )
     {
         return VLC_EGENERIC;
@@ -104,22 +105,20 @@ static int Open ( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    if ( var_Type( p_aout, "audio-device" ) ==
-             (VLC_VAR_STRING | VLC_VAR_HASCHOICE) )
+    if ( var_Type( p_aout, "audio-device" ) != 0 )
     {
         /* The user has selected an audio device. */
         vlc_value_t val;
         var_Get( p_aout, "audio-device", &val );
-        if ( !strcmp( val.psz_string, N_("Stereo") ) )
+        if ( val.i_int == AOUT_VAR_STEREO )
         {
             p_aout->output.output.i_physical_channels
                 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
         }
-        else if ( !strcmp( val.psz_string, N_("Mono") ) )
+        else if ( val.i_int == AOUT_VAR_MONO )
         {
             p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
         }
-        free( val.psz_string );
     }
 
     i_nb_channels = aout_FormatNbChannels( &p_aout->output.output );
@@ -170,40 +169,52 @@ static int Open ( vlc_object_t *p_this )
                                             AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT :
                                             AOUT_CHAN_CENTER);
 
-        if ( var_Type( p_aout, "audio-device" ) < 0 )
+        if ( var_Type( p_aout, "audio-device" ) == 0 )
         {
-            vlc_value_t val;
-            var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
-            val.psz_string = (obtained.channels == 2) ? N_("Stereo") :
+            var_Create( p_aout, "audio-device",
+                        VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
+            text.psz_string = _("Audio device");
+            var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL );
+
+            val.i_int = (obtained.channels == 2) ? AOUT_VAR_STEREO :
+                       AOUT_VAR_MONO;
+            text.psz_string = (obtained.channels == 2) ? N_("Stereo") :
                               N_("Mono");
-            var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
+            var_Change( p_aout, "audio-device",
+                        VLC_VAR_ADDCHOICE, &val, &text );
             var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart,
                              NULL );
         }
     }
-    else if ( var_Type( p_aout, "audio-device" ) < 0 )
+    else if ( var_Type( p_aout, "audio-device" ) == 0 )
     {
         /* First launch. */
-        vlc_value_t val;
-        var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
-        val.psz_string = N_("Stereo");
-        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
-        val.psz_string = N_("Mono");
-        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
+        var_Create( p_aout, "audio-device",
+                    VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
+        text.psz_string = _("Audio device");
+        var_Change( p_aout, "audio-device", VLC_VAR_SETTEXT, &text, NULL );
+
+        val.i_int = AOUT_VAR_STEREO;
+        text.psz_string = N_("Stereo");
+        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
+        val.i_int = AOUT_VAR_MONO;
+        text.psz_string = N_("Mono");
+        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
         if ( i_nb_channels == 2 )
         {
-            val.psz_string = N_("Stereo");
+            val.i_int = AOUT_VAR_STEREO;
         }
         else
         {
-            val.psz_string = N_("Mono");
+            val.i_int = AOUT_VAR_MONO;
         }
-        var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val );
-
-        var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart,
-                         NULL );
+        var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+        var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
     }
 
+    val.b_bool = VLC_TRUE;
+    var_Set( p_aout, "intf-change", val );
+
     p_aout->output.output.i_rate = obtained.freq;
     p_aout->output.i_nb_samples = obtained.samples;
     p_aout->output.pf_play = Play;