[PATCH] winepulse.drv: Print a winediag error when PA buffer size is too small.

Andrew Eikum aeikum at codeweavers.com
Thu Dec 10 10:35:55 CST 2015


winepulse depends on PulseAudio to allocate the entire requested
buffer size. If it allocates less than that size, then mmdevapi
clients may not be able to write as much data as they expect. So, we
should warn the user that the PA buffer is too small.

This is a common symptom of users setting the PULSE_LATENCY_MSEC
environment variable, which would help in some situations with
winealsa, but is no longer required with winepulse.

Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>
---
 dlls/winepulse.drv/mmdevdrv.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 0e6cf9f..ef171d3 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -57,6 +57,7 @@
 #include "audiopolicy.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(pulse);
+WINE_DECLARE_DEBUG_CHANNEL(winediag);
 
 #define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
 
@@ -1336,9 +1337,16 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
         const pa_buffer_attr *attr = pa_stream_get_buffer_attr(This->stream);
         /* Update frames according to new size */
         dump_attr(attr);
-        if (This->dataflow == eRender)
+        if (This->dataflow == eRender) {
+            if (attr->tlength < This->bufsize_bytes) {
+                const char *latenv = getenv("PULSE_LATENCY_MSEC");
+                if (latenv && *latenv)
+                    ERR_(winediag)("PulseAudio buffer too small (%u < %u) - PULSE_LATENCY_MSEC is %s\n", attr->tlength, This->bufsize_bytes, latenv);
+                else
+                    ERR_(winediag)("PulseAudio buffer too small (%u < %u)\n", attr->tlength, This->bufsize_bytes);
+            }
             This->bufsize_bytes = attr->tlength;
-        else {
+        } else {
             This->capture_period = period_bytes = attr->fragsize;
             if ((unalign = This->bufsize_bytes % period_bytes))
                 This->bufsize_bytes += period_bytes - unalign;
-- 
2.6.3




More information about the wine-patches mailing list