]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/waveout.c
* modules/codec/ffmpeg/ffmpeg.c: clean-up for the ffmpeg config options.
[vlc] / modules / audio_output / waveout.c
index da1445f356753cf2025e1fb5cdc764dc52555814..ef039e3c469bef128864e7146a7dab48730c02dd 100644 (file)
@@ -2,7 +2,7 @@
  * waveout.c : Windows waveOut plugin for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: waveout.c,v 1.17 2003/02/17 22:19:24 gbazin Exp $
+ * $Id: waveout.c,v 1.25 2003/05/21 15:54:08 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *      
@@ -93,15 +93,9 @@ typedef struct {
 #endif
 
 #include <initguid.h>
-#ifndef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
-DEFINE_GUID( KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, WAVE_FORMAT_IEEE_FLOAT, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
-#endif
-#ifndef KSDATAFORMAT_SUBTYPE_PCM
-DEFINE_GUID( KSDATAFORMAT_SUBTYPE_PCM, WAVE_FORMAT_PCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
-#endif
-#ifndef KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF
-DEFINE_GUID( KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF, WAVE_FORMAT_DOLBY_AC3_SPDIF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
-#endif
+DEFINE_GUID( __KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, WAVE_FORMAT_IEEE_FLOAT, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
+DEFINE_GUID( __KSDATAFORMAT_SUBTYPE_PCM, WAVE_FORMAT_PCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
+DEFINE_GUID( __KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF, WAVE_FORMAT_DOLBY_AC3_SPDIF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
 
 /*****************************************************************************
  * Local prototypes
@@ -127,8 +121,8 @@ static void InterleaveS16( int16_t *, int *, int );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("Win32 waveOut extension module") );
-    set_capability( "audio output", 100 );
+    set_description( _("Win32 waveOut extension output") );
+    set_capability( "audio output", 50 );
     set_callbacks( Open, Close );
 vlc_module_end();
 
@@ -204,10 +198,9 @@ static int Open( vlc_object_t *p_this )
     }
 
     /* Open the device */
-    if( !strcmp( val.psz_string, N_("A/52 over S/PDIF") ) )
+    if( val.i_int == AOUT_VAR_SPDIF )
     {
         p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
-        free( val.psz_string );
 
         if( OpenWaveOut( p_aout, VLC_FOURCC('s','p','d','i'),
                          p_aout->output.output.i_physical_channels,
@@ -231,20 +224,20 @@ static int Open( vlc_object_t *p_this )
     }
     else
     {
-        if( !strcmp( val.psz_string, N_("5.1") ) )
+        if( val.i_int == AOUT_VAR_5_1 )
         {
             p_aout->output.output.i_physical_channels
                 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
                    | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
                    | AOUT_CHAN_LFE;
         }
-        else if( !strcmp( val.psz_string, N_("2 Front 2 Rear") ) )
+        else if( val.i_int == AOUT_VAR_2F2R )
         {
             p_aout->output.output.i_physical_channels
                 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
                    | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
         }
-        else if( !strcmp( val.psz_string, "Mono" ) )
+        else if( val.i_int == AOUT_VAR_MONO )
         {
             p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
         }
@@ -253,7 +246,6 @@ static int Open( vlc_object_t *p_this )
             p_aout->output.output.i_physical_channels
                 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
         }
-        free( val.psz_string );
 
         if( OpenWaveOutPCM( p_aout, &p_aout->output.output.i_format,
                             p_aout->output.output.i_physical_channels,
@@ -309,26 +301,13 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Probe( aout_instance_t * p_aout )
 {
-    vlc_value_t val;
+    vlc_value_t val, text;
     int i_format;
     unsigned int i_physical_channels;
 
-    var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
-
-    /* Test for SPDIF support */
-    if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) )
-    {
-        if( OpenWaveOut( p_aout, VLC_FOURCC('s','p','d','i'),
-                         p_aout->output.output.i_physical_channels,
-                         aout_FormatNbChannels( &p_aout->output.output ),
-                         p_aout->output.output.i_rate, VLC_TRUE )
-            == VLC_SUCCESS )
-        {
-            msg_Dbg( p_aout, "device supports A/52 over S/PDIF" );
-            val.psz_string = N_("A/52 over S/PDIF");
-            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 );
 
     /* Test for 5.1 support */
     i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
@@ -341,8 +320,10 @@ static void Probe( aout_instance_t * p_aout )
                             p_aout->output.output.i_rate, VLC_TRUE )
             == VLC_SUCCESS )
         {
-            val.psz_string = N_("5.1");
-            var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
+            val.i_int = AOUT_VAR_5_1;
+            text.psz_string = N_("5.1");
+            var_Change( p_aout, "audio-device",
+                        VLC_VAR_ADDCHOICE, &val, &text );
             msg_Dbg( p_aout, "device supports 5.1 channels" );
         }
     }
@@ -358,8 +339,10 @@ static void Probe( aout_instance_t * p_aout )
                             p_aout->output.output.i_rate, VLC_TRUE )
             == VLC_SUCCESS )
         {
-            val.psz_string = N_("2 Front 2 Rear");
-            var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
+            val.i_int = AOUT_VAR_2F2R;
+            text.psz_string = N_("2 Front 2 Rear");
+            var_Change( p_aout, "audio-device",
+                        VLC_VAR_ADDCHOICE, &val, &text );
             msg_Dbg( p_aout, "device supports 4 channels" );
         }
     }
@@ -371,9 +354,9 @@ static void Probe( aout_instance_t * p_aout )
                         p_aout->output.output.i_rate, VLC_TRUE )
         == VLC_SUCCESS )
     {
-        val.psz_string = N_("Stereo");
-        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
-        var_Set( p_aout, "audio-device", val );
+        val.i_int = AOUT_VAR_STEREO;
+        text.psz_string = N_("Stereo");
+        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
         msg_Dbg( p_aout, "device supports 2 channels" );
     }
 
@@ -384,11 +367,39 @@ static void Probe( aout_instance_t * p_aout )
                         p_aout->output.output.i_rate, VLC_TRUE )
         == VLC_SUCCESS )
     {
-        val.psz_string = N_("Mono");
-        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );        
+        val.i_int = AOUT_VAR_MONO;
+        text.psz_string = N_("Mono");
+        var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
         msg_Dbg( p_aout, "device supports 1 channel" );
     }
 
+    /* Test for SPDIF support */
+    if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) )
+    {
+        if( OpenWaveOut( p_aout, VLC_FOURCC('s','p','d','i'),
+                         p_aout->output.output.i_physical_channels,
+                         aout_FormatNbChannels( &p_aout->output.output ),
+                         p_aout->output.output.i_rate, VLC_TRUE )
+            == VLC_SUCCESS )
+        {
+            msg_Dbg( p_aout, "device supports A/52 over S/PDIF" );
+            val.i_int = AOUT_VAR_SPDIF;
+            text.psz_string = N_("A/52 over S/PDIF");
+            var_Change( p_aout, "audio-device",
+                        VLC_VAR_ADDCHOICE, &val, &text );
+            if( config_GetInt( p_aout, "spdif" ) )
+                var_Set( p_aout, "audio-device", val );
+        }
+    }
+
+    var_Change( p_aout, "audio-device", VLC_VAR_CHOICESCOUNT, &val, NULL );
+    if( val.i_int <= 0 )
+    {
+        /* Probe() has failed. */
+        var_Destroy( p_aout, "audio-device" );
+        return;
+    }
+
     var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
 
     val.b_bool = VLC_TRUE;
@@ -472,11 +483,13 @@ static int OpenWaveOut( aout_instance_t *p_aout, int i_format,
     {
     case VLC_FOURCC('s','p','d','i'):
         i_nb_channels = 2;
+        /* To prevent channel re-ordering */
+        waveformat.dwChannelMask = SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT;
         waveformat.Format.wBitsPerSample = 16;
         waveformat.Samples.wValidBitsPerSample =
             waveformat.Format.wBitsPerSample;
         waveformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
-        waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF;
+        waveformat.SubFormat = __KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF;
         break;
 
     case VLC_FOURCC('f','l','3','2'):
@@ -484,7 +497,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, int i_format,
         waveformat.Samples.wValidBitsPerSample =
             waveformat.Format.wBitsPerSample;
         waveformat.Format.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
-        waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
+        waveformat.SubFormat = __KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
         break;
 
     case VLC_FOURCC('s','1','6','l'):
@@ -492,7 +505,7 @@ static int OpenWaveOut( aout_instance_t *p_aout, int i_format,
         waveformat.Samples.wValidBitsPerSample =
             waveformat.Format.wBitsPerSample;
         waveformat.Format.wFormatTag = WAVE_FORMAT_PCM;
-        waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+        waveformat.SubFormat = __KSDATAFORMAT_SUBTYPE_PCM;
         break;
     }