[PATCH v2 3/3] winepulse: Return device-specific values for GetDevicePeriod

Claire Girka wine at gitlab.winehq.org
Wed Jun 29 09:14:55 CDT 2022


From: Claire Girka <claire at sitedethib.com>

When GetDevicePeriod is used, return values specific to the selected device
instead of those of the default one.
---
 dlls/winepulse.drv/mmdevdrv.c | 17 +++++++++++++++++
 dlls/winepulse.drv/pulse.c    | 21 +++++++++++++++++++++
 dlls/winepulse.drv/unixlib.h  | 10 ++++++++++
 3 files changed, 48 insertions(+)

diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index fca36b22d90..4ebc508735c 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1173,6 +1173,23 @@ static HRESULT WINAPI AudioClient_GetDevicePeriod(IAudioClient3 *iface,
     if (!defperiod && !minperiod)
         return E_POINTER;
 
+    if (This->pulse_name[0]) {
+        struct get_device_period_params params;
+        params.render = This->dataflow == eRender;
+        params.pulse_name = This->pulse_name;
+        pulse_call(get_device_period, &params);
+
+        if (FAILED(params.result))
+            return params.result;
+
+        if (defperiod)
+            *defperiod = params.def_period;
+        if (minperiod)
+            *minperiod = params.min_period;
+
+        return S_OK;
+    }
+
     if (defperiod)
         *defperiod = pulse_config.modes[This->dataflow == eCapture].def_period;
     if (minperiod)
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
index 1855ffe11f4..4f1c0e2af26 100644
--- a/dlls/winepulse.drv/pulse.c
+++ b/dlls/winepulse.drv/pulse.c
@@ -759,6 +759,26 @@ static NTSTATUS pulse_get_device_mix_format(void *args)
     return STATUS_SUCCESS;
 }
 
+static NTSTATUS pulse_get_device_period(void *args) {
+    struct get_device_period_params *params = args;
+    struct list *list = params->render ? &g_phys_speakers : &g_phys_sources;
+    PhysDevice *dev;
+
+    LIST_FOR_EACH_ENTRY(dev, list, PhysDevice, entry) {
+        if (strcmp(params->pulse_name, dev->pulse_name))
+            continue;
+
+        params->def_period = dev->def_period;
+        params->min_period = dev->min_period;
+        params->result = S_OK;
+
+        return STATUS_SUCCESS;
+    }
+
+    params->result = E_FAIL;
+    return STATUS_SUCCESS;
+}
+
 /* some poorly-behaved applications call audio functions during DllMain, so we
  * have to do as much as possible without creating a new thread. this function
  * sets up a synchronous connection to verify the server is running and query
@@ -2337,6 +2357,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
     pulse_is_started,
     pulse_get_prop_value,
     pulse_get_device_mix_format,
+    pulse_get_device_period,
 };
 
 #ifdef _WIN64
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
index 6f8e3cf3211..68137c5a59a 100644
--- a/dlls/winepulse.drv/unixlib.h
+++ b/dlls/winepulse.drv/unixlib.h
@@ -167,6 +167,15 @@ struct get_device_mix_format_params
     WAVEFORMATEXTENSIBLE fmt;
 };
 
+struct get_device_period_params
+{
+    const char *pulse_name;
+    HRESULT result;
+    BOOL render;
+    REFERENCE_TIME def_period;
+    REFERENCE_TIME min_period;
+};
+
 struct get_next_packet_size_params
 {
     stream_handle stream;
@@ -261,4 +270,5 @@ enum unix_funcs
     is_started,
     get_prop_value,
     get_device_mix_format,
+    get_device_period,
 };
-- 
GitLab

https://gitlab.winehq.org/wine/wine/-/merge_requests/337



More information about the wine-devel mailing list