Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winepulse.drv/mmdevdrv.c | 55 ++---------------------------- dlls/winepulse.drv/pulse.c | 63 +++++++++++++++++++++++++++++++++-- dlls/winepulse.drv/unixlib.h | 2 +- 3 files changed, 65 insertions(+), 55 deletions(-)
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Tue, May 18, 2021 at 04:58:48PM +0200, Jacek Caban wrote:
Signed-off-by: Jacek Caban jacek@codeweavers.com
dlls/winepulse.drv/mmdevdrv.c | 55 ++---------------------------- dlls/winepulse.drv/pulse.c | 63 +++++++++++++++++++++++++++++++++-- dlls/winepulse.drv/unixlib.h | 2 +- 3 files changed, 65 insertions(+), 55 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index 46d3b308f38..0cfb1106d2c 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -243,12 +243,6 @@ static void silence_buffer(pa_sample_format_t format, BYTE *buffer, UINT32 bytes memset(buffer, format == PA_SAMPLE_U8 ? 0x80 : 0, bytes); }
-static void pulse_op_cb(pa_stream *s, int success, void *user) {
- TRACE("Success: %i\n", success);
- *(int*)user = success;
- pulse->broadcast();
-}
static DWORD WINAPI pulse_timer_cb(void *user) { ACImpl *This = user; @@ -941,56 +935,13 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient3 *iface) static HRESULT WINAPI AudioClient_Reset(IAudioClient3 *iface) { ACImpl *This = impl_from_IAudioClient3(iface);
HRESULT hr = S_OK;
TRACE("(%p)\n", This);
pulse->lock();
hr = pulse_stream_valid(This);
if (FAILED(hr)) {
pulse->unlock();
return hr;
}
if (This->pulse_stream->started) {
pulse->unlock();
return AUDCLNT_E_NOT_STOPPED;
}
if (This->pulse_stream->locked) {
pulse->unlock();
return AUDCLNT_E_BUFFER_OPERATION_PENDING;
}
if (This->dataflow == eRender) {
/* If there is still data in the render buffer it needs to be removed from the server */
int success = 0;
if (This->pulse_stream->held_bytes) {
pa_operation *o = pa_stream_flush(This->pulse_stream->stream, pulse_op_cb, &success);
if (o) {
while(pa_operation_get_state(o) == PA_OPERATION_RUNNING)
pulse->cond_wait();
pa_operation_unref(o);
}
}
if (success || !This->pulse_stream->held_bytes){
This->pulse_stream->clock_lastpos = This->pulse_stream->clock_written = 0;
This->pulse_stream->pa_offs_bytes = This->pulse_stream->lcl_offs_bytes = This->pulse_stream->held_bytes = This->pulse_stream->pa_held_bytes = 0;
}
} else {
ACPacket *p;
This->pulse_stream->clock_written += This->pulse_stream->held_bytes;
This->pulse_stream->held_bytes = 0;
if ((p = This->pulse_stream->locked_ptr)) {
This->pulse_stream->locked_ptr = NULL;
list_add_tail(&This->pulse_stream->packet_free_head, &p->entry);
}
list_move_tail(&This->pulse_stream->packet_free_head, &This->pulse_stream->packet_filled_head);
}
pulse->unlock();
- if (!This->pulse_stream)
return AUDCLNT_E_NOT_INITIALIZED;
- return hr;
- return pulse->reset(This->pulse_stream);
}
static HRESULT WINAPI AudioClient_SetEventHandle(IAudioClient3 *iface, diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 28b221e5f03..dbdf94b2672 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -76,7 +76,7 @@ static int WINAPI pulse_cond_wait(void) return pthread_cond_wait(&pulse_cond, &pulse_mutex); }
-static void WINAPI pulse_broadcast(void) +static void pulse_broadcast(void) { pthread_cond_broadcast(&pulse_cond); } @@ -1347,6 +1347,65 @@ static HRESULT WINAPI pulse_stop(struct pulse_stream *stream) return hr; }
+static HRESULT WINAPI pulse_reset(struct pulse_stream *stream) +{
- pulse_lock();
- if (!pulse_stream_valid(stream))
- {
pulse_unlock();
return AUDCLNT_E_DEVICE_INVALIDATED;
- }
- if (stream->started)
- {
pulse_unlock();
return AUDCLNT_E_NOT_STOPPED;
- }
- if (stream->locked)
- {
pulse_unlock();
return AUDCLNT_E_BUFFER_OPERATION_PENDING;
- }
- if (stream->dataflow == eRender)
- {
/* If there is still data in the render buffer it needs to be removed from the server */
int success = 0;
if (stream->held_bytes)
{
pa_operation *o = pa_stream_flush(stream->stream, pulse_op_cb, &success);
if (o)
{
while (pa_operation_get_state(o) == PA_OPERATION_RUNNING)
pulse_cond_wait();
pa_operation_unref(o);
}
}
if (success || !stream->held_bytes)
{
stream->clock_lastpos = stream->clock_written = 0;
stream->pa_offs_bytes = stream->lcl_offs_bytes = 0;
stream->held_bytes = stream->pa_held_bytes = 0;
}
- }
- else
- {
ACPacket *p;
stream->clock_written += stream->held_bytes;
stream->held_bytes = 0;
if ((p = stream->locked_ptr))
{
stream->locked_ptr = NULL;
list_add_tail(&stream->packet_free_head, &p->entry);
}
list_move_tail(&stream->packet_free_head, &stream->packet_filled_head);
- }
- pulse_unlock();
- return S_OK;
+}
static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume, const float *volumes, const float *session_volumes) { @@ -1361,12 +1420,12 @@ static const struct unix_funcs unix_funcs = pulse_lock, pulse_unlock, pulse_cond_wait,
- pulse_broadcast, pulse_main_loop, pulse_create_stream, pulse_release_stream, pulse_start, pulse_stop,
- pulse_reset, pulse_timer_loop, pulse_set_volumes, pulse_test_connect,
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h index 38996792ffe..f6ecf778558 100644 --- a/dlls/winepulse.drv/unixlib.h +++ b/dlls/winepulse.drv/unixlib.h @@ -71,7 +71,6 @@ struct unix_funcs void (WINAPI *lock)(void); void (WINAPI *unlock)(void); int (WINAPI *cond_wait)(void);
- void (WINAPI *broadcast)(void); void (WINAPI *main_loop)(void); HRESULT (WINAPI *create_stream)(const char *name, EDataFlow dataflow, AUDCLNT_SHAREMODE mode, DWORD flags, REFERENCE_TIME duration, REFERENCE_TIME period,
@@ -80,6 +79,7 @@ struct unix_funcs void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer); HRESULT (WINAPI *start)(struct pulse_stream *stream); HRESULT (WINAPI *stop)(struct pulse_stream *stream);
- HRESULT (WINAPI *reset)(struct pulse_stream *stream); void (WINAPI *timer_loop)(struct pulse_stream *stream); void (WINAPI *set_volumes)(struct pulse_stream *stream, float master_volume, const float *volumes, const float *session_volumes);