From a599ea83c8148685c2b3e69102aaf4cf3c2d48f3 Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Thu, 10 Dec 2015 10:35:55 -0600 Subject: [PATCH] winepulse.drv: Print a winediag error when PA buffer size is too small. 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 Signed-off-by: Sebastian Lackner Signed-off-by: Alexandre Julliard --- 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 0e6cf9f58b0..ef171d3a900 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;