Imported winepulse patches and updated patch-list.patch

This commit is contained in:
Sebastian Lackner
2013-12-06 21:09:21 +01:00
parent 25bf8fbc02
commit 7398e80556
29 changed files with 5232 additions and 2 deletions

View File

@@ -0,0 +1,29 @@
From 39ad530e3367082d908738de82cc786fea804308 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Fri, 22 Nov 2013 21:29:57 +0100
Subject: [PATCH 08/42] winmm: Load winealsa if winepulse is found
Fixes midi on winepulse
---
dlls/winmm/lolvldrv.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c
index f387323..3b1be27 100644
--- a/dlls/winmm/lolvldrv.c
+++ b/dlls/winmm/lolvldrv.c
@@ -543,7 +543,10 @@ static void MMDRV_Init(void)
drvA = HeapAlloc(GetProcessHeap(), 0, size);
WideCharToMultiByte(CP_ACP, 0, pv.u.pwszVal, -1, drvA, size, NULL, NULL);
- MMDRV_Install(drvA, drvA, FALSE);
+ if (!strcasecmp(drvA, "winepulse.drv"))
+ MMDRV_Install("winealsa.drv", "winealsa.drv", 0);
+ else
+ MMDRV_Install(drvA, drvA, FALSE);
HeapFree(GetProcessHeap(), 0, drvA);
PropVariantClear(&pv);
--
1.8.4.4

View File

@@ -0,0 +1,172 @@
From 8dd6c030b4487907c24b6b98cc0b88c7bb15e953 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:57 +0100
Subject: [PATCH 10/42] winepulse: Add format and period probing
---
dlls/winepulse.drv/mmdevdrv.c | 128 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 128 insertions(+)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index d187bdc..40db26d 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -70,6 +70,10 @@ static HANDLE pulse_thread;
static pthread_mutex_t pulse_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t pulse_cond = PTHREAD_COND_INITIALIZER;
+/* Mixer format + period times */
+static WAVEFORMATEXTENSIBLE pulse_fmt[2];
+static REFERENCE_TIME pulse_min_period[2], pulse_def_period[2];
+
static DWORD pulse_stream_volume;
const WCHAR pulse_keyW[] = {'S','o','f','t','w','a','r','e','\\',
@@ -139,6 +143,121 @@ static DWORD CALLBACK pulse_mainloop_thread(void *tmp) {
}
static void pulse_contextcallback(pa_context *c, void *userdata);
+static void pulse_stream_state(pa_stream *s, void *user);
+
+static const enum pa_channel_position pulse_pos_from_wfx[] = {
+ PA_CHANNEL_POSITION_FRONT_LEFT,
+ PA_CHANNEL_POSITION_FRONT_RIGHT,
+ PA_CHANNEL_POSITION_FRONT_CENTER,
+ PA_CHANNEL_POSITION_LFE,
+ PA_CHANNEL_POSITION_REAR_LEFT,
+ PA_CHANNEL_POSITION_REAR_RIGHT,
+ PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER,
+ PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER,
+ PA_CHANNEL_POSITION_REAR_CENTER,
+ PA_CHANNEL_POSITION_SIDE_LEFT,
+ PA_CHANNEL_POSITION_SIDE_RIGHT,
+ PA_CHANNEL_POSITION_TOP_CENTER,
+ PA_CHANNEL_POSITION_TOP_FRONT_LEFT,
+ PA_CHANNEL_POSITION_TOP_FRONT_CENTER,
+ PA_CHANNEL_POSITION_TOP_FRONT_RIGHT,
+ PA_CHANNEL_POSITION_TOP_REAR_LEFT,
+ PA_CHANNEL_POSITION_TOP_REAR_CENTER,
+ PA_CHANNEL_POSITION_TOP_REAR_RIGHT
+};
+
+static void pulse_probe_settings(int render, WAVEFORMATEXTENSIBLE *fmt) {
+ WAVEFORMATEX *wfx = &fmt->Format;
+ pa_stream *stream;
+ pa_channel_map map;
+ pa_sample_spec ss;
+ pa_buffer_attr attr;
+ int ret, i;
+ unsigned int length = 0;
+
+ pa_channel_map_init_auto(&map, 2, PA_CHANNEL_MAP_ALSA);
+ ss.rate = 48000;
+ ss.format = PA_SAMPLE_FLOAT32LE;
+ ss.channels = map.channels;
+
+ attr.maxlength = -1;
+ attr.tlength = -1;
+ attr.minreq = attr.fragsize = pa_frame_size(&ss);
+ attr.prebuf = 0;
+
+ stream = pa_stream_new(pulse_ctx, "format test stream", &ss, &map);
+ if (stream)
+ pa_stream_set_state_callback(stream, pulse_stream_state, NULL);
+ if (!stream)
+ ret = -1;
+ else if (render)
+ ret = pa_stream_connect_playback(stream, NULL, &attr,
+ PA_STREAM_START_CORKED|PA_STREAM_FIX_RATE|PA_STREAM_FIX_CHANNELS|PA_STREAM_EARLY_REQUESTS, NULL, NULL);
+ else
+ ret = pa_stream_connect_record(stream, NULL, &attr, PA_STREAM_START_CORKED|PA_STREAM_FIX_RATE|PA_STREAM_FIX_CHANNELS|PA_STREAM_EARLY_REQUESTS);
+ if (ret >= 0) {
+ while (pa_stream_get_state(stream) == PA_STREAM_CREATING)
+ pthread_cond_wait(&pulse_cond, &pulse_lock);
+ if (pa_stream_get_state(stream) == PA_STREAM_READY) {
+ ss = *pa_stream_get_sample_spec(stream);
+ map = *pa_stream_get_channel_map(stream);
+ if (render)
+ length = pa_stream_get_buffer_attr(stream)->minreq;
+ else
+ length = pa_stream_get_buffer_attr(stream)->fragsize;
+ pa_stream_disconnect(stream);
+ while (pa_stream_get_state(stream) == PA_STREAM_READY)
+ pthread_cond_wait(&pulse_cond, &pulse_lock);
+ }
+ }
+ if (stream)
+ pa_stream_unref(stream);
+ if (length)
+ pulse_def_period[!render] = pulse_min_period[!render] = pa_bytes_to_usec(10 * length, &ss);
+ else
+ pulse_min_period[!render] = MinimumPeriod;
+ if (pulse_def_period[!render] <= DefaultPeriod)
+ pulse_def_period[!render] = DefaultPeriod;
+
+ wfx->wFormatTag = WAVE_FORMAT_EXTENSIBLE;
+ wfx->cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
+ wfx->nChannels = ss.channels;
+ wfx->wBitsPerSample = 8 * pa_sample_size_of_format(ss.format);
+ wfx->nSamplesPerSec = ss.rate;
+ wfx->nBlockAlign = pa_frame_size(&ss);
+ wfx->nAvgBytesPerSec = wfx->nSamplesPerSec * wfx->nBlockAlign;
+ if (ss.format != PA_SAMPLE_S24_32LE)
+ fmt->Samples.wValidBitsPerSample = wfx->wBitsPerSample;
+ else
+ fmt->Samples.wValidBitsPerSample = 24;
+ if (ss.format == PA_SAMPLE_FLOAT32LE)
+ fmt->SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
+ else
+ fmt->SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
+
+ fmt->dwChannelMask = 0;
+ for (i = 0; i < map.channels; ++i)
+ switch (map.map[i]) {
+ default: FIXME("Unhandled channel %s\n", pa_channel_position_to_string(map.map[i])); break;
+ case PA_CHANNEL_POSITION_FRONT_LEFT: fmt->dwChannelMask |= SPEAKER_FRONT_LEFT; break;
+ case PA_CHANNEL_POSITION_MONO:
+ case PA_CHANNEL_POSITION_FRONT_CENTER: fmt->dwChannelMask |= SPEAKER_FRONT_CENTER; break;
+ case PA_CHANNEL_POSITION_FRONT_RIGHT: fmt->dwChannelMask |= SPEAKER_FRONT_RIGHT; break;
+ case PA_CHANNEL_POSITION_REAR_LEFT: fmt->dwChannelMask |= SPEAKER_BACK_LEFT; break;
+ case PA_CHANNEL_POSITION_REAR_CENTER: fmt->dwChannelMask |= SPEAKER_BACK_CENTER; break;
+ case PA_CHANNEL_POSITION_REAR_RIGHT: fmt->dwChannelMask |= SPEAKER_BACK_RIGHT; break;
+ case PA_CHANNEL_POSITION_LFE: fmt->dwChannelMask |= SPEAKER_LOW_FREQUENCY; break;
+ case PA_CHANNEL_POSITION_SIDE_LEFT: fmt->dwChannelMask |= SPEAKER_SIDE_LEFT; break;
+ case PA_CHANNEL_POSITION_SIDE_RIGHT: fmt->dwChannelMask |= SPEAKER_SIDE_RIGHT; break;
+ case PA_CHANNEL_POSITION_TOP_CENTER: fmt->dwChannelMask |= SPEAKER_TOP_CENTER; break;
+ case PA_CHANNEL_POSITION_TOP_FRONT_LEFT: fmt->dwChannelMask |= SPEAKER_TOP_FRONT_LEFT; break;
+ case PA_CHANNEL_POSITION_TOP_FRONT_CENTER: fmt->dwChannelMask |= SPEAKER_TOP_FRONT_CENTER; break;
+ case PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: fmt->dwChannelMask |= SPEAKER_TOP_FRONT_RIGHT; break;
+ case PA_CHANNEL_POSITION_TOP_REAR_LEFT: fmt->dwChannelMask |= SPEAKER_TOP_BACK_LEFT; break;
+ case PA_CHANNEL_POSITION_TOP_REAR_CENTER: fmt->dwChannelMask |= SPEAKER_TOP_BACK_CENTER; break;
+ case PA_CHANNEL_POSITION_TOP_REAR_RIGHT: fmt->dwChannelMask |= SPEAKER_TOP_BACK_RIGHT; break;
+ }
+}
static HRESULT pulse_connect(void)
{
@@ -199,6 +318,8 @@ static HRESULT pulse_connect(void)
TRACE("Connected to server %s with protocol version: %i.\n",
pa_context_get_server(pulse_ctx),
pa_context_get_server_protocol_version(pulse_ctx));
+ pulse_probe_settings(1, &pulse_fmt[0]);
+ pulse_probe_settings(0, &pulse_fmt[1]);
return S_OK;
fail:
@@ -230,6 +351,13 @@ static void pulse_contextcallback(pa_context *c, void *userdata) {
pthread_cond_signal(&pulse_cond);
}
+static void pulse_stream_state(pa_stream *s, void *user)
+{
+ pa_stream_state_t state = pa_stream_get_state(s);
+ TRACE("Stream state changed to %i\n", state);
+ pthread_cond_signal(&pulse_cond);
+}
+
HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
UINT *num, UINT *def_index)
{
--
1.8.4.4

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,352 @@
From 24e5a426ff9493945ff2c834375a57f688f0356b Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:57 +0100
Subject: [PATCH 12/42] winepulse: Add IAudioRenderClient and
IAudioCaptureClient
---
dlls/winepulse.drv/mmdevdrv.c | 301 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 301 insertions(+)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 37d85ff..01cfd25 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -146,12 +146,27 @@ struct ACImpl {
static const WCHAR defaultW[] = {'P','u','l','s','e','a','u','d','i','o',0};
static const IAudioClientVtbl AudioClient_Vtbl;
+static const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
+static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
+static const IAudioClockVtbl AudioClock_Vtbl;
+static const IAudioClock2Vtbl AudioClock2_Vtbl;
+static const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl;
static inline ACImpl *impl_from_IAudioClient(IAudioClient *iface)
{
return CONTAINING_RECORD(iface, ACImpl, IAudioClient_iface);
}
+static inline ACImpl *impl_from_IAudioRenderClient(IAudioRenderClient *iface)
+{
+ return CONTAINING_RECORD(iface, ACImpl, IAudioRenderClient_iface);
+}
+
+static inline ACImpl *impl_from_IAudioCaptureClient(IAudioCaptureClient *iface)
+{
+ return CONTAINING_RECORD(iface, ACImpl, IAudioCaptureClient_iface);
+}
+
/* Following pulseaudio design here, mainloop has the lock taken whenever
* it is handling something for pulse, and the lock is required whenever
* doing any pa_* call that can affect the state in any way
@@ -701,6 +716,11 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(void *key, IMMDevice *dev,
return E_OUTOFMEMORY;
This->IAudioClient_iface.lpVtbl = &AudioClient_Vtbl;
+ This->IAudioRenderClient_iface.lpVtbl = &AudioRenderClient_Vtbl;
+ This->IAudioCaptureClient_iface.lpVtbl = &AudioCaptureClient_Vtbl;
+ This->IAudioClock_iface.lpVtbl = &AudioClock_Vtbl;
+ This->IAudioClock2_iface.lpVtbl = &AudioClock2_Vtbl;
+ This->IAudioStreamVolume_iface.lpVtbl = &AudioStreamVolume_Vtbl;
This->dataflow = dataflow;
This->parent = dev;
This->clock_pulse = PA_USEC_INVALID;
@@ -1421,6 +1441,16 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient *iface, REFIID riid,
if (FAILED(hr))
return hr;
+ if (IsEqualIID(riid, &IID_IAudioRenderClient)) {
+ if (This->dataflow != eRender)
+ return AUDCLNT_E_WRONG_ENDPOINT_TYPE;
+ *ppv = &This->IAudioRenderClient_iface;
+ } else if (IsEqualIID(riid, &IID_IAudioCaptureClient)) {
+ if (This->dataflow != eCapture)
+ return AUDCLNT_E_WRONG_ENDPOINT_TYPE;
+ *ppv = &This->IAudioCaptureClient_iface;
+ }
+
if (*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
@@ -1449,6 +1479,277 @@ static const IAudioClientVtbl AudioClient_Vtbl =
AudioClient_GetService
};
+static HRESULT WINAPI AudioRenderClient_QueryInterface(
+ IAudioRenderClient *iface, REFIID riid, void **ppv)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
+
+ if (!ppv)
+ return E_POINTER;
+ *ppv = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IAudioRenderClient))
+ *ppv = iface;
+ if (*ppv) {
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
+ }
+
+ WARN("Unknown interface %s\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI AudioRenderClient_AddRef(IAudioRenderClient *iface)
+{
+ ACImpl *This = impl_from_IAudioRenderClient(iface);
+ return AudioClient_AddRef(&This->IAudioClient_iface);
+}
+
+static ULONG WINAPI AudioRenderClient_Release(IAudioRenderClient *iface)
+{
+ ACImpl *This = impl_from_IAudioRenderClient(iface);
+ return AudioClient_Release(&This->IAudioClient_iface);
+}
+
+static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
+ UINT32 frames, BYTE **data)
+{
+ ACImpl *This = impl_from_IAudioRenderClient(iface);
+ UINT32 avail, pad, req, bytes = frames * pa_frame_size(&This->ss);
+ HRESULT hr = S_OK;
+ int ret = -1;
+
+ TRACE("(%p)->(%u, %p)\n", This, frames, data);
+
+ if (!data)
+ return E_POINTER;
+ *data = NULL;
+
+ pthread_mutex_lock(&pulse_lock);
+ hr = pulse_stream_valid(This);
+ if (FAILED(hr) || This->locked) {
+ pthread_mutex_unlock(&pulse_lock);
+ return FAILED(hr) ? hr : AUDCLNT_E_OUT_OF_ORDER;
+ }
+ if (!frames) {
+ pthread_mutex_unlock(&pulse_lock);
+ return S_OK;
+ }
+
+ ACImpl_GetRenderPad(This, &pad);
+ avail = This->bufsize_frames - pad;
+ if (avail < frames || bytes > This->bufsize_bytes) {
+ pthread_mutex_unlock(&pulse_lock);
+ WARN("Wanted to write %u, but only %u available\n", frames, avail);
+ return AUDCLNT_E_BUFFER_TOO_LARGE;
+ }
+
+ This->locked = frames;
+ req = bytes;
+ ret = pa_stream_begin_write(This->stream, &This->locked_ptr, &req);
+ if (ret < 0 || req < bytes) {
+ FIXME("%p Not using pulse locked data: %i %u/%u %u/%u\n", This, ret, req/pa_frame_size(&This->ss), frames, pad, This->bufsize_frames);
+ if (ret >= 0)
+ pa_stream_cancel_write(This->stream);
+ *data = This->tmp_buffer;
+ This->locked_ptr = NULL;
+ } else
+ *data = This->locked_ptr;
+ pthread_mutex_unlock(&pulse_lock);
+ return hr;
+}
+
+static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
+ IAudioRenderClient *iface, UINT32 written_frames, DWORD flags)
+{
+ ACImpl *This = impl_from_IAudioRenderClient(iface);
+ UINT32 written_bytes = written_frames * pa_frame_size(&This->ss);
+
+ TRACE("(%p)->(%u, %x)\n", This, written_frames, flags);
+
+ pthread_mutex_lock(&pulse_lock);
+ if (!This->locked || !written_frames) {
+ if (This->locked_ptr)
+ pa_stream_cancel_write(This->stream);
+ This->locked = 0;
+ This->locked_ptr = NULL;
+ pthread_mutex_unlock(&pulse_lock);
+ return written_frames ? AUDCLNT_E_OUT_OF_ORDER : S_OK;
+ }
+
+ if (This->locked < written_frames) {
+ pthread_mutex_unlock(&pulse_lock);
+ return AUDCLNT_E_INVALID_SIZE;
+ }
+
+ if (flags & AUDCLNT_BUFFERFLAGS_SILENT) {
+ if (This->ss.format == PA_SAMPLE_U8)
+ memset(This->tmp_buffer, 128, written_bytes);
+ else
+ memset(This->tmp_buffer, 0, written_bytes);
+ }
+
+ This->locked = 0;
+ if (This->locked_ptr)
+ pa_stream_write(This->stream, This->locked_ptr, written_bytes, NULL, 0, PA_SEEK_RELATIVE);
+ else
+ pa_stream_write(This->stream, This->tmp_buffer, written_bytes, NULL, 0, PA_SEEK_RELATIVE);
+ This->pad += written_bytes;
+ This->locked_ptr = NULL;
+ TRACE("Released %u, pad %u\n", written_frames, This->pad / pa_frame_size(&This->ss));
+ assert(This->pad <= This->bufsize_bytes);
+ pthread_mutex_unlock(&pulse_lock);
+ return S_OK;
+}
+
+static const IAudioRenderClientVtbl AudioRenderClient_Vtbl = {
+ AudioRenderClient_QueryInterface,
+ AudioRenderClient_AddRef,
+ AudioRenderClient_Release,
+ AudioRenderClient_GetBuffer,
+ AudioRenderClient_ReleaseBuffer
+};
+
+static HRESULT WINAPI AudioCaptureClient_QueryInterface(
+ IAudioCaptureClient *iface, REFIID riid, void **ppv)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
+
+ if (!ppv)
+ return E_POINTER;
+ *ppv = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IAudioCaptureClient))
+ *ppv = iface;
+ if (*ppv) {
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
+ }
+
+ WARN("Unknown interface %s\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI AudioCaptureClient_AddRef(IAudioCaptureClient *iface)
+{
+ ACImpl *This = impl_from_IAudioCaptureClient(iface);
+ return IAudioClient_AddRef(&This->IAudioClient_iface);
+}
+
+static ULONG WINAPI AudioCaptureClient_Release(IAudioCaptureClient *iface)
+{
+ ACImpl *This = impl_from_IAudioCaptureClient(iface);
+ return IAudioClient_Release(&This->IAudioClient_iface);
+}
+
+static HRESULT WINAPI AudioCaptureClient_GetBuffer(IAudioCaptureClient *iface,
+ BYTE **data, UINT32 *frames, DWORD *flags, UINT64 *devpos,
+ UINT64 *qpcpos)
+{
+ ACImpl *This = impl_from_IAudioCaptureClient(iface);
+ HRESULT hr;
+ ACPacket *packet;
+
+ TRACE("(%p)->(%p, %p, %p, %p, %p)\n", This, data, frames, flags,
+ devpos, qpcpos);
+
+ if (!data || !frames || !flags)
+ return E_POINTER;
+
+ pthread_mutex_lock(&pulse_lock);
+ hr = pulse_stream_valid(This);
+ if (FAILED(hr) || This->locked) {
+ pthread_mutex_unlock(&pulse_lock);
+ return FAILED(hr) ? hr : AUDCLNT_E_OUT_OF_ORDER;
+ }
+
+ ACImpl_GetCapturePad(This, NULL);
+ if ((packet = This->locked_ptr)) {
+ *frames = This->capture_period / pa_frame_size(&This->ss);
+ *flags = 0;
+ if (packet->discont)
+ *flags |= AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY;
+ if (devpos) {
+ if (packet->discont)
+ *devpos = (This->clock_written + This->capture_period) / pa_frame_size(&This->ss);
+ else
+ *devpos = This->clock_written / pa_frame_size(&This->ss);
+ }
+ if (qpcpos)
+ *qpcpos = packet->qpcpos;
+ *data = packet->data;
+ }
+ else
+ *frames = 0;
+ This->locked = *frames;
+ pthread_mutex_unlock(&pulse_lock);
+ return *frames ? S_OK : AUDCLNT_S_BUFFER_EMPTY;
+}
+
+static HRESULT WINAPI AudioCaptureClient_ReleaseBuffer(
+ IAudioCaptureClient *iface, UINT32 done)
+{
+ ACImpl *This = impl_from_IAudioCaptureClient(iface);
+
+ TRACE("(%p)->(%u)\n", This, done);
+
+ pthread_mutex_lock(&pulse_lock);
+ if (!This->locked && done) {
+ pthread_mutex_unlock(&pulse_lock);
+ return AUDCLNT_E_OUT_OF_ORDER;
+ }
+ if (done && This->locked != done) {
+ pthread_mutex_unlock(&pulse_lock);
+ return AUDCLNT_E_INVALID_SIZE;
+ }
+ if (done) {
+ ACPacket *packet = This->locked_ptr;
+ This->locked_ptr = NULL;
+ This->pad -= This->capture_period;
+ if (packet->discont)
+ This->clock_written += 2 * This->capture_period;
+ else
+ This->clock_written += This->capture_period;
+ list_add_tail(&This->packet_free_head, &packet->entry);
+ }
+ This->locked = 0;
+ pthread_mutex_unlock(&pulse_lock);
+ return S_OK;
+}
+
+static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
+ IAudioCaptureClient *iface, UINT32 *frames)
+{
+ ACImpl *This = impl_from_IAudioCaptureClient(iface);
+ ACPacket *p;
+
+ TRACE("(%p)->(%p)\n", This, frames);
+ if (!frames)
+ return E_POINTER;
+
+ pthread_mutex_lock(&pulse_lock);
+ ACImpl_GetCapturePad(This, NULL);
+ p = This->locked_ptr;
+ if (p)
+ *frames = This->capture_period / pa_frame_size(&This->ss);
+ else
+ *frames = 0;
+ pthread_mutex_unlock(&pulse_lock);
+ return S_OK;
+}
+
+static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl =
+{
+ AudioCaptureClient_QueryInterface,
+ AudioCaptureClient_AddRef,
+ AudioCaptureClient_Release,
+ AudioCaptureClient_GetBuffer,
+ AudioCaptureClient_ReleaseBuffer,
+ AudioCaptureClient_GetNextPacketSize
+};
+
HRESULT WINAPI AUDDRV_GetAudioSessionManager(IMMDevice *device,
IAudioSessionManager2 **out)
{
--
1.8.4.4

View File

@@ -0,0 +1,209 @@
From fa8bdbe20707458b7b43f9afc2d93adaadc833be Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:57 +0100
Subject: [PATCH 13/42] winepulse: Add IAudioClock and IAudioClock2
---
dlls/winepulse.drv/mmdevdrv.c | 172 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 172 insertions(+)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 01cfd25..3ed2288 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -167,6 +167,16 @@ static inline ACImpl *impl_from_IAudioCaptureClient(IAudioCaptureClient *iface)
return CONTAINING_RECORD(iface, ACImpl, IAudioCaptureClient_iface);
}
+static inline ACImpl *impl_from_IAudioClock(IAudioClock *iface)
+{
+ return CONTAINING_RECORD(iface, ACImpl, IAudioClock_iface);
+}
+
+static inline ACImpl *impl_from_IAudioClock2(IAudioClock2 *iface)
+{
+ return CONTAINING_RECORD(iface, ACImpl, IAudioClock2_iface);
+}
+
/* Following pulseaudio design here, mainloop has the lock taken whenever
* it is handling something for pulse, and the lock is required whenever
* doing any pa_* call that can affect the state in any way
@@ -1449,6 +1459,8 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient *iface, REFIID riid,
if (This->dataflow != eCapture)
return AUDCLNT_E_WRONG_ENDPOINT_TYPE;
*ppv = &This->IAudioCaptureClient_iface;
+ } else if (IsEqualIID(riid, &IID_IAudioClock)) {
+ *ppv = &This->IAudioClock_iface;
}
if (*ppv) {
@@ -1750,6 +1762,166 @@ static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl =
AudioCaptureClient_GetNextPacketSize
};
+static HRESULT WINAPI AudioClock_QueryInterface(IAudioClock *iface,
+ REFIID riid, void **ppv)
+{
+ ACImpl *This = impl_from_IAudioClock(iface);
+
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
+
+ if (!ppv)
+ return E_POINTER;
+ *ppv = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IAudioClock))
+ *ppv = iface;
+ else if (IsEqualIID(riid, &IID_IAudioClock2))
+ *ppv = &This->IAudioClock2_iface;
+ if (*ppv) {
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
+ }
+
+ WARN("Unknown interface %s\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI AudioClock_AddRef(IAudioClock *iface)
+{
+ ACImpl *This = impl_from_IAudioClock(iface);
+ return IAudioClient_AddRef(&This->IAudioClient_iface);
+}
+
+static ULONG WINAPI AudioClock_Release(IAudioClock *iface)
+{
+ ACImpl *This = impl_from_IAudioClock(iface);
+ return IAudioClient_Release(&This->IAudioClient_iface);
+}
+
+static HRESULT WINAPI AudioClock_GetFrequency(IAudioClock *iface, UINT64 *freq)
+{
+ ACImpl *This = impl_from_IAudioClock(iface);
+ HRESULT hr;
+
+ TRACE("(%p)->(%p)\n", This, freq);
+
+ pthread_mutex_lock(&pulse_lock);
+ hr = pulse_stream_valid(This);
+ if (SUCCEEDED(hr))
+ *freq = This->ss.rate * pa_frame_size(&This->ss);
+ pthread_mutex_unlock(&pulse_lock);
+ return hr;
+}
+
+static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
+ UINT64 *qpctime)
+{
+ ACImpl *This = impl_from_IAudioClock(iface);
+ pa_usec_t time;
+ HRESULT hr;
+
+ TRACE("(%p)->(%p, %p)\n", This, pos, qpctime);
+
+ if (!pos)
+ return E_POINTER;
+
+ pthread_mutex_lock(&pulse_lock);
+ hr = pulse_stream_valid(This);
+ if (FAILED(hr)) {
+ pthread_mutex_unlock(&pulse_lock);
+ return hr;
+ }
+
+ *pos = This->clock_written;
+ if (This->clock_pulse != PA_USEC_INVALID && pa_stream_get_time(This->stream, &time) >= 0) {
+ UINT32 delta = pa_usec_to_bytes(time - This->clock_pulse, &This->ss);
+ if (delta < This->pad)
+ *pos += delta;
+ else
+ *pos += This->pad;
+ }
+
+ /* Make time never go backwards */
+ if (*pos < This->clock_lastpos)
+ *pos = This->clock_lastpos;
+ else
+ This->clock_lastpos = *pos;
+ pthread_mutex_unlock(&pulse_lock);
+
+ TRACE("%p Position: %u\n", This, (unsigned)*pos);
+
+ if (qpctime) {
+ LARGE_INTEGER stamp, freq;
+ QueryPerformanceCounter(&stamp);
+ QueryPerformanceFrequency(&freq);
+ *qpctime = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
+ }
+
+ return S_OK;
+}
+
+static HRESULT WINAPI AudioClock_GetCharacteristics(IAudioClock *iface,
+ DWORD *chars)
+{
+ ACImpl *This = impl_from_IAudioClock(iface);
+
+ TRACE("(%p)->(%p)\n", This, chars);
+
+ if (!chars)
+ return E_POINTER;
+
+ *chars = AUDIOCLOCK_CHARACTERISTIC_FIXED_FREQ;
+
+ return S_OK;
+}
+
+static const IAudioClockVtbl AudioClock_Vtbl =
+{
+ AudioClock_QueryInterface,
+ AudioClock_AddRef,
+ AudioClock_Release,
+ AudioClock_GetFrequency,
+ AudioClock_GetPosition,
+ AudioClock_GetCharacteristics
+};
+
+static HRESULT WINAPI AudioClock2_QueryInterface(IAudioClock2 *iface,
+ REFIID riid, void **ppv)
+{
+ ACImpl *This = impl_from_IAudioClock2(iface);
+ return IAudioClock_QueryInterface(&This->IAudioClock_iface, riid, ppv);
+}
+
+static ULONG WINAPI AudioClock2_AddRef(IAudioClock2 *iface)
+{
+ ACImpl *This = impl_from_IAudioClock2(iface);
+ return IAudioClient_AddRef(&This->IAudioClient_iface);
+}
+
+static ULONG WINAPI AudioClock2_Release(IAudioClock2 *iface)
+{
+ ACImpl *This = impl_from_IAudioClock2(iface);
+ return IAudioClient_Release(&This->IAudioClient_iface);
+}
+
+static HRESULT WINAPI AudioClock2_GetDevicePosition(IAudioClock2 *iface,
+ UINT64 *pos, UINT64 *qpctime)
+{
+ ACImpl *This = impl_from_IAudioClock2(iface);
+ HRESULT hr = AudioClock_GetPosition(&This->IAudioClock_iface, pos, qpctime);
+ if (SUCCEEDED(hr))
+ *pos /= pa_frame_size(&This->ss);
+ return hr;
+}
+
+static const IAudioClock2Vtbl AudioClock2_Vtbl =
+{
+ AudioClock2_QueryInterface,
+ AudioClock2_AddRef,
+ AudioClock2_Release,
+ AudioClock2_GetDevicePosition
+};
+
HRESULT WINAPI AUDDRV_GetAudioSessionManager(IMMDevice *device,
IAudioSessionManager2 **out)
{
--
1.8.4.4

View File

@@ -0,0 +1,285 @@
From 3b427a167037eec4e3f6b0be941c11795235c635 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:57 +0100
Subject: [PATCH 14/42] winepulse: Add audiostreamvolume
---
Pulse allows streams to set volume, but for various reasons it's
better off being disabled by default.
It can be enabled with HKCU\Software\Wine\Pulse\StreamVol=0x1
---
dlls/winepulse.drv/mmdevdrv.c | 236 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 236 insertions(+)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 3ed2288..b7414c2 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -177,6 +177,11 @@ static inline ACImpl *impl_from_IAudioClock2(IAudioClock2 *iface)
return CONTAINING_RECORD(iface, ACImpl, IAudioClock2_iface);
}
+static inline ACImpl *impl_from_IAudioStreamVolume(IAudioStreamVolume *iface)
+{
+ return CONTAINING_RECORD(iface, ACImpl, IAudioStreamVolume_iface);
+}
+
/* Following pulseaudio design here, mainloop has the lock taken whenever
* it is handling something for pulse, and the lock is required whenever
* doing any pa_* call that can affect the state in any way
@@ -444,6 +449,12 @@ static void pulse_op_cb(pa_stream *s, int success, void *user) {
pthread_cond_signal(&pulse_cond);
}
+static void pulse_ctx_op_cb(pa_context *c, int success, void *user) {
+ TRACE("Success: %i\n", success);
+ *(int*)user = success;
+ pthread_cond_signal(&pulse_cond);
+}
+
static void pulse_attr_update(pa_stream *s, void *user) {
const pa_buffer_attr *attr = pa_stream_get_buffer_attr(s);
TRACE("New attributes or device moved:\n");
@@ -1461,6 +1472,8 @@ static HRESULT WINAPI AudioClient_GetService(IAudioClient *iface, REFIID riid,
*ppv = &This->IAudioCaptureClient_iface;
} else if (IsEqualIID(riid, &IID_IAudioClock)) {
*ppv = &This->IAudioClock_iface;
+ } else if (IsEqualIID(riid, &IID_IAudioStreamVolume)) {
+ *ppv = &This->IAudioStreamVolume_iface;
}
if (*ppv) {
@@ -1922,6 +1935,229 @@ static const IAudioClock2Vtbl AudioClock2_Vtbl =
AudioClock2_GetDevicePosition
};
+static HRESULT WINAPI AudioStreamVolume_QueryInterface(
+ IAudioStreamVolume *iface, REFIID riid, void **ppv)
+{
+ TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
+
+ if (!ppv)
+ return E_POINTER;
+ *ppv = NULL;
+
+ if (IsEqualIID(riid, &IID_IUnknown) ||
+ IsEqualIID(riid, &IID_IAudioStreamVolume))
+ *ppv = iface;
+ if (*ppv) {
+ IUnknown_AddRef((IUnknown*)*ppv);
+ return S_OK;
+ }
+
+ WARN("Unknown interface %s\n", debugstr_guid(riid));
+ return E_NOINTERFACE;
+}
+
+static ULONG WINAPI AudioStreamVolume_AddRef(IAudioStreamVolume *iface)
+{
+ ACImpl *This = impl_from_IAudioStreamVolume(iface);
+ return IAudioClient_AddRef(&This->IAudioClient_iface);
+}
+
+static ULONG WINAPI AudioStreamVolume_Release(IAudioStreamVolume *iface)
+{
+ ACImpl *This = impl_from_IAudioStreamVolume(iface);
+ return IAudioClient_Release(&This->IAudioClient_iface);
+}
+
+static HRESULT WINAPI AudioStreamVolume_GetChannelCount(
+ IAudioStreamVolume *iface, UINT32 *out)
+{
+ ACImpl *This = impl_from_IAudioStreamVolume(iface);
+
+ TRACE("(%p)->(%p)\n", This, out);
+
+ if (!out)
+ return E_POINTER;
+
+ *out = This->ss.channels;
+
+ return S_OK;
+}
+
+struct pulse_info_cb_data {
+ UINT32 n;
+ float *levels;
+};
+
+static void pulse_sink_input_info_cb(pa_context *c, const pa_sink_input_info *info, int eol, void *data)
+{
+ struct pulse_info_cb_data *d = data;
+ int i;
+ if (eol)
+ return;
+ for (i = 0; i < d->n; ++i)
+ d->levels[i] = (float)info->volume.values[i] / (float)PA_VOLUME_NORM;
+ pthread_cond_signal(&pulse_cond);
+}
+
+static void pulse_source_info_cb(pa_context *c, const pa_source_info *info, int eol, void *data)
+{
+ struct pulse_info_cb_data *d = data;
+ int i;
+ if (eol)
+ return;
+ for (i = 0; i < d->n; ++i)
+ d->levels[i] = (float)info->volume.values[i] / (float)PA_VOLUME_NORM;
+ pthread_cond_signal(&pulse_cond);
+}
+
+static HRESULT WINAPI AudioStreamVolume_SetAllVolumes(
+ IAudioStreamVolume *iface, UINT32 count, const float *levels)
+{
+ ACImpl *This = impl_from_IAudioStreamVolume(iface);
+ pa_operation *o;
+ HRESULT hr;
+ int success = 0, i;
+ pa_cvolume cv;
+
+ TRACE("(%p)->(%d, %p)\n", This, count, levels);
+
+ if (!levels)
+ return E_POINTER;
+
+ if (count != This->ss.channels)
+ return E_INVALIDARG;
+
+ pthread_mutex_lock(&pulse_lock);
+ hr = pulse_stream_valid(This);
+ if (FAILED(hr))
+ goto out;
+
+ if (pulse_stream_volume) {
+ cv.channels = count;
+ for (i = 0; i < cv.channels; ++i)
+ cv.values[i] = levels[i] * (float)PA_VOLUME_NORM;
+ if (This->dataflow == eRender)
+ o = pa_context_set_sink_input_volume(pulse_ctx, pa_stream_get_index(This->stream), &cv, pulse_ctx_op_cb, &success);
+ else
+ o = pa_context_set_source_volume_by_index(pulse_ctx, pa_stream_get_device_index(This->stream), &cv, pulse_ctx_op_cb, &success);
+ if (o) {
+ while(pa_operation_get_state(o) == PA_OPERATION_RUNNING)
+ pthread_cond_wait(&pulse_cond, &pulse_lock);
+ pa_operation_unref(o);
+ }
+ if (!success)
+ hr = AUDCLNT_E_BUFFER_ERROR;
+ } else {
+ int i;
+ for (i = 0; i < count; ++i)
+ This->vol[i] = levels[i];
+ }
+
+out:
+ pthread_mutex_unlock(&pulse_lock);
+ return hr;
+}
+
+static HRESULT WINAPI AudioStreamVolume_GetAllVolumes(
+ IAudioStreamVolume *iface, UINT32 count, float *levels)
+{
+ ACImpl *This = impl_from_IAudioStreamVolume(iface);
+ pa_operation *o;
+ HRESULT hr;
+ struct pulse_info_cb_data info;
+
+ TRACE("(%p)->(%d, %p)\n", This, count, levels);
+
+ if (!levels)
+ return E_POINTER;
+
+ if (count != This->ss.channels)
+ return E_INVALIDARG;
+
+ pthread_mutex_lock(&pulse_lock);
+ hr = pulse_stream_valid(This);
+ if (FAILED(hr))
+ goto out;
+
+ if (pulse_stream_volume) {
+ info.n = count;
+ info.levels = levels;
+ if (This->dataflow == eRender)
+ o = pa_context_get_sink_input_info(pulse_ctx, pa_stream_get_index(This->stream), pulse_sink_input_info_cb, &info);
+ else
+ o = pa_context_get_source_info_by_index(pulse_ctx, pa_stream_get_device_index(This->stream), pulse_source_info_cb, &info);
+ if (o) {
+ while(pa_operation_get_state(o) == PA_OPERATION_RUNNING)
+ pthread_cond_wait(&pulse_cond, &pulse_lock);
+ pa_operation_unref(o);
+ } else
+ hr = AUDCLNT_E_BUFFER_ERROR;
+ } else {
+ int i;
+ for (i = 0; i < count; ++i)
+ levels[i] = This->vol[i];
+ }
+
+out:
+ pthread_mutex_unlock(&pulse_lock);
+ return hr;
+}
+
+static HRESULT WINAPI AudioStreamVolume_SetChannelVolume(
+ IAudioStreamVolume *iface, UINT32 index, float level)
+{
+ ACImpl *This = impl_from_IAudioStreamVolume(iface);
+ HRESULT hr;
+ float volumes[PA_CHANNELS_MAX];
+
+ TRACE("(%p)->(%d, %f)\n", This, index, level);
+
+ if (level < 0.f || level > 1.f)
+ return E_INVALIDARG;
+
+ if (index >= This->ss.channels)
+ return E_INVALIDARG;
+
+ hr = AudioStreamVolume_GetAllVolumes(iface, This->ss.channels, volumes);
+ volumes[index] = level;
+ if (SUCCEEDED(hr))
+ hr = AudioStreamVolume_SetAllVolumes(iface, This->ss.channels, volumes);
+ return hr;
+}
+
+static HRESULT WINAPI AudioStreamVolume_GetChannelVolume(
+ IAudioStreamVolume *iface, UINT32 index, float *level)
+{
+ ACImpl *This = impl_from_IAudioStreamVolume(iface);
+ float volumes[PA_CHANNELS_MAX];
+ HRESULT hr;
+
+ TRACE("(%p)->(%d, %p)\n", This, index, level);
+
+ if (!level)
+ return E_POINTER;
+
+ if (index >= This->ss.channels)
+ return E_INVALIDARG;
+
+ hr = AudioStreamVolume_GetAllVolumes(iface, This->ss.channels, volumes);
+ if (SUCCEEDED(hr))
+ *level = volumes[index];
+ return hr;
+}
+
+static const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl =
+{
+ AudioStreamVolume_QueryInterface,
+ AudioStreamVolume_AddRef,
+ AudioStreamVolume_Release,
+ AudioStreamVolume_GetChannelCount,
+ AudioStreamVolume_SetChannelVolume,
+ AudioStreamVolume_GetChannelVolume,
+ AudioStreamVolume_SetAllVolumes,
+ AudioStreamVolume_GetAllVolumes
+};
+
HRESULT WINAPI AUDDRV_GetAudioSessionManager(IMMDevice *device,
IAudioSessionManager2 **out)
{
--
1.8.4.4

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,35 @@
From 832d14f35d779db701a00fc839750d40d92092b2 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:57 +0100
Subject: [PATCH 16/42] fix fdels trailing whitespaces
Happy? :P
---
dlls/winepulse.drv/mmdevdrv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 64ee62e..5a71a3d 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1898,7 +1898,7 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
TRACE("(%p)->(%p)\n", This, frames);
if (!frames)
return E_POINTER;
-
+
pthread_mutex_lock(&pulse_lock);
ACImpl_GetCapturePad(This, NULL);
p = This->locked_ptr;
@@ -1998,7 +1998,7 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
else
*pos += This->pad;
}
-
+
/* Make time never go backwards */
if (*pos < This->clock_lastpos)
*pos = This->clock_lastpos;
--
1.8.4.4

View File

@@ -0,0 +1,48 @@
From 34f9b00bfe94027b2e6763dfb9a66ddf13df2eff Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 17/42] winepulse v12
Changes since v11:
- Fix incorrect assertions which may fail on moving a capture device
- Whitespace apply fixes
Changes since v10:
- Make some members static
- Fix small memory leak in GetService
---
dlls/winepulse.drv/mmdevdrv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 5a71a3d..960af3c 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -596,10 +596,11 @@ static void pulse_rd_loop(ACImpl *This, size_t bytes)
dst = p->data;
while (rem) {
pa_stream_peek(This->stream, (const void**)&src, &src_len);
- assert(src_len && src_len <= bytes);
+ assert(src_len);
assert(This->peek_ofs < src_len);
src += This->peek_ofs;
src_len -= This->peek_ofs;
+ assert(src_len <= bytes);
copy = rem;
if (copy > src_len)
@@ -627,9 +628,10 @@ static void pulse_rd_drop(ACImpl *This, size_t bytes)
while (rem) {
const void *src;
pa_stream_peek(This->stream, &src, &src_len);
- assert(src_len && src_len <= bytes);
+ assert(src_len);
assert(This->peek_ofs < src_len);
src_len -= This->peek_ofs;
+ assert(src_len <= bytes);
copy = rem;
if (copy > src_len)
--
1.8.4.4

View File

@@ -0,0 +1,41 @@
From b60b5c38e4f55e60e951fb50a0905b76aa0dc815 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 18/42] winepulse v15: Add support for missing formats, and
silence an error for missing format tags
---
dlls/winepulse.drv/mmdevdrv.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 960af3c..f52f119 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1109,7 +1109,22 @@ static HRESULT pulse_spec_from_waveformat(ACImpl *This, const WAVEFORMATEX *fmt)
}
break;
}
- default: FIXME("Unhandled tag %x\n", fmt->wFormatTag);
+ case WAVE_FORMAT_ALAW:
+ case WAVE_FORMAT_MULAW:
+ if (fmt->wBitsPerSample != 8) {
+ FIXME("Unsupported bpp %u for LAW\n", fmt->wBitsPerSample);
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
+ }
+ if (fmt->nChannels != 1 && fmt->nChannels != 2) {
+ FIXME("Unsupported channels %u for LAW\n", fmt->nChannels);
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
+ }
+ This->ss.format = fmt->wFormatTag == WAVE_FORMAT_MULAW ? PA_SAMPLE_ULAW : PA_SAMPLE_ALAW;
+ pa_channel_map_init_auto(&This->map, fmt->nChannels, PA_CHANNEL_MAP_ALSA);
+ break;
+ default:
+ WARN("Unhandled tag %x\n", fmt->wFormatTag);
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
}
This->ss.channels = This->map.channels;
if (!pa_channel_map_valid(&This->map) || This->ss.format == PA_SAMPLE_INVALID) {
--
1.8.4.4

View File

@@ -0,0 +1,79 @@
From 95ae131b414df0b866fb1cf42e384c0e69af79de Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 19/42] winepulse v16: Add official warning wine doesn't want
to support winepulse
And give an alternative place to ask for support.
I wish it didn't have to come to this.
---
dlls/winepulse.drv/mmdevdrv.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index f52f119..76a2e0e 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -59,6 +59,7 @@
#define NULL_PTR_ERR MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, RPC_X_NULL_REF_POINTER)
WINE_DEFAULT_DEBUG_CHANNEL(pulse);
+WINE_DECLARE_DEBUG_CHANNEL(winediag);
static const REFERENCE_TIME MinimumPeriod = 30000;
static const REFERENCE_TIME DefaultPeriod = 100000;
@@ -81,6 +82,8 @@ const WCHAR pulse_keyW[] = {'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','P','u','l','s','e',0};
const WCHAR pulse_streamW[] = { 'S','t','r','e','a','m','V','o','l',0 };
+static HANDLE warn_once;
+
BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH) {
@@ -99,7 +102,10 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
}
if (pulse_ml)
pa_mainloop_quit(pulse_ml, 0);
- CloseHandle(pulse_thread);
+ if (pulse_thread)
+ CloseHandle(pulse_thread);
+ if (warn_once)
+ CloseHandle(warn_once);
}
return TRUE;
}
@@ -758,6 +764,10 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
int WINAPI AUDDRV_GetPriority(void)
{
HRESULT hr;
+ if (getenv("WINENOPULSE")) {
+ FIXME_(winediag)("winepulse has been temporarily disabled through the environment\n");
+ return 0;
+ }
pthread_mutex_lock(&pulse_lock);
hr = pulse_connect();
pthread_mutex_unlock(&pulse_lock);
@@ -771,7 +781,18 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(void *key, IMMDevice *dev,
ACImpl *This;
int i;
- TRACE("%p %p %d %p\n", key, dev, dataflow, out);
+ /* Give one visible warning per session
+ * Sadly wine has chosen not to accept the winepulse patch, so support ourselves
+ */
+ if (!warn_once && (warn_once = CreateEventA(0, 0, 0, "__winepulse_warn_event")) && GetLastError() != ERROR_ALREADY_EXISTS) {
+ FIXME_(winediag)("Winepulse is not officially supported by the wine project\n");
+ FIXME_(winediag)("For sound related feedback and support, please visit http://ubuntuforums.org/showthread.php?t=1960599\n");
+ } else {
+ WARN_(winediag)("Winepulse is not officially supported by the wine project\n");
+ WARN_(winediag)("For sound related feedback and support, please visit http://ubuntuforums.org/showthread.php?t=1960599\n");
+ }
+
+ TRACE("%s %p %p\n", debugstr_guid(guid), dev, out);
if (dataflow != eRender && dataflow != eCapture)
return E_UNEXPECTED;
--
1.8.4.4

View File

@@ -0,0 +1,125 @@
From b5111c70a07ffd6ce97f4300686556d7bc1bccd3 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 20/42] winepulse v17: Fix winmm tests
Handle dwChannelMask = SPEAKER_ALL better so WAVE_FORMAT_EXTENSIBLE tests pass too
---
dlls/winepulse.drv/mmdevdrv.c | 72 +++++++++++++++++++++++++++++++++----------
1 file changed, 56 insertions(+), 16 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 76a2e0e..6e75674 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1066,6 +1066,8 @@ static HRESULT pulse_spec_from_waveformat(ACImpl *This, const WAVEFORMATEX *fmt)
This->ss.format = PA_SAMPLE_U8;
else if (fmt->wBitsPerSample == 16)
This->ss.format = PA_SAMPLE_S16LE;
+ else
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
pa_channel_map_init_auto(&This->map, fmt->nChannels, PA_CHANNEL_MAP_ALSA);
break;
case WAVE_FORMAT_EXTENSIBLE: {
@@ -1102,13 +1104,16 @@ static HRESULT pulse_spec_from_waveformat(ACImpl *This, const WAVEFORMATEX *fmt)
This->ss.format = PA_SAMPLE_S24_32LE;
else if (valid == 32)
This->ss.format = PA_SAMPLE_S32LE;
- default:
break;
+ default:
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
}
}
This->map.channels = fmt->nChannels;
- if (!mask)
+ if (!mask || mask == SPEAKER_ALL)
mask = get_channel_mask(fmt->nChannels);
+ else if (mask == ~0U && fmt->nChannels == 1)
+ mask = SPEAKER_FRONT_CENTER;
for (j = 0; j < sizeof(pulse_pos_from_wfx)/sizeof(*pulse_pos_from_wfx) && i < fmt->nChannels; ++j) {
if (mask & (1 << j))
This->map.map[i++] = pulse_pos_from_wfx[j];
@@ -1118,14 +1123,9 @@ static HRESULT pulse_spec_from_waveformat(ACImpl *This, const WAVEFORMATEX *fmt)
if (mask == SPEAKER_FRONT_CENTER)
This->map.map[0] = PA_CHANNEL_POSITION_MONO;
- if ((mask & SPEAKER_ALL) && i < fmt->nChannels) {
- This->map.map[i++] = PA_CHANNEL_POSITION_MONO;
- FIXME("Is the 'all' channel mapped correctly?\n");
- }
-
if (i < fmt->nChannels || (mask & SPEAKER_RESERVED)) {
This->map.channels = 0;
- ERR("Invalid channel mask: %i/%i and %x\n", i, fmt->nChannels, mask);
+ ERR("Invalid channel mask: %i/%i and %x(%x)\n", i, fmt->nChannels, mask, wfe->dwChannelMask);
break;
}
break;
@@ -1383,15 +1383,55 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface,
return E_INVALIDARG;
if (mode == AUDCLNT_SHAREMODE_EXCLUSIVE)
return This->dataflow == eCapture ? AUDCLNT_E_UNSUPPORTED_FORMAT : AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED;
- if (fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE &&
- fmt->cbSize < sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))
- return E_INVALIDARG;
-
- dump_fmt(fmt);
-
+ switch (fmt->wFormatTag) {
+ case WAVE_FORMAT_EXTENSIBLE:
+ if (fmt->cbSize < sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX))
+ return E_INVALIDARG;
+ dump_fmt(fmt);
+ break;
+ case WAVE_FORMAT_ALAW:
+ case WAVE_FORMAT_MULAW:
+ case WAVE_FORMAT_IEEE_FLOAT:
+ case WAVE_FORMAT_PCM:
+ dump_fmt(fmt);
+ break;
+ default:
+ dump_fmt(fmt);
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
+ }
+ if (fmt->nChannels == 0)
+ return AUDCLNT_E_UNSUPPORTED_FORMAT;
closest = clone_format(fmt);
- if (!closest)
- hr = E_OUTOFMEMORY;
+ if (!closest) {
+ if (out)
+ *out = NULL;
+ return E_OUTOFMEMORY;
+ }
+
+ if (fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
+ UINT32 mask = 0, i, channels = 0;
+ WAVEFORMATEXTENSIBLE *ext = (WAVEFORMATEXTENSIBLE*)closest;
+
+ if ((fmt->nChannels > 1 && ext->dwChannelMask == SPEAKER_ALL) ||
+ (fmt->nChannels == 1 && ext->dwChannelMask == ~0U)) {
+ mask = ext->dwChannelMask;
+ channels = fmt->nChannels;
+ } else if (ext->dwChannelMask) {
+ for (i = 1; !(i & SPEAKER_RESERVED); i <<= 1) {
+ if (i & ext->dwChannelMask) {
+ mask |= i;
+ channels++;
+ }
+ }
+ if (channels < fmt->nChannels)
+ mask = get_channel_mask(fmt->nChannels);
+ } else
+ mask = ext->dwChannelMask;
+ if (ext->dwChannelMask != mask) {
+ ext->dwChannelMask = mask;
+ hr = S_FALSE;
+ }
+ }
if (hr == S_OK || !out) {
CoTaskMemFree(closest);
--
1.8.4.4

View File

@@ -0,0 +1,207 @@
From c87397b563c9eb30a1a2f347b7690a9d76c14fbb Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 21/42] winepulse v18: Latency and compilation improvements
Changes since v17:
- Remove clock_pulse interpolation
* Couldn't work, sadly
- Allow 2 * MinimumPeriod for shared buffers
- Fix all compiler warnings when compiling with 64-bits
- Dynamically select low latency mode if less than 2 default periods are request
* This requires the rtkit patch to be useful
---
dlls/winepulse.drv/mmdevdrv.c | 55 +++++++++++++++++--------------------------
1 file changed, 22 insertions(+), 33 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 6e75674..8e76826 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -169,7 +169,6 @@ struct ACImpl {
pa_channel_map map;
INT64 clock_lastpos, clock_written;
- pa_usec_t clock_pulse;
AudioSession *session;
AudioSessionWrapper *session_wrapper;
@@ -518,7 +517,6 @@ static void pulse_attr_update(pa_stream *s, void *user) {
static void pulse_wr_callback(pa_stream *s, size_t bytes, void *userdata)
{
ACImpl *This = userdata;
- pa_usec_t time;
UINT32 oldpad = This->pad;
if (bytes < This->bufsize_bytes)
@@ -528,13 +526,8 @@ static void pulse_wr_callback(pa_stream *s, size_t bytes, void *userdata)
assert(oldpad >= This->pad);
- if (0 && This->pad && pa_stream_get_time(This->stream, &time) >= 0)
- This->clock_pulse = time;
- else
- This->clock_pulse = PA_USEC_INVALID;
-
This->clock_written += oldpad - This->pad;
- TRACE("New pad: %u (-%u)\n", This->pad / pa_frame_size(&This->ss), (oldpad - This->pad) / pa_frame_size(&This->ss));
+ TRACE("New pad: %zu (-%zu)\n", This->pad / pa_frame_size(&This->ss), (oldpad - This->pad) / pa_frame_size(&This->ss));
if (This->event)
SetEvent(This->event);
@@ -542,8 +535,6 @@ static void pulse_wr_callback(pa_stream *s, size_t bytes, void *userdata)
static void pulse_underflow_callback(pa_stream *s, void *userdata)
{
- ACImpl *This = userdata;
- This->clock_pulse = PA_USEC_INVALID;
WARN("Underflow\n");
}
@@ -562,12 +553,8 @@ static void pulse_latency_callback(pa_stream *s, void *userdata)
static void pulse_started_callback(pa_stream *s, void *userdata)
{
ACImpl *This = userdata;
- pa_usec_t time;
TRACE("(Re)started playing\n");
- assert(This->clock_pulse == PA_USEC_INVALID);
- if (0 && pa_stream_get_time(This->stream, &time) >= 0)
- This->clock_pulse = time;
if (This->event)
SetEvent(This->event);
}
@@ -578,7 +565,7 @@ static void pulse_rd_loop(ACImpl *This, size_t bytes)
ACPacket *p, *next;
LARGE_INTEGER stamp, freq;
BYTE *dst, *src;
- UINT32 src_len, copy, rem = This->capture_period;
+ size_t src_len, copy, rem = This->capture_period;
if (!(p = (ACPacket*)list_head(&This->packet_free_head))) {
p = (ACPacket*)list_head(&This->packet_filled_head);
if (!p->discont) {
@@ -630,7 +617,7 @@ static void pulse_rd_loop(ACImpl *This, size_t bytes)
static void pulse_rd_drop(ACImpl *This, size_t bytes)
{
while (bytes >= This->capture_period) {
- UINT32 src_len, copy, rem = This->capture_period;
+ size_t src_len, copy, rem = This->capture_period;
while (rem) {
const void *src;
pa_stream_peek(This->stream, &src, &src_len);
@@ -660,7 +647,7 @@ static void pulse_rd_callback(pa_stream *s, size_t bytes, void *userdata)
{
ACImpl *This = userdata;
- TRACE("Readable total: %u, fragsize: %u\n", bytes, pa_stream_get_buffer_attr(s)->fragsize);
+ TRACE("Readable total: %zu, fragsize: %u\n", bytes, pa_stream_get_buffer_attr(s)->fragsize);
assert(bytes >= This->peek_ofs);
bytes -= This->peek_ofs;
if (bytes < This->capture_period)
@@ -815,7 +802,6 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(void *key, IMMDevice *dev,
This->IAudioStreamVolume_iface.lpVtbl = &AudioStreamVolume_Vtbl;
This->dataflow = dataflow;
This->parent = dev;
- This->clock_pulse = PA_USEC_INVALID;
for (i = 0; i < PA_CHANNELS_MAX; ++i)
This->vol[i] = 1.f;
IMMDevice_AddRef(This->parent);
@@ -1199,7 +1185,19 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
goto exit;
if (mode == AUDCLNT_SHAREMODE_SHARED) {
- period = pulse_def_period[This->dataflow == eCapture];
+ REFERENCE_TIME def = pulse_def_period[This->dataflow == eCapture];
+ REFERENCE_TIME min = pulse_min_period[This->dataflow == eCapture];
+
+ /* Switch to low latency mode if below 2 default periods,
+ * which is 20 ms by default, this will increase the amount
+ * of interrupts but allows very low latency. In dsound I
+ * managed to get a total latency of ~8ms, which is well below
+ * default
+ */
+ if (duration < 2 * def)
+ period = min;
+ else
+ period = def;
if (duration < 2 * period)
duration = 2 * period;
}
@@ -1510,7 +1508,6 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
pthread_mutex_unlock(&pulse_lock);
return AUDCLNT_E_NOT_STOPPED;
}
- This->clock_pulse = PA_USEC_INVALID;
if (pa_stream_is_corked(This->stream)) {
o = pa_stream_cork(This->stream, 0, pulse_op_cb, &success);
@@ -1566,7 +1563,6 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface)
}
if (SUCCEEDED(hr)) {
This->started = FALSE;
- This->clock_pulse = PA_USEC_INVALID;
}
pthread_mutex_unlock(&pulse_lock);
return hr;
@@ -1764,7 +1760,8 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
UINT32 frames, BYTE **data)
{
ACImpl *This = impl_from_IAudioRenderClient(iface);
- UINT32 avail, pad, req, bytes = frames * pa_frame_size(&This->ss);
+ size_t avail, req, bytes = frames * pa_frame_size(&This->ss);
+ UINT32 pad;
HRESULT hr = S_OK;
int ret = -1;
@@ -1789,7 +1786,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
avail = This->bufsize_frames - pad;
if (avail < frames || bytes > This->bufsize_bytes) {
pthread_mutex_unlock(&pulse_lock);
- WARN("Wanted to write %u, but only %u available\n", frames, avail);
+ WARN("Wanted to write %u, but only %zu available\n", frames, avail);
return AUDCLNT_E_BUFFER_TOO_LARGE;
}
@@ -1797,7 +1794,7 @@ static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
req = bytes;
ret = pa_stream_begin_write(This->stream, &This->locked_ptr, &req);
if (ret < 0 || req < bytes) {
- FIXME("%p Not using pulse locked data: %i %u/%u %u/%u\n", This, ret, req/pa_frame_size(&This->ss), frames, pad, This->bufsize_frames);
+ FIXME("%p Not using pulse locked data: %i %zu/%u %u/%u\n", This, ret, req/pa_frame_size(&This->ss), frames, pad, This->bufsize_frames);
if (ret >= 0)
pa_stream_cancel_write(This->stream);
*data = This->tmp_buffer;
@@ -1845,7 +1842,7 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
pa_stream_write(This->stream, This->tmp_buffer, written_bytes, NULL, 0, PA_SEEK_RELATIVE);
This->pad += written_bytes;
This->locked_ptr = NULL;
- TRACE("Released %u, pad %u\n", written_frames, This->pad / pa_frame_size(&This->ss));
+ TRACE("Released %u, pad %zu\n", written_frames, This->pad / pa_frame_size(&This->ss));
assert(This->pad <= This->bufsize_bytes);
pthread_mutex_unlock(&pulse_lock);
return S_OK;
@@ -2053,7 +2050,6 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
UINT64 *qpctime)
{
ACImpl *This = impl_from_IAudioClock(iface);
- pa_usec_t time;
HRESULT hr;
TRACE("(%p)->(%p, %p)\n", This, pos, qpctime);
@@ -2069,13 +2065,6 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
}
*pos = This->clock_written;
- if (This->clock_pulse != PA_USEC_INVALID && pa_stream_get_time(This->stream, &time) >= 0) {
- UINT32 delta = pa_usec_to_bytes(time - This->clock_pulse, &This->ss);
- if (delta < This->pad)
- *pos += delta;
- else
- *pos += This->pad;
- }
/* Make time never go backwards */
if (*pos < This->clock_lastpos)
--
1.8.4.4

View File

@@ -0,0 +1,114 @@
From e2845d85e98107c4859b0efa521516dd31cf88ea Mon Sep 17 00:00:00 2001
From: Juergen Tretthahn <orson@orson.at>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 22/42] winepulse: API Compatibility with 1.5.2 onward, v2
V2: Add winepulse.drv.spec to commit too
V1: Original version
Commit e87cb774d131963d2642d075977571585ec5da8d changed the driver api
leave this commit out to build for builds prior to this
Not needed for: 1.5.1, 1.5 and 1.4 builds
---
dlls/winepulse.drv/mmdevdrv.c | 34 ++++++++++++++++++++++------------
dlls/winepulse.drv/winepulse.drv.spec | 2 +-
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 8e76826..b374b53 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -82,6 +82,11 @@ const WCHAR pulse_keyW[] = {'S','o','f','t','w','a','r','e','\\',
'W','i','n','e','\\','P','u','l','s','e',0};
const WCHAR pulse_streamW[] = { 'S','t','r','e','a','m','V','o','l',0 };
+static GUID pulse_render_guid =
+{ 0xfd47d9cc, 0x4218, 0x4135, { 0x9c, 0xe2, 0x0c, 0x19, 0x5c, 0x87, 0x40, 0x5b } };
+static GUID pulse_capture_guid =
+{ 0x25da76d0, 0x033c, 0x4235, { 0x90, 0x02, 0x19, 0xf4, 0x88, 0x94, 0xac, 0x6f } };
+
static HANDLE warn_once;
BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
@@ -716,7 +721,7 @@ static HRESULT pulse_stream_connect(ACImpl *This, UINT32 period_bytes) {
return S_OK;
}
-HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
+HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **keys,
UINT *num, UINT *def_index)
{
HRESULT hr = S_OK;
@@ -730,20 +735,21 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids, void ***keys,
*num = 1;
*def_index = 0;
- *ids = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR *));
+ *ids = HeapAlloc(GetProcessHeap(), 0, sizeof(**ids));
if (!*ids)
return E_OUTOFMEMORY;
+ (*ids)[0] = defaultW;
- (*ids)[0] = HeapAlloc(GetProcessHeap(), 0, sizeof(defaultW));
- if (!(*ids)[0]) {
+ *keys = HeapAlloc(GetProcessHeap(), 0, sizeof(**keys));
+ if (!*keys) {
HeapFree(GetProcessHeap(), 0, *ids);
+ *ids = NULL;
return E_OUTOFMEMORY;
}
-
- lstrcpyW((*ids)[0], defaultW);
-
- *keys = HeapAlloc(GetProcessHeap(), 0, sizeof(void *));
- (*keys)[0] = NULL;
+ if (flow == eRender)
+ (*keys)[0] = pulse_render_guid;
+ else
+ (*keys)[0] = pulse_capture_guid;
return S_OK;
}
@@ -761,12 +767,12 @@ int WINAPI AUDDRV_GetPriority(void)
return SUCCEEDED(hr) ? 3 : 0;
}
-HRESULT WINAPI AUDDRV_GetAudioEndpoint(void *key, IMMDevice *dev,
- EDataFlow dataflow, IAudioClient **out)
+HRESULT WINAPI AUDDRV_GetAudioEndpoint(GUID *guid, IMMDevice *dev, IAudioClient **out)
{
HRESULT hr;
ACImpl *This;
int i;
+ EDataFlow dataflow;
/* Give one visible warning per session
* Sadly wine has chosen not to accept the winepulse patch, so support ourselves
@@ -780,7 +786,11 @@ HRESULT WINAPI AUDDRV_GetAudioEndpoint(void *key, IMMDevice *dev,
}
TRACE("%s %p %p\n", debugstr_guid(guid), dev, out);
- if (dataflow != eRender && dataflow != eCapture)
+ if (IsEqualGUID(guid, &pulse_render_guid))
+ dataflow = eRender;
+ else if (IsEqualGUID(guid, &pulse_capture_guid))
+ dataflow = eCapture;
+ else
return E_UNEXPECTED;
*out = NULL;
diff --git a/dlls/winepulse.drv/winepulse.drv.spec b/dlls/winepulse.drv/winepulse.drv.spec
index a089166..612bf46 100644
--- a/dlls/winepulse.drv/winepulse.drv.spec
+++ b/dlls/winepulse.drv/winepulse.drv.spec
@@ -1,5 +1,5 @@
# MMDevAPI driver functions
@ stdcall -private GetPriority() AUDDRV_GetPriority
@ stdcall -private GetEndpointIDs(long ptr ptr ptr ptr) AUDDRV_GetEndpointIDs
-@ stdcall -private GetAudioEndpoint(ptr ptr long ptr) AUDDRV_GetAudioEndpoint
+@ stdcall -private GetAudioEndpoint(ptr ptr ptr) AUDDRV_GetAudioEndpoint
@ stdcall -private GetAudioSessionManager(ptr ptr) AUDDRV_GetAudioSessionManager
--
1.8.4.4

View File

@@ -0,0 +1,58 @@
From 34aa975484571428eed615bb0774cbdcc3a3ea0a Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 23/42] winepulse: Fix low latency support
Some games request a 20 ms buffer and will only fill 20 ms.
Since 10 ms periods are too long in this case for winepulse,
fill change period size to 5 ms and force a trigger if
there's still data left to fill.
---
dlls/winepulse.drv/mmdevdrv.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index b374b53..7c07f54 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1205,11 +1205,15 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
* default
*/
if (duration < 2 * def)
- period = min;
+ period = min;
else
- period = def;
+ period = def;
if (duration < 2 * period)
duration = 2 * period;
+
+ /* 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);
@@ -1820,6 +1824,7 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
{
ACImpl *This = impl_from_IAudioRenderClient(iface);
UINT32 written_bytes = written_frames * pa_frame_size(&This->ss);
+ UINT32 period;
TRACE("(%p)->(%u, %x)\n", This, written_frames, flags);
@@ -1854,6 +1859,11 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
This->locked_ptr = NULL;
TRACE("Released %u, pad %zu\n", written_frames, This->pad / pa_frame_size(&This->ss));
assert(This->pad <= This->bufsize_bytes);
+
+ period = pa_stream_get_buffer_attr(This->stream)->minreq;
+ /* Require a minimum of 3 periods filled, if possible */
+ if (This->event && This->pad + period <= This->bufsize_bytes && This->pad < period * 3)
+ SetEvent(This->event);
pthread_mutex_unlock(&pulse_lock);
return S_OK;
}
--
1.8.4.4

View File

@@ -0,0 +1,27 @@
From ba6788c394705ebd5ce285585cf54c8347ddee80 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 24/42] winepulse: drop realtime priority before thread
destruction
prevents having to handle a kernel RT Watchdog Timeout.
---
dlls/winepulse.drv/mmdevdrv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 7c07f54..ba68102 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -101,6 +101,8 @@ BOOL WINAPI DllMain(HINSTANCE dll, DWORD reason, void *reserved)
}
DisableThreadLibraryCalls(dll);
} else if (reason == DLL_PROCESS_DETACH) {
+ if (pulse_thread)
+ SetThreadPriority(pulse_thread, 0);
if (pulse_ctx) {
pa_context_disconnect(pulse_ctx);
pa_context_unref(pulse_ctx);
--
1.8.4.4

View File

@@ -0,0 +1,29 @@
From 9b8cec1403996ee0cc21ef05d595862d63dd417e Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 25/42] winepulse: remove bogus SetEvent from
pulse_started_callback
---
dlls/winepulse.drv/mmdevdrv.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index ba68102..68de00c 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -559,11 +559,7 @@ static void pulse_latency_callback(pa_stream *s, void *userdata)
static void pulse_started_callback(pa_stream *s, void *userdata)
{
- ACImpl *This = userdata;
-
TRACE("(Re)started playing\n");
- if (This->event)
- SetEvent(This->event);
}
static void pulse_rd_loop(ACImpl *This, size_t bytes)
--
1.8.4.4

View File

@@ -0,0 +1,42 @@
From 63638aee04429b7fd2f937a3005f96187082b8c1 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 26/42] winepulse: disable the setevent part of the latency
hack
If you get playback glitches in skyrim or other games as a result of
this patch, PLEASE REPORT TO ME!
---
dlls/winepulse.drv/mmdevdrv.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 68de00c..643d55e 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1822,7 +1822,7 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
{
ACImpl *This = impl_from_IAudioRenderClient(iface);
UINT32 written_bytes = written_frames * pa_frame_size(&This->ss);
- UINT32 period;
+// UINT32 period;
TRACE("(%p)->(%u, %x)\n", This, written_frames, flags);
@@ -1858,10 +1858,10 @@ static HRESULT WINAPI AudioRenderClient_ReleaseBuffer(
TRACE("Released %u, pad %zu\n", written_frames, This->pad / pa_frame_size(&This->ss));
assert(This->pad <= This->bufsize_bytes);
- period = pa_stream_get_buffer_attr(This->stream)->minreq;
+// period = pa_stream_get_buffer_attr(This->stream)->minreq;
/* Require a minimum of 3 periods filled, if possible */
- if (This->event && This->pad + period <= This->bufsize_bytes && This->pad < period * 3)
- SetEvent(This->event);
+// if (This->event && This->pad + period <= This->bufsize_bytes && This->pad < period * 3)
+// SetEvent(This->event);
pthread_mutex_unlock(&pulse_lock);
return S_OK;
}
--
1.8.4.4

View File

@@ -0,0 +1,28 @@
From 767887f715fb48b3c7086878c8bd1b14a58f9a06 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Date: Fri, 22 Nov 2013 21:29:58 +0100
Subject: [PATCH 27/42] winepulse v20: fix the checks in IsFormatSupported
Thanks to DGhost001 for reporting and isolating the issue.
---
dlls/winepulse.drv/mmdevdrv.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 643d55e..86dd10a 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -1443,6 +1443,10 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface,
}
}
+ if (fmt->nBlockAlign != fmt->nChannels * fmt->wBitsPerSample / 8 ||
+ fmt->nAvgBytesPerSec != fmt->nBlockAlign * fmt->nSamplesPerSec)
+ hr = S_FALSE;
+
if (hr == S_OK || !out) {
CoTaskMemFree(closest);
if (out)
--
1.8.4.4

Some files were not shown because too many files have changed in this diff Show More