]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/waveout.c
* modules/*: sanitization of the modules description strings.
[vlc] / modules / audio_output / waveout.c
index b70673716b96bfadc1d1f58e0ff653de0447b823..2e241b20f9001ce6e6541661470eac9496268251 100644 (file)
@@ -2,7 +2,7 @@
  * waveout.c : Windows waveOut plugin for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: waveout.c,v 1.15 2003/02/14 09:50:12 gbazin Exp $
+ * $Id: waveout.c,v 1.21 2003/03/30 18:14:36 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *      
@@ -93,14 +93,14 @@ 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 );
+#ifndef KKSDATAFORMAT_SUBTYPE_IEEE_FLOAT
+DEFINE_GUID( KKSDATAFORMAT_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 );
+#ifndef KKSDATAFORMAT_SUBTYPE_PCM
+DEFINE_GUID( KKSDATAFORMAT_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 );
+#ifndef KKSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF
+DEFINE_GUID( KKSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF, WAVE_FORMAT_DOLBY_AC3_SPDIF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
 #endif
 
 /*****************************************************************************
@@ -127,7 +127,7 @@ static void InterleaveS16( int16_t *, int *, int );
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_description( _("Win32 waveOut extension module") );
+    set_description( _("Win32 waveOut extension output") );
     set_capability( "audio output", 50 );
     set_callbacks( Open, Close );
 vlc_module_end();
@@ -315,21 +315,6 @@ static void Probe( aout_instance_t * p_aout )
 
     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 );
-        }
-    }
-
     /* Test for 5.1 support */
     i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
                           AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
@@ -343,15 +328,15 @@ static void Probe( aout_instance_t * p_aout )
         {
             val.psz_string = N_("5.1");
             var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
-        }
-        else
             msg_Dbg( p_aout, "device supports 5.1 channels" );
+        }
     }
 
     /* Test for 2 Front 2 Rear support */
     i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
                           AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
-    if( p_aout->output.output.i_physical_channels & i_physical_channels )
+    if( ( p_aout->output.output.i_physical_channels & i_physical_channels )
+        == i_physical_channels )
     {
         if( OpenWaveOutPCM( p_aout, &i_format,
                             i_physical_channels, 4,
@@ -360,9 +345,8 @@ static void Probe( aout_instance_t * p_aout )
         {
             val.psz_string = N_("2 Front 2 Rear");
             var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
-        }
-        else
             msg_Dbg( p_aout, "device supports 4 channels" );
+        }
     }
 
     /* Test for stereo support */
@@ -375,9 +359,8 @@ static void Probe( aout_instance_t * p_aout )
         val.psz_string = N_("Stereo");
         var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
         var_Set( p_aout, "audio-device", val );
-    }
-    else
         msg_Dbg( p_aout, "device supports 2 channels" );
+    }
 
     /* Test for mono support */
     i_physical_channels = AOUT_CHAN_CENTER;
@@ -388,9 +371,25 @@ static void Probe( aout_instance_t * p_aout )
     {
         val.psz_string = N_("Mono");
         var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );        
-    }
-    else
         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.psz_string = N_("A/52 over S/PDIF");
+            var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
+            if( config_GetInt( p_aout, "spdif" ) )
+                var_Set( p_aout, "audio-device", val );
+        }
+    }
 
     var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
 
@@ -475,11 +474,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 = KKSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF;
         break;
 
     case VLC_FOURCC('f','l','3','2'):
@@ -487,7 +488,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 = KKSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
         break;
 
     case VLC_FOURCC('s','1','6','l'):
@@ -495,7 +496,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 = KKSDATAFORMAT_SUBTYPE_PCM;
         break;
     }
 
@@ -746,6 +747,9 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
     }
 }
 
+/*****************************************************************************
+ * InterleaveFloat32/S16: change the channel order to the Microsoft one.
+ *****************************************************************************/
 static void InterleaveFloat32( float *p_buf, int *pi_chan_table,
                                int i_nb_channels )
 {