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

Claire Girka wine at gitlab.winehq.org
Tue Jul 5 08:56:34 CDT 2022


From: Claire Girka <claire at sitedethib.com>

---
 dlls/winepulse.drv/mmdevdrv.c | 13 +++++----
 dlls/winepulse.drv/pulse.c    | 54 +++++++++++++++++++++++++++++++++++
 dlls/winepulse.drv/unixlib.h  | 10 +++++++
 3 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 61875b7352d..6b78a56388b 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1165,6 +1165,7 @@ static HRESULT WINAPI AudioClient_GetMixFormat(IAudioClient3 *iface,
 static HRESULT WINAPI AudioClient_GetDevicePeriod(IAudioClient3 *iface,
         REFERENCE_TIME *defperiod, REFERENCE_TIME *minperiod)
 {
+    struct get_device_period_params params;
     ACImpl *This = impl_from_IAudioClient3(iface);
 
     TRACE("(%p)->(%p, %p)\n", This, defperiod, minperiod);
@@ -1172,12 +1173,14 @@ static HRESULT WINAPI AudioClient_GetDevicePeriod(IAudioClient3 *iface,
     if (!defperiod && !minperiod)
         return E_POINTER;
 
-    if (defperiod)
-        *defperiod = pulse_config.modes[This->dataflow == eCapture].def_period;
-    if (minperiod)
-        *minperiod = pulse_config.modes[This->dataflow == eCapture].min_period;
+    params.flow = This->dataflow;
+    params.pulse_name = This->pulse_name;
+    params.def_period = defperiod;
+    params.min_period = minperiod;
 
-    return S_OK;
+    pulse_call(get_device_period, &params);
+
+    return params.result;
 }
 
 static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface)
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
index 2e2d94d2d1f..2b8f6ffdcbc 100644
--- a/dlls/winepulse.drv/pulse.c
+++ b/dlls/winepulse.drv/pulse.c
@@ -1075,6 +1075,28 @@ static ULONG_PTR zero_bits(void)
 #endif
 }
 
+static HRESULT get_device_period_helper(EDataFlow flow, const char *pulse_name, REFERENCE_TIME *def, REFERENCE_TIME *min) {
+    struct list *list = (flow == eRender) ? &g_phys_speakers : &g_phys_sources;
+    PhysDevice *dev;
+
+    if (!def && !min) {
+        return E_POINTER;
+    }
+
+    LIST_FOR_EACH_ENTRY(dev, list, PhysDevice, entry) {
+        if (strcmp(pulse_name, dev->pulse_name))
+            continue;
+
+        if (def)
+            *def = dev->def_period;
+        if (min)
+            *min = dev->min_period;
+        return S_OK;
+    }
+
+    return E_FAIL;
+}
+
 static NTSTATUS pulse_create_stream(void *args)
 {
     struct create_stream_params *params = args;
@@ -2052,6 +2074,14 @@ static NTSTATUS pulse_get_mix_format(void *args)
     return STATUS_SUCCESS;
 }
 
+static NTSTATUS pulse_get_device_period(void *args)
+{
+    struct get_device_period_params *params = args;
+
+    params->result = get_device_period_helper(params->flow, params->pulse_name, params->def_period, params->min_period);
+    return STATUS_SUCCESS;
+}
+
 static NTSTATUS pulse_get_buffer_size(void *args)
 {
     struct get_buffer_size_params *params = args;
@@ -2332,6 +2362,7 @@ const unixlib_entry_t __wine_unix_call_funcs[] =
     pulse_get_capture_buffer,
     pulse_release_capture_buffer,
     pulse_get_mix_format,
+    pulse_get_device_period,
     pulse_get_buffer_size,
     pulse_get_latency,
     pulse_get_current_padding,
@@ -2507,6 +2538,28 @@ static NTSTATUS pulse_wow64_get_mix_format(void *args)
     return STATUS_SUCCESS;
 }
 
+static NTSTATUS pulse_wow64_get_device_period(void *args)
+{
+    struct
+    {
+        PTR32 pulse_name;
+        EDataFlow flow;
+        HRESULT result;
+        PTR32 def_period;
+        PTR32 min_period;
+    } *params32 = args;
+    struct get_device_period_params params =
+    {
+        .pulse_name = ULongToPtr(params32->pulse_name),
+        .flow = params32->flow,
+        .def_period = ULongToPtr(params32->def_period),
+        .min_period = ULongToPtr(params32->min_period),
+    };
+    pulse_get_device_period(&params);
+    params32->result = params.result;
+    return STATUS_SUCCESS;
+}
+
 static NTSTATUS pulse_wow64_get_buffer_size(void *args)
 {
     struct
@@ -2734,6 +2787,7 @@ const unixlib_entry_t __wine_unix_call_wow64_funcs[] =
     pulse_wow64_get_capture_buffer,
     pulse_release_capture_buffer,
     pulse_wow64_get_mix_format,
+    pulse_wow64_get_device_period,
     pulse_wow64_get_buffer_size,
     pulse_wow64_get_latency,
     pulse_wow64_get_current_padding,
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
index b6a19ddeb96..2eebc20297c 100644
--- a/dlls/winepulse.drv/unixlib.h
+++ b/dlls/winepulse.drv/unixlib.h
@@ -146,6 +146,15 @@ struct get_mix_format_params
     HRESULT result;
 };
 
+struct get_device_period_params
+{
+    const char *pulse_name;
+    EDataFlow flow;
+    HRESULT result;
+    REFERENCE_TIME *def_period;
+    REFERENCE_TIME *min_period;
+};
+
 struct get_buffer_size_params
 {
     stream_handle stream;
@@ -250,6 +259,7 @@ enum unix_funcs
     get_capture_buffer,
     release_capture_buffer,
     get_mix_format,
+    get_device_period,
     get_buffer_size,
     get_latency,
     get_current_padding,
-- 
GitLab


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



More information about the wine-devel mailing list