]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/directx.c
macosx: Fix crashlog opening.
[vlc] / modules / audio_output / directx.c
index 2dd86f97319790bb2953ac46445d4fb60fe02e25..6c7228e7dc1ae657d98e1b8c5bdac2532146a685 100644 (file)
@@ -30,7 +30,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
 
@@ -226,7 +226,7 @@ static int  FillBuffer        ( aout_instance_t *, int, aout_buffer_t * );
     "audio output mode (which is not well supported by some soundcards)." )
 
 vlc_module_begin();
-    set_description( _("DirectX audio output") );
+    set_description( N_("DirectX audio output") );
     set_shortname( "DirectX" );
     set_capability( "audio output", 100 );
     set_category( CAT_AUDIO );
@@ -254,10 +254,7 @@ static int OpenAudio( vlc_object_t *p_this )
    /* Allocate structure */
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
 
     /* Initialize some variables */
     p_aout->output.p_sys->p_dsobject = NULL;
@@ -418,6 +415,7 @@ static void Probe( aout_instance_t * p_aout )
     int i_format;
     unsigned int i_physical_channels;
     DWORD ui_speaker_config;
+    bool is_default_output_set = false;
 
     var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE );
     text.psz_string = _("Audio Device");
@@ -437,6 +435,8 @@ static void Probe( aout_instance_t * p_aout )
             text.psz_string = "5.1";
             var_Change( p_aout, "audio-device",
                         VLC_VAR_ADDCHOICE, &val, &text );
+            var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+            is_default_output_set = true;
             msg_Dbg( p_aout, "device supports 5.1 channels" );
         }
     }
@@ -456,6 +456,8 @@ static void Probe( aout_instance_t * p_aout )
                text.psz_string = "7.1";
                var_Change( p_aout, "audio-device",
                            VLC_VAR_ADDCHOICE, &val, &text );
+               var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+               is_default_output_set = true;
                msg_Dbg( p_aout, "device supports 7.1 channels" );
            }
        }
@@ -474,6 +476,11 @@ static void Probe( aout_instance_t * p_aout )
             text.psz_string = N_("3 Front 2 Rear");
             var_Change( p_aout, "audio-device",
                         VLC_VAR_ADDCHOICE, &val, &text );
+            if(!is_default_output_set)
+            {
+                var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+                is_default_output_set = true;
+            }
             msg_Dbg( p_aout, "device supports 5 channels" );
         }
     }
@@ -492,6 +499,11 @@ static void Probe( aout_instance_t * p_aout )
             text.psz_string = N_("2 Front 2 Rear");
             var_Change( p_aout, "audio-device",
                         VLC_VAR_ADDCHOICE, &val, &text );
+            if(!is_default_output_set)
+            {
+                var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+                is_default_output_set = true;
+            }
             msg_Dbg( p_aout, "device supports 4 channels" );
         }
     }
@@ -505,7 +517,12 @@ static void Probe( aout_instance_t * p_aout )
         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 );
+        if(!is_default_output_set)
+        {
+            var_Change( p_aout, "audio-device", VLC_VAR_SETDEFAULT, &val, NULL );
+            is_default_output_set = true;
+            msg_Dbg( p_aout, "device supports 2 channels (DEFAULT!)" );
+        }
         msg_Dbg( p_aout, "device supports 2 channels" );
     }
 
@@ -527,16 +544,20 @@ static void Probe( aout_instance_t * p_aout )
                                               &ui_speaker_config ) )
     {
         ui_speaker_config = DSSPEAKER_STEREO;
+        msg_Dbg( p_aout, "GetSpeakerConfig failed" );
     }
     switch( DSSPEAKER_CONFIG(ui_speaker_config) )
     {
     case DSSPEAKER_7POINT1:
+        msg_Dbg( p_aout, "Windows says your SpeakerConfig is 7.1" );
         val.i_int = AOUT_VAR_7_1;
         break;
     case DSSPEAKER_5POINT1:
+        msg_Dbg( p_aout, "Windows says your SpeakerConfig is 5.1" );
         val.i_int = AOUT_VAR_5_1;
         break;
     case DSSPEAKER_QUAD:
+        msg_Dbg( p_aout, "Windows says your SpeakerConfig is Quad" );
         val.i_int = AOUT_VAR_2F2R;
         break;
 #if 0 /* Lots of people just get their settings wrong and complain that
@@ -546,8 +567,11 @@ static void Probe( aout_instance_t * p_aout )
         break;
 #endif
     case DSSPEAKER_SURROUND:
+        msg_Dbg( p_aout, "Windows says your SpeakerConfig is surround" );
     case DSSPEAKER_STEREO:
+        msg_Dbg( p_aout, "Windows says your SpeakerConfig is stereo" );
     default:
+        /* If nothing else is found, choose stereo output */
         val.i_int = AOUT_VAR_STEREO;
         break;
     }
@@ -1040,7 +1064,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
     /* Wait here until Play() is called */
     WaitForSingleObject( p_notif->event, INFINITE );
 
-    if( !p_notif->b_die )
+    if( vlc_object_alive (p_notif) )
     {
         mwait( p_notif->start_date - AOUT_PTS_TOLERANCE / 2 );
 
@@ -1065,7 +1089,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
     }
     last_time = mdate();
 
-    while( !p_notif->b_die )
+    while( vlc_object_alive (p_notif) )
     {
         long l_read, l_free_slots;
         mtime_t mtime = mdate();