Commit bca0706f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winepulse: Store volume levels in pulse_stream.

parent b1ddfca1
...@@ -264,7 +264,7 @@ static int write_buffer(const ACImpl *This, BYTE *buffer, UINT32 bytes) ...@@ -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) ...@@ -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, ...@@ -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( ...@@ -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;
......
...@@ -755,7 +755,7 @@ static HRESULT WINAPI pulse_create_stream(const char *name, EDataFlow dataflow, ...@@ -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, ...@@ -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) ...@@ -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 = ...@@ -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,
}; };
......
...@@ -49,6 +49,7 @@ struct pulse_stream ...@@ -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 ...@@ -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);
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment