winepulse: Adjust pulse stream volumes for master volume.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-05-13 16:03:58 +02:00 committed by Alexandre Julliard
parent bca0706f3a
commit 8060e56b26
3 changed files with 10 additions and 5 deletions

View File

@ -264,7 +264,7 @@ static int write_buffer(const ACImpl *This, BYTE *buffer, UINT32 bytes)
channels = This->pulse_stream->ss.channels;
for (i = 0; i < channels; i++)
{
vol[i] = This->pulse_stream->vol[i] * This->session->master_vol * This->session->channel_vols[i];
vol[i] = This->pulse_stream->vol[i] * This->session->channel_vols[i];
adjust |= vol[i] != 1.0f;
}
if (!adjust) goto write;
@ -528,7 +528,7 @@ static DWORD WINAPI pulse_timer_cb(void *user)
static void set_stream_volumes(ACImpl *This)
{
pulse->set_volumes(This->pulse_stream, This->vol);
pulse->set_volumes(This->pulse_stream, This->session->master_vol, This->vol);
}
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **keys,
@ -2593,6 +2593,7 @@ static HRESULT WINAPI SimpleAudioVolume_SetMasterVolume(
{
AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
AudioSession *session = This->session;
ACImpl *client;
TRACE("(%p)->(%f, %s)\n", session, level, wine_dbgstr_guid(context));
@ -2606,6 +2607,8 @@ static HRESULT WINAPI SimpleAudioVolume_SetMasterVolume(
pulse->lock();
session->master_vol = level;
LIST_FOR_EACH_ENTRY(client, &This->session->clients, ACImpl, entry)
set_stream_volumes(client);
pulse->unlock();
return S_OK;

View File

@ -1004,12 +1004,13 @@ static HRESULT WINAPI pulse_stop(struct pulse_stream *stream)
return hr;
}
static void WINAPI pulse_set_volumes(struct pulse_stream *stream, const float *volumes)
static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume,
const float *volumes)
{
unsigned int i;
for (i = 0; i < stream->ss.channels; i++)
stream->vol[i] = volumes[i];
stream->vol[i] = volumes[i] * master_volume;
}
static const struct unix_funcs unix_funcs =

View File

@ -80,6 +80,7 @@ struct unix_funcs
void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer);
void (WINAPI *read)(struct pulse_stream *stream);
HRESULT (WINAPI *stop)(struct pulse_stream *stream);
void (WINAPI *set_volumes)(struct pulse_stream *stream, const float *volumes);
void (WINAPI *set_volumes)(struct pulse_stream *stream, float master_volume,
const float *volumes);
HRESULT (WINAPI *test_connect)(const char *name, struct pulse_config *config);
};