winepulse: Store volume levels in pulse_stream.

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:38 +02:00 committed by Alexandre Julliard
parent b1ddfca16e
commit bca0706f3a
3 changed files with 22 additions and 2 deletions

View File

@ -264,7 +264,7 @@ static int write_buffer(const ACImpl *This, BYTE *buffer, UINT32 bytes)
channels = This->pulse_stream->ss.channels; channels = This->pulse_stream->ss.channels;
for (i = 0; i < channels; i++) for (i = 0; i < channels; i++)
{ {
vol[i] = This->vol[i] * This->session->master_vol * This->session->channel_vols[i]; vol[i] = This->pulse_stream->vol[i] * This->session->master_vol * This->session->channel_vols[i];
adjust |= vol[i] != 1.0f; adjust |= vol[i] != 1.0f;
} }
if (!adjust) goto write; if (!adjust) goto write;
@ -526,6 +526,11 @@ static DWORD WINAPI pulse_timer_cb(void *user)
return 0; return 0;
} }
static void set_stream_volumes(ACImpl *This)
{
pulse->set_volumes(This->pulse_stream, This->vol);
}
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **keys, HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **keys,
UINT *num, UINT *def_index) UINT *num, UINT *def_index)
{ {
@ -870,6 +875,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
hr = get_audio_session(sessionguid, This->parent, This->channel_count, &This->session); hr = get_audio_session(sessionguid, This->parent, This->channel_count, &This->session);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
set_stream_volumes(This);
list_add_tail(&This->session->clients, &This->entry); list_add_tail(&This->session->clients, &This->entry);
} else { } else {
pulse->release_stream(This->pulse_stream, NULL); pulse->release_stream(This->pulse_stream, NULL);
@ -2038,6 +2044,7 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes(
for (i = 0; i < count; ++i) for (i = 0; i < count; ++i)
This->vol[i] = levels[i]; This->vol[i] = levels[i];
set_stream_volumes(This);
out: out:
pulse->unlock(); pulse->unlock();
return hr; return hr;

View File

@ -755,7 +755,7 @@ static HRESULT WINAPI pulse_create_stream(const char *name, EDataFlow dataflow,
struct pulse_stream **ret) struct pulse_stream **ret)
{ {
struct pulse_stream *stream; struct pulse_stream *stream;
unsigned int bufsize_bytes; unsigned int i, bufsize_bytes;
HRESULT hr; HRESULT hr;
if (FAILED(hr = pulse_connect(name))) if (FAILED(hr = pulse_connect(name)))
@ -765,6 +765,8 @@ static HRESULT WINAPI pulse_create_stream(const char *name, EDataFlow dataflow,
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
stream->dataflow = dataflow; stream->dataflow = dataflow;
for (i = 0; i < ARRAY_SIZE(stream->vol); ++i)
stream->vol[i] = 1.f;
hr = pulse_spec_from_waveformat(stream, fmt); hr = pulse_spec_from_waveformat(stream, fmt);
TRACE("Obtaining format returns %08x\n", hr); TRACE("Obtaining format returns %08x\n", hr);
@ -1002,6 +1004,14 @@ static HRESULT WINAPI pulse_stop(struct pulse_stream *stream)
return hr; return hr;
} }
static void WINAPI pulse_set_volumes(struct pulse_stream *stream, const float *volumes)
{
unsigned int i;
for (i = 0; i < stream->ss.channels; i++)
stream->vol[i] = volumes[i];
}
static const struct unix_funcs unix_funcs = static const struct unix_funcs unix_funcs =
{ {
pulse_lock, pulse_lock,
@ -1013,6 +1023,7 @@ static const struct unix_funcs unix_funcs =
pulse_release_stream, pulse_release_stream,
pulse_read, pulse_read,
pulse_stop, pulse_stop,
pulse_set_volumes,
pulse_test_connect, pulse_test_connect,
}; };

View File

@ -49,6 +49,7 @@ struct pulse_stream
DWORD flags; DWORD flags;
AUDCLNT_SHAREMODE share; AUDCLNT_SHAREMODE share;
HANDLE event; HANDLE event;
float vol[PA_CHANNELS_MAX];
INT32 locked; INT32 locked;
UINT32 bufsize_frames, real_bufsize_bytes, period_bytes; UINT32 bufsize_frames, real_bufsize_bytes, period_bytes;
@ -79,5 +80,6 @@ struct unix_funcs
void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer); void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer);
void (WINAPI *read)(struct pulse_stream *stream); void (WINAPI *read)(struct pulse_stream *stream);
HRESULT (WINAPI *stop)(struct pulse_stream *stream); HRESULT (WINAPI *stop)(struct pulse_stream *stream);
void (WINAPI *set_volumes)(struct pulse_stream *stream, const float *volumes);
HRESULT (WINAPI *test_connect)(const char *name, struct pulse_config *config); HRESULT (WINAPI *test_connect)(const char *name, struct pulse_config *config);
}; };