]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/directx.c
Untested attempt to DirectAudio support for 7.1 system
[vlc] / modules / audio_output / directx.c
index 292817bf38e35d85d804caf3daca8185244c9400..2dd86f97319790bb2953ac46445d4fb60fe02e25 100644 (file)
@@ -31,6 +31,7 @@
 #endif
 
 #include <vlc/vlc.h>
+#include <vlc_plugin.h>
 #include <vlc_aout.h>
 
 #include <windows.h>
@@ -84,6 +85,9 @@
 #   define SPEAKER_RESERVED               0x80000000
 #endif
 
+#ifndef DSSPEAKER_DSSPEAKER_DIRECTOUT
+#   define DSSPEAKER_DSSPEAKER_DIRECTOUT         0x00000000
+#endif
 #ifndef DSSPEAKER_HEADPHONE
 #   define DSSPEAKER_HEADPHONE         0x00000001
 #endif
 #ifndef DSSPEAKER_5POINT1
 #   define DSSPEAKER_5POINT1           0x00000006
 #endif
+#ifndef DSSPEAKER_7POINT1
+#   define DSSPEAKER_7POINT1           0x00000007
+#endif
+#ifndef DSSPEAKER_7POINT1_SURROUND
+#   define DSSPEAKER_7POINT1_SURROUND           0x00000008
+#endif
+#ifndef DSSPEAKER_7POINT1_WIDE
+#   define DSSPEAKER_7POINT1_WIDE           DSSPEAKER_7POINT1
+#endif
 
 #ifndef _WAVEFORMATEXTENSIBLE_
 typedef struct {
@@ -317,6 +330,14 @@ static int OpenAudio( vlc_object_t *p_this )
                    | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
                    | AOUT_CHAN_LFE;
         }
+        else if( val.i_int == AOUT_VAR_7_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_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT
+                           | AOUT_CHAN_LFE;
+        }
         else if( val.i_int == AOUT_VAR_3F2R )
         {
             p_aout->output.output.i_physical_channels
@@ -420,6 +441,25 @@ static void Probe( aout_instance_t * p_aout )
         }
     }
 
+    /* Test for 7.1 support */
+    i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
+                             AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
+                             AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT |
+                             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, 8,
+                                  p_aout->output.output.i_rate, true )
+               == VLC_SUCCESS )
+           {
+               val.i_int = AOUT_VAR_7_1;
+               text.psz_string = "7.1";
+               var_Change( p_aout, "audio-device",
+                           VLC_VAR_ADDCHOICE, &val, &text );
+               msg_Dbg( p_aout, "device supports 7.1 channels" );
+           }
+       }
+
     /* Test for 3 Front 2 Rear support */
     i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
                           AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
@@ -490,6 +530,9 @@ static void Probe( aout_instance_t * p_aout )
     }
     switch( DSSPEAKER_CONFIG(ui_speaker_config) )
     {
+    case DSSPEAKER_7POINT1:
+        val.i_int = AOUT_VAR_7_1;
+        break;
     case DSSPEAKER_5POINT1:
         val.i_int = AOUT_VAR_5_1;
         break;
@@ -960,8 +1003,7 @@ static int FillBuffer( aout_instance_t *p_aout, int i_frame,
                                  p_sys->i_bits_per_sample );
         }
 
-        p_aout->p_libvlc->pf_memcpy( p_write_position, p_buffer->p_buffer,
-                                  l_bytes1 );
+        vlc_memcpy( p_write_position, p_buffer->p_buffer, l_bytes1 );
         aout_BufferFree( p_buffer );
     }
 
@@ -1043,7 +1085,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
 
         /* Detect underruns */
         if( l_queued && mtime - last_time >
-            I64C(1000000) * l_queued / p_aout->output.output.i_rate )
+            INT64_C(1000000) * l_queued / p_aout->output.output.i_rate )
         {
             msg_Dbg( p_aout, "detected underrun!" );
         }
@@ -1058,7 +1100,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
         for( i = 0; i < l_free_slots; i++ )
         {
             aout_buffer_t *p_buffer = aout_OutputNextBuffer( p_aout,
-                mtime + I64C(1000000) * (i * FRAME_SIZE + l_queued) /
+                mtime + INT64_C(1000000) * (i * FRAME_SIZE + l_queued) /
                 p_aout->output.output.i_rate, b_sleek );
 
             /* If there is no audio data available and we have some buffered
@@ -1071,7 +1113,7 @@ static void DirectSoundThread( notification_thread_t *p_notif )
 
         /* Sleep a reasonable amount of time */
         l_queued += (i * FRAME_SIZE);
-        msleep( I64C(1000000) * l_queued / p_aout->output.output.i_rate / 2 );
+        msleep( INT64_C(1000000) * l_queued / p_aout->output.output.i_rate / 2 );
     }
 
     /* make sure the buffer isn't playing */