Jacek Caban : winepulse: Store volume levels in pulse_stream.

Alexandre Julliard julliard at winehq.org
Mon May 17 15:45:33 CDT 2021


Module: wine
Branch: master
Commit: bca0706f3a93fa0a57f4dbdc6ae541e8f25afb34
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=bca0706f3a93fa0a57f4dbdc6ae541e8f25afb34

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu May 13 16:03:38 2021 +0200

winepulse: Store volume levels in pulse_stream.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winepulse.drv/mmdevdrv.c |  9 ++++++++-
 dlls/winepulse.drv/pulse.c    | 13 ++++++++++++-
 dlls/winepulse.drv/unixlib.h  |  2 ++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 589a87076ff..2a9ebd86c3a 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -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->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;
     }
     if (!adjust) goto write;
@@ -526,6 +526,11 @@ static DWORD WINAPI pulse_timer_cb(void *user)
     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,
         UINT *num, UINT *def_index)
 {
@@ -870,6 +875,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient3 *iface,
     if (SUCCEEDED(hr)) {
         hr = get_audio_session(sessionguid, This->parent, This->channel_count, &This->session);
         if (SUCCEEDED(hr)) {
+            set_stream_volumes(This);
             list_add_tail(&This->session->clients, &This->entry);
         } else {
             pulse->release_stream(This->pulse_stream, NULL);
@@ -2038,6 +2044,7 @@ static HRESULT WINAPI AudioStreamVolume_SetAllVolumes(
     for (i = 0; i < count; ++i)
         This->vol[i] = levels[i];
 
+    set_stream_volumes(This);
 out:
     pulse->unlock();
     return hr;
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
index fed34167018..f0bfcd98b7d 100644
--- a/dlls/winepulse.drv/pulse.c
+++ b/dlls/winepulse.drv/pulse.c
@@ -755,7 +755,7 @@ static HRESULT WINAPI pulse_create_stream(const char *name, EDataFlow dataflow,
                                           struct pulse_stream **ret)
 {
     struct pulse_stream *stream;
-    unsigned int bufsize_bytes;
+    unsigned int i, bufsize_bytes;
     HRESULT hr;
 
     if (FAILED(hr = pulse_connect(name)))
@@ -765,6 +765,8 @@ static HRESULT WINAPI pulse_create_stream(const char *name, EDataFlow dataflow,
         return E_OUTOFMEMORY;
 
     stream->dataflow = dataflow;
+    for (i = 0; i < ARRAY_SIZE(stream->vol); ++i)
+        stream->vol[i] = 1.f;
 
     hr = pulse_spec_from_waveformat(stream, fmt);
     TRACE("Obtaining format returns %08x\n", hr);
@@ -1002,6 +1004,14 @@ static HRESULT WINAPI pulse_stop(struct pulse_stream *stream)
     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 =
 {
     pulse_lock,
@@ -1013,6 +1023,7 @@ static const struct unix_funcs unix_funcs =
     pulse_release_stream,
     pulse_read,
     pulse_stop,
+    pulse_set_volumes,
     pulse_test_connect,
 };
 
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
index ca764afa19d..7b5c5400a1f 100644
--- a/dlls/winepulse.drv/unixlib.h
+++ b/dlls/winepulse.drv/unixlib.h
@@ -49,6 +49,7 @@ struct pulse_stream
     DWORD flags;
     AUDCLNT_SHAREMODE share;
     HANDLE event;
+    float vol[PA_CHANNELS_MAX];
 
     INT32 locked;
     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 *read)(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);
 };




More information about the wine-cvs mailing list