]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/waveout.c
Remove WinCE
[vlc] / modules / audio_output / waveout.c
index e0cee676de1e416d12516d0c9f3fd6edcdcba2d6..7c7b545878215f361afe675d3cb577b5ee64d279 100644 (file)
@@ -51,7 +51,7 @@
  *****************************************************************************/
 static int  Open         ( vlc_object_t * );
 static void Close        ( vlc_object_t * );
-static void Play         ( audio_output_t *, block_t * );
+static void Play         ( audio_output_t *, block_t *, mtime_t * );
 
 /*****************************************************************************
  * notification_thread_t: waveOut event thread
@@ -73,42 +73,12 @@ static int MuteSet( audio_output_t *, bool );
 
 static int WaveOutClearDoneBuffers(aout_sys_t *p_sys);
 
-static int ReloadWaveoutDevices( vlc_object_t *, char const *,
-                                vlc_value_t, vlc_value_t, void * );
+static int ReloadWaveoutDevices( vlc_object_t *, const char *,
+                                 char ***, char *** );
 static uint32_t findDeviceID(char *);
 
 static const wchar_t device_name_fmt[] = L"%ls ($%x,$%x)";
 
-static const char *const ppsz_adev[] = { "wavemapper", };
-static const char *const ppsz_adev_text[] = { N_("Microsoft Soundmapper") };
-
-
-/*****************************************************************************
- * Module descriptor
- *****************************************************************************/
-#define DEVICE_TEXT N_("Select Audio Device")
-#define DEVICE_LONG N_("Select special Audio device, or let windows "\
-                       "decide (default), change needs VLC restart "\
-                       "to apply.")
-#define DEFAULT_AUDIO_DEVICE N_("Default Audio Device")
-
-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_string( "waveout-audio-device", "wavemapper",
-                 DEVICE_TEXT, DEVICE_LONG, false )
-       change_string_list( ppsz_adev, ppsz_adev_text, ReloadWaveoutDevices )
-       change_action_add( ReloadWaveoutDevices, N_("Refresh list") )
-
-    add_bool( "waveout-float32", true, FLOAT_TEXT, FLOAT_LONGTEXT, true )
-
-    set_callbacks( Open, Close )
-vlc_module_end ()
-
 /*****************************************************************************
  * aout_sys_t: waveOut audio output method descriptor
  *****************************************************************************
@@ -141,13 +111,47 @@ struct aout_sys_t
 
     uint8_t *p_silence_buffer;              /* buffer we use to play silence */
 
-    float volume;
-    bool mute;
+    union {
+        float volume;
+        float soft_gain;
+    };
+    union {
+        bool mute;
+        bool soft_mute;
+    };
 
     bool b_chan_reorder;              /* do we need channel reordering */
     int pi_chan_table[AOUT_CHAN_MAX];
 };
 
+#include "volume.h"
+
+/*****************************************************************************
+ * Module descriptor
+ *****************************************************************************/
+#define DEVICE_TEXT N_("Select Audio Device")
+#define DEVICE_LONG N_("Select special Audio device, or let windows "\
+                       "decide (default), change needs VLC restart "\
+                       "to apply.")
+#define DEFAULT_AUDIO_DEVICE N_("Default Audio Device")
+
+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_string( "waveout-audio-device", "wavemapper",
+                 DEVICE_TEXT, DEVICE_LONG, false )
+       change_string_cb( ReloadWaveoutDevices )
+    add_sw_gain( )
+
+    add_bool( "waveout-float32", true, FLOAT_TEXT, FLOAT_LONGTEXT, true )
+
+    set_callbacks( Open, Close )
+vlc_module_end ()
+
 /*****************************************************************************
  * Open: open the audio device
  *****************************************************************************
@@ -168,11 +172,6 @@ static int Open( vlc_object_t *p_this )
     p_aout->pf_pause = aout_PacketPause;
     p_aout->pf_flush = aout_PacketFlush;
 
-    /*
-     initialize/update Device selection List
-    */
-    ReloadWaveoutDevices( p_this, "waveout-audio-device", val, val, NULL);
-
     /*
       check for configured audio device!
     */
@@ -297,7 +296,6 @@ static int Open( vlc_object_t *p_this )
 
         aout_PacketInit( p_aout, &p_aout->sys->packet, FRAME_SIZE );
 
-#ifndef UNDER_CE
         /* Check for hardware volume support */
         if( waveOutGetDevCaps( (UINT_PTR)p_aout->sys->h_waveout,
                                &wocaps, sizeof(wocaps) ) == MMSYSERR_NOERROR
@@ -309,8 +307,7 @@ static int Open( vlc_object_t *p_this )
             p_aout->sys->mute = false;
         }
         else
-#endif
-            aout_VolumeSoftInit( p_aout );
+            aout_SoftVolumeInit( p_aout );
     }
 
     waveOutReset( p_aout->sys->h_waveout );
@@ -483,7 +480,8 @@ static void Probe( audio_output_t * p_aout )
  * This doesn't actually play the buffer. This just stores the buffer so it
  * can be played by the callback thread.
  *****************************************************************************/
-static void Play( audio_output_t *_p_aout, block_t *block )
+static void Play( audio_output_t *_p_aout, block_t *block,
+                  mtime_t *restrict drift )
 {
     if( !_p_aout->sys->b_playing )
     {
@@ -500,7 +498,7 @@ static void Play( audio_output_t *_p_aout, block_t *block )
         SetEvent( _p_aout->sys->new_buffer_event );
     }
 
-    aout_PacketPlay( _p_aout, block );
+    aout_PacketPlay( _p_aout, block, drift );
 }
 
 /*****************************************************************************
@@ -594,11 +592,9 @@ static int OpenWaveOut( audio_output_t *p_aout, uint32_t i_device_id, int i_form
 #define waveformat p_aout->sys->waveformat
 
     waveformat.dwChannelMask = 0;
-    for( unsigned i = 0; i < sizeof(pi_channels_src)/sizeof(uint32_t); i++ )
-    {
-        if( i_channels & pi_channels_src[i] )
+    for( unsigned i = 0; pi_vlc_chan_order_wg4[i]; i++ )
+        if( i_channels & pi_vlc_chan_order_wg4[i] )
             waveformat.dwChannelMask |= pi_channels_in[i];
-    }
 
     switch( i_format )
     {
@@ -836,7 +832,7 @@ static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
 
 
 /****************************************************************************
- * WaveOutClearDoneBuffers: Clear all done marked buffers, and free aout_bufer
+ * WaveOutClearDoneBuffers: Clear all done marked buffers, and free buffer
  ****************************************************************************
  * return value is the number of still playing buffers in the queue
  ****************************************************************************/
@@ -1002,7 +998,6 @@ static void* WaveOutThread( void *data )
     return NULL;
 }
 
-#ifndef UNDER_CE
 static int VolumeSet( audio_output_t *aout, float volume )
 {
     aout_sys_t *sys = aout->sys;
@@ -1032,45 +1027,25 @@ static int MuteSet( audio_output_t * p_aout, bool mute )
     waveOutSetVolume( hwo, vol | (vol << 16) );
     return 0;
 }
-#endif
 
 /*
   reload the configuration drop down list, of the Audio Devices
 */
 static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
-                                 vlc_value_t newval, vlc_value_t oldval, void *data )
+                                 char ***values, char ***descs )
 {
-    VLC_UNUSED( newval ); VLC_UNUSED( oldval ); VLC_UNUSED( data );
-
-    module_config_t *p_item = config_FindConfig( p_this, psz_name );
-    if( !p_item ) return VLC_SUCCESS;
-
-    /* Clear-up the current list */
-    if( p_item->i_list )
-    {
-        int i;
+    int n = 0, nb_devices = waveOutGetNumDevs();
 
-        /* Keep the first entry */
-        for( i = 1; i < p_item->i_list; i++ )
-        {
-            free((char *)(p_item->ppsz_list[i]) );
-            free((char *)(p_item->ppsz_list_text[i]) );
-        }
-        /* TODO: Remove when no more needed */
-        p_item->ppsz_list[i] = NULL;
-        p_item->ppsz_list_text[i] = NULL;
-    }
-    p_item->i_list = 1;
+    VLC_UNUSED( psz_name );
 
-    int wave_devices = waveOutGetNumDevs();
+    *values = xmalloc( (nb_devices + 1) * sizeof(char *) );
+    *descs = xmalloc( (nb_devices + 1) * sizeof(char *) );
 
-    p_item->ppsz_list = xrealloc( p_item->ppsz_list,
-                          (wave_devices+2) * sizeof(char *) );
-    p_item->ppsz_list_text = xrealloc( p_item->ppsz_list_text,
-                          (wave_devices+2) * sizeof(char *) );
+    (*values)[n] = strdup( "wavemapper" );
+    (*descs)[n] = strdup( _("Microsoft Soundmapper") );
+    n++;
 
-    int j=1;
-    for(int i=0; i<wave_devices; i++)
+    for(int i = 0; i < nb_devices; i++)
     {
         WAVEOUTCAPS caps;
         wchar_t dev_name[MAXPNAMELEN+32];
@@ -1080,16 +1055,13 @@ static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
             continue;
 
         _snwprintf(dev_name, MAXPNAMELEN + 32, device_name_fmt,
-                 caps.szPname, caps.wMid, caps.wPid);
-        p_item->ppsz_list[j] = FromWide( dev_name );
-        p_item->ppsz_list_text[j] = FromWide( dev_name );
-        p_item->i_list++;
-        j++;
+                   caps.szPname, caps.wMid, caps.wPid);
+        (*values)[n] = FromWide( dev_name );
+        (*descs)[n] = strdup( (*values)[n] );
+        n++;
     }
-    p_item->ppsz_list[j] = NULL;
-    p_item->ppsz_list_text[j] = NULL;
 
-    return VLC_SUCCESS;
+    return n;
 }
 
 /*