+ * Probe: probe the audio device for available formats and channels
+ *****************************************************************************/
+static void Probe( aout_instance_t * p_aout )
+{
+ vlc_value_t val, text;
+ int i_format;
+ unsigned int i_physical_channels;
+ DWORD ui_speaker_config;
+
+ 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 |
+ AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
+ AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE;
+ if( p_aout->output.output.i_physical_channels == i_physical_channels )
+ {
+ if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 6,
+ p_aout->output.output.i_rate, VLC_TRUE )
+ == VLC_SUCCESS )
+ {
+ val.i_int = AOUT_VAR_5_1;
+ text.psz_string = "5.1";
+ var_Change( p_aout, "audio-device",
+ VLC_VAR_ADDCHOICE, &val, &text );
+ msg_Dbg( p_aout, "device supports 5.1 channels" );
+ }
+ }
+
+ /* Test for 3 Front 2 Rear support */
+ i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
+ AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
+ AOUT_CHAN_REARRIGHT;
+ if( p_aout->output.output.i_physical_channels == i_physical_channels )
+ {
+ if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 5,
+ p_aout->output.output.i_rate, VLC_TRUE )
+ == VLC_SUCCESS )
+ {
+ val.i_int = AOUT_VAR_3F2R;
+ text.psz_string = N_("3 Front 2 Rear");
+ var_Change( p_aout, "audio-device",
+ VLC_VAR_ADDCHOICE, &val, &text );
+ msg_Dbg( p_aout, "device supports 5 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 )
+ == i_physical_channels )
+ {
+ if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 4,
+ p_aout->output.output.i_rate, VLC_TRUE )
+ == VLC_SUCCESS )
+ {
+ 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" );
+ }
+ }
+
+ /* Test for stereo support */
+ i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
+ if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 2,
+ p_aout->output.output.i_rate, VLC_TRUE )
+ == VLC_SUCCESS )
+ {
+ val.i_int = AOUT_VAR_STEREO;
+ text.psz_string = N_("Stereo");
+ var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val, &text );
+ var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+ msg_Dbg( p_aout, "device supports 2 channels" );
+ }
+
+ /* Test for mono support */
+ i_physical_channels = AOUT_CHAN_CENTER;
+ if( CreateDSBufferPCM( p_aout, &i_format, i_physical_channels, 1,
+ p_aout->output.output.i_rate, VLC_TRUE )
+ == VLC_SUCCESS )
+ {
+ 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" );
+ }
+
+ /* Check the speaker configuration to determine which channel config should
+ * be the default */
+ if FAILED( IDirectSound_GetSpeakerConfig( p_aout->output.p_sys->p_dsobject,
+ &ui_speaker_config ) )
+ {
+ ui_speaker_config = DSSPEAKER_STEREO;
+ }
+ switch( DSSPEAKER_CONFIG(ui_speaker_config) )
+ {
+ case DSSPEAKER_5POINT1:
+ val.i_int = AOUT_VAR_5_1;
+ break;
+ case DSSPEAKER_QUAD:
+ val.i_int = AOUT_VAR_2F2R;
+ break;
+#if 0 /* Lots of people just get their settings wrong and complain that
+ * this is a problem with VLC so just don't ever set mono by default. */
+ case DSSPEAKER_MONO:
+ val.i_int = AOUT_VAR_MONO;
+ break;
+#endif
+ case DSSPEAKER_SURROUND:
+ case DSSPEAKER_STEREO:
+ default:
+ val.i_int = AOUT_VAR_STEREO;
+ break;
+ }
+ var_Set( p_aout, "audio-device", val );
+
+ /* Test for SPDIF support */
+ if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) )
+ {
+ if( CreateDSBuffer( 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,
+ AOUT_SPDIF_SIZE, 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;
+ var_Set( p_aout, "intf-change", val );
+}
+
+/*****************************************************************************
+ * Play: we'll start playing the directsound buffer here because at least here
+ * we know the first buffer has been put in the aout fifo and we also
+ * know its date.