]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/waveout.c
Remove unused parameter
[vlc] / modules / audio_output / waveout.c
index b7c7d1f155199e58f6be0da97d699fa15a5b1995..049b76ab58be74a86e4608b75acf70a586531f44 100644 (file)
@@ -29,7 +29,8 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_aout.h>
 #include <vlc_charset.h>
 
@@ -122,14 +123,14 @@ typedef struct notification_thread_t
 /* local functions */
 static void Probe        ( aout_instance_t * );
 static int OpenWaveOut   ( aout_instance_t *, uint32_t,
-                           int, int, int, int, vlc_bool_t );
+                           int, int, int, int, bool );
 static int OpenWaveOutPCM( aout_instance_t *, uint32_t,
-                           int*, int, int, int, vlc_bool_t );
+                           int*, int, int, int, bool );
 static int PlayWaveOut   ( aout_instance_t *, HWAVEOUT, WAVEHDR *,
-                           aout_buffer_t *, vlc_bool_t );
+                           aout_buffer_t *, bool );
 
 static void CALLBACK WaveOutCallback ( HWAVEOUT, UINT, DWORD, DWORD, DWORD );
-static void WaveOutThread( notification_thread_t * );
+static void* WaveOutThread( vlc_object_t * );
 
 static int VolumeInfos( aout_instance_t *, audio_volume_t * );
 static int VolumeGet( aout_instance_t *, audio_volume_t * );
@@ -143,8 +144,8 @@ static uint32_t findDeviceID(char *);
 
 static const char psz_device_name_fmt[] = "%s ($%x,$%x)";
 
-static const char *ppsz_adev[] = { "wavemapper", };
-static const char *ppsz_adev_text[] = { N_("Microsoft Soundmapper") };
+static const char *const ppsz_adev[] = { "wavemapper", };
+static const char *const ppsz_adev_text[] = { N_("Microsoft Soundmapper") };
 
 
 
@@ -161,23 +162,24 @@ static const char *ppsz_adev_text[] = { N_("Microsoft Soundmapper") };
                        "to apply.")
 #define DEFAULT_AUDIO_DEVICE N_("Default Audio Device")
 
-vlc_module_begin();
-    set_shortname( "WaveOut" );
-    set_description( _("Win32 waveOut extension output") );
-    set_capability( "audio output", 50 );
-    set_category( CAT_AUDIO );
-    set_subcategory( SUBCAT_AUDIO_AOUT );
-    add_bool( "waveout-float32", 1, 0, FLOAT_TEXT, FLOAT_LONGTEXT, VLC_TRUE );
-
-    add_string( "waveout-dev", "wavemapper", NULL,
-                 DEVICE_TEXT, DEVICE_LONG, VLC_FALSE );
+vlc_module_begin ()
+    set_shortname( "WaveOut" )
+    set_description( N_("Win32 waveOut extension output") )
+    set_capability( "audio output", 50 )
+    set_category( CAT_AUDIO )
+    set_subcategory( SUBCAT_AUDIO_AOUT )
+    add_bool( "waveout-float32", 1, 0, FLOAT_TEXT, FLOAT_LONGTEXT, true )
+
+    add_string( "waveout-audio-device", "wavemapper", NULL,
+                 DEVICE_TEXT, DEVICE_LONG, false );
+       add_deprecated_alias( "waveout-dev" )   /* deprecated since 0.9.3 */
        change_string_list( ppsz_adev, ppsz_adev_text, ReloadWaveoutDevices );
-       change_need_restart();
-       change_action_add( ReloadWaveoutDevices, N_("Refresh list") );
+       change_need_restart ()
+       change_action_add( ReloadWaveoutDevices, N_("Refresh list") )
 
 
-    set_callbacks( Open, Close );
-vlc_module_end();
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 /*****************************************************************************
  * aout_sys_t: waveOut audio output method descriptor
@@ -207,26 +209,27 @@ struct aout_sys_t
 
     int i_buffer_size;
 
-    byte_t *p_silence_buffer;               /* buffer we use to play silence */
+    uint8_t *p_silence_buffer;              /* buffer we use to play silence */
 
-    vlc_bool_t b_chan_reorder;              /* do we need channel reordering */
+    bool b_chan_reorder;              /* do we need channel reordering */
     int pi_chan_table[AOUT_CHAN_MAX];
 };
 
 static const uint32_t pi_channels_src[] =
     { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
       AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
-      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
+      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, AOUT_CHAN_REARCENTER,
       AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 };
 static const uint32_t pi_channels_in[] =
     { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT,
       SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT,
-      SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
+      SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT, SPEAKER_BACK_CENTER,
       SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY, 0 };
 static const uint32_t pi_channels_out[] =
     { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT,
       SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY,
       SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
+      SPEAKER_BACK_CENTER,
       SPEAKER_SIDE_LEFT, SPEAKER_SIDE_RIGHT, 0 };
 
 /*****************************************************************************
@@ -244,25 +247,22 @@ static int Open( vlc_object_t *p_this )
     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_EGENERIC;
-    }
+        return VLC_ENOMEM;
 
     p_aout->output.pf_play = Play;
-    p_aout->b_die = VLC_FALSE;
+    p_aout->b_die = false;
 
 
     /*
      initialize/update Device selection List
     */
-    ReloadWaveoutDevices( p_this, "waveout-dev", val, val, NULL);
+    ReloadWaveoutDevices( p_this, "waveout-audio-device", val, val, NULL);
 
 
     /*
       check for configured audio device!
     */
-    char *psz_waveout_dev = var_CreateGetString( p_aout, "waveout-dev");
+    char *psz_waveout_dev = var_CreateGetString( p_aout, "waveout-audio-device");
 
     p_aout->output.p_sys->i_wave_device_id =
          findDeviceID( psz_waveout_dev );
@@ -304,7 +304,7 @@ static int Open( vlc_object_t *p_this )
     if( var_Get( p_aout, "audio-device", &val ) < 0 )
     {
         /* Probe() has failed. */
-        var_Destroy( p_aout, "waveout-device");
+        var_Destroy( p_aout, "waveout-audio-device");
         free( p_aout->output.p_sys );
         return VLC_EGENERIC;
     }
@@ -320,7 +320,7 @@ static int Open( vlc_object_t *p_this )
                          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_FALSE )
+                         p_aout->output.output.i_rate, false )
             != VLC_SUCCESS )
         {
             msg_Err( p_aout, "cannot open waveout audio device" );
@@ -369,7 +369,7 @@ static int Open( vlc_object_t *p_this )
                             &p_aout->output.output.i_format,
                             p_aout->output.output.i_physical_channels,
                             aout_FormatNbChannels( &p_aout->output.output ),
-                            p_aout->output.output.i_rate, VLC_FALSE )
+                            p_aout->output.output.i_rate, false )
             != VLC_SUCCESS )
         {
             msg_Err( p_aout, "cannot open waveout audio device" );
@@ -410,7 +410,6 @@ static int Open( vlc_object_t *p_this )
     if( p_aout->output.p_sys->p_silence_buffer == NULL )
     {
         free( p_aout->output.p_sys );
-        msg_Err( p_aout, "out of memory" );
         return 1;
     }
     p_aout->output.p_sys->i_repeat_counter = 0;
@@ -436,7 +435,7 @@ static int Open( vlc_object_t *p_this )
     /* Then launch the notification thread */
     if( vlc_thread_create( p_aout->output.p_sys->p_notif,
                            "waveOut Notification Thread", WaveOutThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
+                           VLC_THREAD_PRIORITY_OUTPUT ) )
     {
         msg_Err( p_aout, "cannot create WaveOutThread" );
     }
@@ -475,7 +474,7 @@ static void Probe( aout_instance_t * p_aout )
                             p_aout->output.p_sys->i_wave_device_id,
                             &i_format,
                             i_physical_channels, 6,
-                            p_aout->output.output.i_rate, VLC_TRUE )
+                            p_aout->output.output.i_rate, true )
             == VLC_SUCCESS )
         {
             val.i_int = AOUT_VAR_5_1;
@@ -496,7 +495,7 @@ static void Probe( aout_instance_t * p_aout )
                             p_aout->output.p_sys->i_wave_device_id,
                             &i_format,
                             i_physical_channels, 4,
-                            p_aout->output.output.i_rate, VLC_TRUE )
+                            p_aout->output.output.i_rate, true )
             == VLC_SUCCESS )
         {
             val.i_int = AOUT_VAR_2F2R;
@@ -513,7 +512,7 @@ static void Probe( aout_instance_t * p_aout )
                         p_aout->output.p_sys->i_wave_device_id,
                         &i_format,
                         i_physical_channels, 2,
-                        p_aout->output.output.i_rate, VLC_TRUE )
+                        p_aout->output.output.i_rate, true )
         == VLC_SUCCESS )
     {
         val.i_int = AOUT_VAR_STEREO;
@@ -528,7 +527,7 @@ static void Probe( aout_instance_t * p_aout )
                         p_aout->output.p_sys->i_wave_device_id,
                         &i_format,
                         i_physical_channels, 1,
-                        p_aout->output.output.i_rate, VLC_TRUE )
+                        p_aout->output.output.i_rate, true )
         == VLC_SUCCESS )
     {
         val.i_int = AOUT_VAR_MONO;
@@ -545,7 +544,7 @@ static void Probe( aout_instance_t * 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 )
+                         p_aout->output.output.i_rate, true )
             == VLC_SUCCESS )
         {
             msg_Dbg( p_aout, "device supports A/52 over S/PDIF" );
@@ -568,7 +567,7 @@ static void Probe( aout_instance_t * p_aout )
 
     var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
 
-    val.b_bool = VLC_TRUE;
+    val.b_bool = true;
     var_Set( p_aout, "intf-change", val );
 }
 
@@ -679,7 +678,7 @@ static void Close( vlc_object_t *p_this )
  ****************************************************************************/
 static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_format,
                         int i_channels, int i_nb_channels, int i_rate,
-                        vlc_bool_t b_probe )
+                        bool b_probe )
 {
     MMRESULT result;
     unsigned int i;
@@ -810,9 +809,9 @@ static int OpenWaveOut( aout_instance_t *p_aout, uint32_t i_device_id, int i_for
  ****************************************************************************/
 static int OpenWaveOutPCM( aout_instance_t *p_aout, uint32_t i_device_id, int *i_format,
                            int i_channels, int i_nb_channels, int i_rate,
-                           vlc_bool_t b_probe )
+                           bool b_probe )
 {
-    vlc_bool_t b_use_float32 = var_CreateGetBool( p_aout, "waveout-float32");
+    bool b_use_float32 = var_CreateGetBool( p_aout, "waveout-float32");
 
     if( !b_use_float32 || OpenWaveOut( p_aout, i_device_id, VLC_FOURCC('f','l','3','2'),
                                    i_channels, i_nb_channels, i_rate, b_probe )
@@ -842,7 +841,7 @@ static int OpenWaveOutPCM( aout_instance_t *p_aout, uint32_t i_device_id, int *i
  *****************************************************************************/
 static int PlayWaveOut( aout_instance_t *p_aout, HWAVEOUT h_waveout,
                         WAVEHDR *p_waveheader, aout_buffer_t *p_buffer,
-                        vlc_bool_t b_spdif)
+                        bool b_spdif)
 {
     MMRESULT result;
 
@@ -858,9 +857,9 @@ static int PlayWaveOut( aout_instance_t *p_aout, HWAVEOUT h_waveout,
         */
         if(b_spdif)
         {
-           p_aout->p_libvlc->pf_memcpy( p_aout->output.p_sys->p_silence_buffer,
-                                     p_buffer->p_buffer,
-                                     p_aout->output.p_sys->i_buffer_size );
+           vlc_memcpy( p_aout->output.p_sys->p_silence_buffer,
+                       p_buffer->p_buffer,
+                       p_aout->output.p_sys->i_buffer_size );
            p_aout->output.p_sys->i_repeat_counter = 2;
         }
     } else {
@@ -870,10 +869,8 @@ static int PlayWaveOut( aout_instance_t *p_aout, HWAVEOUT h_waveout,
            p_aout->output.p_sys->i_repeat_counter--;
            if(!p_aout->output.p_sys->i_repeat_counter)
            {
-               p_aout->p_libvlc->pf_memset( p_aout->output.p_sys->p_silence_buffer,
-                                            0x00,
-                                            p_aout->output.p_sys->i_buffer_size
-                                          );
+               vlc_memset( p_aout->output.p_sys->p_silence_buffer,
+                           0x00, p_aout->output.p_sys->i_buffer_size );
            }
         }
         p_waveheader->lpData = p_aout->output.p_sys->p_silence_buffer;
@@ -908,12 +905,13 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
                                       DWORD _p_aout,
                                       DWORD dwParam1, DWORD dwParam2 )
 {
+    (void)h_waveout;    (void)dwParam1;    (void)dwParam2;
     aout_instance_t *p_aout = (aout_instance_t *)_p_aout;
     int i, i_queued_frames = 0;
 
     if( uMsg != WOM_DONE ) return;
 
-    if( p_aout->b_die ) return;
+    if( !vlc_object_alive (p_aout) ) return;
 
     /* Find out the current latency */
     for( i = 0; i < FRAMES_NUM; i++ )
@@ -974,27 +972,29 @@ static int WaveOutClearDoneBuffers(aout_sys_t *p_sys)
  * we are not authorized to use waveOutWrite() directly in the waveout
  * callback.
  *****************************************************************************/
-static void WaveOutThread( notification_thread_t *p_notif )
+static void* WaveOutThread( vlc_object_t *p_this )
 {
+    notification_thread_t *p_notif = (notification_thread_t*)p_this;
     aout_instance_t *p_aout = p_notif->p_aout;
     aout_sys_t *p_sys = p_aout->output.p_sys;
     aout_buffer_t *p_buffer = NULL;
     WAVEHDR *p_waveheader = p_sys->waveheader;
     int i, i_queued_frames;
-    vlc_bool_t b_sleek;
+    bool b_sleek;
     mtime_t next_date;
     uint32_t i_buffer_length = 64;
+    int canc = vlc_savecancel ();
 
     /* We don't want any resampling when using S/PDIF */
     b_sleek = p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i');
 
     // wait for first call to "play()"
-    while( !p_sys->start_date && !p_aout->b_die )
+    while( !p_sys->start_date && vlc_object_alive (p_aout) )
            WaitForSingleObject( p_sys->event, INFINITE );
-    if( p_aout->b_die )
-        return;
+    if( !vlc_object_alive (p_aout) )
+        return NULL;
 
-    msg_Dbg( p_aout, "will start to play in "I64Fd" us",
+    msg_Dbg( p_aout, "will start to play in %"PRId64" us",
              (p_sys->start_date - AOUT_PTS_TOLERANCE/4)-mdate());
 
     // than wait a short time... before grabbing first frames
@@ -1008,12 +1008,12 @@ static void WaveOutThread( notification_thread_t *p_notif )
                            p_aout->output.b_starving, msg);
     next_date = mdate();
 
-    while( !p_aout->b_die )
+    while( vlc_object_alive (p_aout) )
     {
         /* Cleanup and find out the current latency */
         i_queued_frames = WaveOutClearDoneBuffers( p_sys );
 
-        if( p_aout->b_die ) return;
+        if( !vlc_object_alive (p_aout) ) return NULL;
 
         /* Try to fill in as many frame buffers as possible */
         for( i = 0; i < FRAMES_NUM; i++ )
@@ -1089,7 +1089,7 @@ static void WaveOutThread( notification_thread_t *p_notif )
             }
         }
 
-        if( p_aout->b_die ) return;
+        if( !vlc_object_alive (p_aout) ) return NULL;
 
         /*
           deal with the case that the loop didn't fillup the buffer to the
@@ -1110,6 +1110,8 @@ static void WaveOutThread( notification_thread_t *p_notif )
     }
 
 #undef waveout_warn
+    vlc_restorecancel (canc);
+    return NULL;
 }
 
 static int VolumeInfos( aout_instance_t * p_aout, audio_volume_t * pi_soft )
@@ -1208,7 +1210,7 @@ static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
     p_item->ppsz_list_text[j] = NULL;
 
     /* Signal change to the interface */
-    p_item->b_dirty = VLC_TRUE;
+    p_item->b_dirty = true;
 
     return VLC_SUCCESS;
 }