Updated winepulse-PulseAudio_Support patchset

This commit is contained in:
Alistair Leslie-Hughes 2018-07-20 08:34:16 +10:00
parent 49025c255b
commit 18f4be0e03

View File

@ -1,14 +1,14 @@
From 79547dc643cb4686b61cd60a1ce975714b033a89 Mon Sep 17 00:00:00 2001
From 6b24328a061f853e5aafe258fc8f3075aae71b16 Mon Sep 17 00:00:00 2001
From: Andrew Eikum <aeikum@codeweavers.com>
Date: Fri, 1 Jun 2018 14:43:01 -0500
Subject: [PATCH 2/7] winepulse: Don't rely on pulseaudio callbacks for timing
---
dlls/winepulse.drv/mmdevdrv.c | 491 +++++++++++++++++++-----------------------
1 file changed, 221 insertions(+), 270 deletions(-)
dlls/winepulse.drv/mmdevdrv.c | 505 +++++++++++++++++++-----------------------
1 file changed, 231 insertions(+), 274 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index f192b1d..0039c34 100644
index f192b1d..0654ab0 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -169,13 +169,16 @@ struct ACImpl {
@ -192,7 +192,38 @@ index f192b1d..0039c34 100644
}
QueryPerformanceCounter(&stamp);
QueryPerformanceFrequency(&freq);
@@ -795,21 +757,18 @@ static void pulse_rd_loop(ACImpl *This, size_t bytes)
@@ -769,12 +731,14 @@ static void pulse_rd_loop(ACImpl *This, size_t bytes)
This->peek_ofs += copy;
if(This->peek_len == This->peek_ofs)
This->peek_len = 0;
- } else {
- pa_stream_peek(This->stream, (const void**)&src, &src_len);
+ } else if (pa_stream_peek(This->stream, (const void**)&src, &src_len) && src_len) {
copy = min(rem, src_len);
- memcpy(dst, src, rem);
+ if(src)
+ memcpy(dst, src, copy);
+ else
+ silence_buffer(This->ss.format, dst, copy);
dst += copy;
rem -= copy;
@@ -786,7 +750,11 @@ static void pulse_rd_loop(ACImpl *This, size_t bytes)
This->peek_buffer_len = src_len;
}
- memcpy(This->peek_buffer, src + copy, src_len - copy);
+ if(src)
+ memcpy(This->peek_buffer, src + copy, src_len - copy);
+ else
+ silence_buffer(This->ss.format, This->peek_buffer, src_len - copy);
+
This->peek_len = src_len - copy;
This->peek_ofs = 0;
}
@@ -795,21 +763,18 @@ static void pulse_rd_loop(ACImpl *This, size_t bytes)
}
}
@ -217,7 +248,7 @@ index f192b1d..0039c34 100644
copy = rem;
if (copy > src_len)
@@ -828,23 +787,95 @@ static void pulse_rd_drop(ACImpl *This, size_t bytes)
@@ -828,23 +793,95 @@ static void pulse_rd_drop(ACImpl *This, size_t bytes)
}
}
@ -240,9 +271,7 @@ index f192b1d..0039c34 100644
else
pulse_rd_drop(This, bytes);
+}
- if (This->event)
- SetEvent(This->event);
+
+static DWORD WINAPI pulse_timer_cb(void *user)
+{
+ DWORD delay;
@ -278,7 +307,9 @@ index f192b1d..0039c34 100644
+ }
+ }else{
+ INT32 adjust = This->last_time + This->mmdev_period_usec - now;
+
- if (This->event)
- SetEvent(This->event);
+ adv_usec = now - This->last_time;
+
+ if(adjust > ((INT32)(This->mmdev_period_usec / 2)))
@ -321,7 +352,7 @@ index f192b1d..0039c34 100644
}
static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
@@ -873,15 +904,16 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
@@ -873,15 +910,16 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
/* PulseAudio will fill in correct values */
attr.minreq = attr.fragsize = period_bytes;
@ -341,7 +372,7 @@ index f192b1d..0039c34 100644
if (ret < 0) {
WARN("Returns %i\n", ret);
return AUDCLNT_E_ENDPOINT_CREATE_FAILED;
@@ -892,11 +924,9 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
@@ -892,11 +930,9 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
return AUDCLNT_E_ENDPOINT_CREATE_FAILED;
if (This->dataflow == eRender) {
@ -354,7 +385,7 @@ index f192b1d..0039c34 100644
return S_OK;
}
@@ -1031,6 +1061,11 @@ static ULONG WINAPI AudioClient_Release(IAudioClient *iface)
@@ -1031,6 +1067,11 @@ static ULONG WINAPI AudioClient_Release(IAudioClient *iface)
TRACE("(%p) Refcount now %u\n", This, ref);
if (!ref) {
if (This->stream) {
@ -366,7 +397,7 @@ index f192b1d..0039c34 100644
pthread_mutex_lock(&pulse_lock);
if (PA_STREAM_IS_GOOD(pa_stream_get_state(This->stream))) {
pa_stream_disconnect(This->stream);
@@ -1326,7 +1361,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
@@ -1326,7 +1367,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
{
ACImpl *This = impl_from_IAudioClient(iface);
HRESULT hr = S_OK;
@ -375,7 +406,7 @@ index f192b1d..0039c34 100644
TRACE("(%p)->(%x, %x, %s, %s, %p, %s)\n", This, mode, flags,
wine_dbgstr_longlong(duration), wine_dbgstr_longlong(period), fmt, debugstr_guid(sessionguid));
@@ -1371,38 +1406,19 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
@@ -1371,38 +1412,19 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
if (FAILED(hr))
goto exit;
@ -398,14 +429,14 @@ index f192b1d..0039c34 100644
- period = def;
- if (duration < 2 * period)
- duration = 2 * period;
+ This->period_bytes = pa_frame_size(&This->ss) * MulDiv(period, This->ss.rate, 10000000);
-
- /* Uh oh, really low latency requested.. */
- if (duration <= 2 * period)
- period /= 2;
- }
- period_bytes = pa_frame_size(&This->ss) * MulDiv(period, This->ss.rate, 10000000);
-
+ This->period_bytes = pa_frame_size(&This->ss) * MulDiv(period, This->ss.rate, 10000000);
- if (duration < 20000000)
- This->bufsize_frames = ceil((duration / 10000000.) * fmt->nSamplesPerSec);
- else
@ -422,7 +453,7 @@ index f192b1d..0039c34 100644
if (SUCCEEDED(hr)) {
UINT32 unalign;
const pa_buffer_attr *attr = pa_stream_get_buffer_attr(This->stream);
@@ -1410,39 +1426,34 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
@@ -1410,39 +1432,34 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
/* Update frames according to new size */
dump_attr(attr);
if (This->dataflow == eRender) {
@ -475,7 +506,7 @@ index f192b1d..0039c34 100644
}
}
}
@@ -1507,12 +1518,12 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient *iface,
@@ -1507,12 +1524,12 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient *iface,
attr = pa_stream_get_buffer_attr(This->stream);
if (This->dataflow == eRender){
lat = attr->minreq / pa_frame_size(&This->ss);
@ -489,7 +520,7 @@ index f192b1d..0039c34 100644
pthread_mutex_unlock(&pulse_lock);
TRACE("Latency: %u ms\n", (DWORD)(*latency / 10000));
return S_OK;
@@ -1520,7 +1531,7 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient *iface,
@@ -1520,7 +1537,7 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient *iface,
static void ACImpl_GetRenderPad(ACImpl *This, UINT32 *out)
{
@ -498,7 +529,7 @@ index f192b1d..0039c34 100644
}
static void ACImpl_GetCapturePad(ACImpl *This, UINT32 *out)
@@ -1532,7 +1543,7 @@ static void ACImpl_GetCapturePad(ACImpl *This, UINT32 *out)
@@ -1532,7 +1549,7 @@ static void ACImpl_GetCapturePad(ACImpl *This, UINT32 *out)
list_remove(&packet->entry);
}
if (out)
@ -507,7 +538,7 @@ index f192b1d..0039c34 100644
}
static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient *iface,
@@ -1778,6 +1789,8 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
@@ -1778,6 +1795,8 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
return AUDCLNT_E_NOT_STOPPED;
}
@ -516,7 +547,7 @@ index f192b1d..0039c34 100644
if (pa_stream_is_corked(This->stream)) {
o = pa_stream_cork(This->stream, 0, pulse_op_cb, &success);
if (o) {
@@ -1792,8 +1805,10 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
@@ -1792,8 +1811,10 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
if (SUCCEEDED(hr)) {
This->started = TRUE;
@ -529,7 +560,7 @@ index f192b1d..0039c34 100644
}
pthread_mutex_unlock(&pulse_lock);
return hr;
@@ -1865,7 +1880,7 @@ static HRESULT WINAPI AudioClient_Reset(IAudioClient *iface)
@@ -1865,7 +1886,7 @@ static HRESULT WINAPI AudioClient_Reset(IAudioClient *iface)
if (This->dataflow == eRender) {
/* If there is still data in the render buffer it needs to be removed from the server */
int success = 0;
@ -538,7 +569,7 @@ index f192b1d..0039c34 100644
pa_operation *o = pa_stream_flush(This->stream, pulse_op_cb, &success);
if (o) {
while(pa_operation_get_state(o) == PA_OPERATION_RUNNING)
@@ -1873,14 +1888,14 @@ static HRESULT WINAPI AudioClient_Reset(IAudioClient *iface)
@@ -1873,14 +1894,14 @@ static HRESULT WINAPI AudioClient_Reset(IAudioClient *iface)
pa_operation_unref(o);
}
}
@ -558,7 +589,7 @@ index f192b1d..0039c34 100644
if ((p = This->locked_ptr)) {
This->locked_ptr = NULL;
@@ -2046,10 +2061,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
@@ -2046,10 +2067,9 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
UINT32 frames, BYTE **data)
{
ACImpl *This = impl_from_IAudioRenderClient(iface);
@ -571,7 +602,7 @@ index f192b1d..0039c34 100644
TRACE("(%p)->(%u, %p)\n", This, frames, data);
@@ -2068,37 +2082,19 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
@@ -2068,37 +2088,19 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
return S_OK;
}
@ -617,7 +648,7 @@ index f192b1d..0039c34 100644
}
silence_buffer(This->ss.format, *data, bytes);
@@ -2110,111 +2106,59 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
@@ -2110,111 +2112,59 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
static void pulse_wrap_buffer(ACImpl *This, BYTE *buffer, UINT32 written_bytes)
{
@ -749,7 +780,7 @@ index f192b1d..0039c34 100644
return S_OK;
}
@@ -2286,13 +2230,13 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
@@ -2286,13 +2236,13 @@ static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
ACImpl_GetCapturePad(This, NULL);
if ((packet = This->locked_ptr)) {
@ -765,7 +796,7 @@ index f192b1d..0039c34 100644
else
*devpos = This->clock_written / pa_frame_size(&This->ss);
}
@@ -2326,11 +2270,11 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
@@ -2326,11 +2276,11 @@ static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
if (done) {
ACPacket *packet = This->locked_ptr;
This->locked_ptr = NULL;
@ -780,7 +811,7 @@ index f192b1d..0039c34 100644
list_add_tail(&This->packet_free_head, &packet->entry);
}
This->locked = 0;
@@ -2350,7 +2294,7 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
@@ -2350,7 +2300,7 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
pthread_mutex_lock(&pulse_lock);
ACImpl_GetCapturePad(This, NULL);
if (This->locked_ptr)
@ -789,7 +820,7 @@ index f192b1d..0039c34 100644
else
*frames = 0;
pthread_mutex_unlock(&pulse_lock);
@@ -2442,7 +2386,14 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
@@ -2442,7 +2392,14 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
return hr;
}