Module: wine Branch: master Commit: 253b1325b4a8ffc02e0c05e336c201ae8bbb3705 URL: https://source.winehq.org/git/wine.git/?a=commit;h=253b1325b4a8ffc02e0c05e33...
Author: Huw Davies huw@codeweavers.com Date: Thu Mar 10 08:20:06 2022 +0000
winealsa: Move set_volumes to the unixlib.
Signed-off-by: Huw Davies huw@codeweavers.com Signed-off-by: Andrew Eikum aeikum@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winealsa.drv/alsa.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ dlls/winealsa.drv/mmdevdrv.c | 12 ++++++----- dlls/winealsa.drv/unixlib.h | 46 +++++++++------------------------------- 3 files changed, 67 insertions(+), 41 deletions(-)
diff --git a/dlls/winealsa.drv/alsa.c b/dlls/winealsa.drv/alsa.c index 365f5637b20..c199a2e603d 100644 --- a/dlls/winealsa.drv/alsa.c +++ b/dlls/winealsa.drv/alsa.c @@ -45,6 +45,43 @@
WINE_DEFAULT_DEBUG_CHANNEL(alsa);
+struct alsa_stream +{ + snd_pcm_t *pcm_handle; + snd_pcm_uframes_t alsa_bufsize_frames, alsa_period_frames, safe_rewind_frames; + snd_pcm_hw_params_t *hw_params; /* does not hold state between calls */ + snd_pcm_format_t alsa_format; + + LARGE_INTEGER last_period_time; + + WAVEFORMATEX *fmt; + DWORD flags; + AUDCLNT_SHAREMODE share; + EDataFlow flow; + HANDLE event; + + BOOL need_remapping; + int alsa_channels; + int alsa_channel_map[32]; + + BOOL started, please_quit; + REFERENCE_TIME mmdev_period_rt; + UINT64 written_frames, last_pos_frames; + UINT32 bufsize_frames, held_frames, tmp_buffer_frames, mmdev_period_frames; + snd_pcm_uframes_t remapping_buf_frames; + UINT32 lcl_offs_frames; /* offs into local_buffer where valid data starts */ + UINT32 wri_offs_frames; /* where to write fresh data in local_buffer */ + UINT32 hidden_frames; /* ALSA reserve to ensure continuous rendering */ + UINT32 vol_adjusted_frames; /* Frames we've already adjusted the volume of but didn't write yet */ + UINT32 data_in_alsa_frames; + + BYTE *local_buffer, *tmp_buffer, *remapping_buf, *silence_buf; + LONG32 getbuf_last; /* <0 when using tmp_buffer */ + float *vols; + + pthread_mutex_t lock; +}; + #define EXTRA_SAFE_RT 40000
static const WCHAR drv_keyW[] = {'S','o','f','t','w','a','r','e','\', @@ -2162,6 +2199,18 @@ static NTSTATUS get_position(void *args) return alsa_unlock_result(stream, ¶ms->result, S_OK); }
+static NTSTATUS set_volumes(void *args) +{ + struct set_volumes_params *params = args; + struct alsa_stream *stream = params->stream; + unsigned int i; + + for(i = 0; i < stream->fmt->nChannels; i++) + stream->vols[i] = params->volumes[i] * params->session_volumes[i] * params->master_volume; + + return STATUS_SUCCESS; +} + static NTSTATUS set_event_handle(void *args) { struct set_event_handle_params *params = args; @@ -2213,6 +2262,7 @@ unixlib_entry_t __wine_unix_call_funcs[] = get_next_packet_size, get_frequency, get_position, + set_volumes, set_event_handle, is_started, }; diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 0f6a30e0f45..c2ec3dd54af 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -334,12 +334,14 @@ static void get_device_guid(EDataFlow flow, const char *device, GUID *guid)
static void set_stream_volumes(ACImpl *This) { - struct alsa_stream *stream = This->stream; - unsigned int i; + struct set_volumes_params params; + + params.stream = This->stream; + params.master_volume = (This->session->mute ? 0.0f : This->session->master_vol); + params.volumes = This->vols; + params.session_volumes = This->session->channel_vols;
- for(i = 0; i < stream->fmt->nChannels; i++) - stream->vols[i] = This->session->mute ? 0.0f : - This->vols[i] * This->session->channel_vols[i] * This->session->master_vol; + ALSA_CALL(set_volumes, ¶ms); }
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **guids_out, diff --git a/dlls/winealsa.drv/unixlib.h b/dlls/winealsa.drv/unixlib.h index b73f40c8282..4326f79a50b 100644 --- a/dlls/winealsa.drv/unixlib.h +++ b/dlls/winealsa.drv/unixlib.h @@ -18,42 +18,7 @@
#include "audioclient.h"
-struct alsa_stream -{ - snd_pcm_t *pcm_handle; - snd_pcm_uframes_t alsa_bufsize_frames, alsa_period_frames, safe_rewind_frames; - snd_pcm_hw_params_t *hw_params; /* does not hold state between calls */ - snd_pcm_format_t alsa_format; - - LARGE_INTEGER last_period_time; - - WAVEFORMATEX *fmt; - DWORD flags; - AUDCLNT_SHAREMODE share; - EDataFlow flow; - HANDLE event; - - BOOL need_remapping; - int alsa_channels; - int alsa_channel_map[32]; - - BOOL started, please_quit; - REFERENCE_TIME mmdev_period_rt; - UINT64 written_frames, last_pos_frames; - UINT32 bufsize_frames, held_frames, tmp_buffer_frames, mmdev_period_frames; - snd_pcm_uframes_t remapping_buf_frames; - UINT32 lcl_offs_frames; /* offs into local_buffer where valid data starts */ - UINT32 wri_offs_frames; /* where to write fresh data in local_buffer */ - UINT32 hidden_frames; /* ALSA reserve to ensure continuous rendering */ - UINT32 vol_adjusted_frames; /* Frames we've already adjusted the volume of but didn't write yet */ - UINT32 data_in_alsa_frames; - - BYTE *local_buffer, *tmp_buffer, *remapping_buf, *silence_buf; - LONG32 getbuf_last; /* <0 when using tmp_buffer */ - float *vols; - - pthread_mutex_t lock; -}; +struct alsa_stream;
struct endpoint { @@ -209,6 +174,14 @@ struct get_position_params UINT64 *qpctime; };
+struct set_volumes_params +{ + struct alsa_stream *stream; + float master_volume; + const float *volumes; + const float *session_volumes; +}; + struct set_event_handle_params { struct alsa_stream *stream; @@ -243,6 +216,7 @@ enum alsa_funcs alsa_get_next_packet_size, alsa_get_frequency, alsa_get_position, + alsa_set_volumes, alsa_set_event_handle, alsa_is_started, };