Commit b1ddfca1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winepulse: Move pulse_stop to unix lib.

parent a5d4079c
......@@ -1223,40 +1223,12 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface)
static HRESULT WINAPI AudioClient_Stop(IAudioClient3 *iface)
{
ACImpl *This = impl_from_IAudioClient3(iface);
HRESULT hr = S_OK;
pa_operation *o;
int success;
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 S_FALSE;
}
if (!This->pulse_stream)
return AUDCLNT_E_NOT_INITIALIZED;
if (This->dataflow == eRender) {
o = pa_stream_cork(This->pulse_stream->stream, 1, pulse_op_cb, &success);
if (o) {
while(pa_operation_get_state(o) == PA_OPERATION_RUNNING)
pulse->cond_wait();
pa_operation_unref(o);
} else
success = 0;
if (!success)
hr = E_FAIL;
}
if (SUCCEEDED(hr)) {
This->pulse_stream->started = FALSE;
}
pulse->unlock();
return hr;
return pulse->stop(This->pulse_stream);
}
static HRESULT WINAPI AudioClient_Reset(IAudioClient3 *iface)
......
......@@ -200,11 +200,23 @@ static void pulse_started_callback(pa_stream *s, void *userdata)
TRACE("%p: (Re)started playing\n", userdata);
}
static void pulse_op_cb(pa_stream *s, int success, void *user)
{
TRACE("Success: %i\n", success);
*(int*)user = success;
pulse_broadcast();
}
static void silence_buffer(pa_sample_format_t format, BYTE *buffer, UINT32 bytes)
{
memset(buffer, format == PA_SAMPLE_U8 ? 0x80 : 0, bytes);
}
static BOOL pulse_stream_valid(struct pulse_stream *stream)
{
return pa_stream_get_state(stream->stream) == PA_STREAM_READY;
}
static HRESULT pulse_connect(const char *name)
{
if (pulse_ctx && PA_CONTEXT_IS_GOOD(pa_context_get_state(pulse_ctx)))
......@@ -951,6 +963,45 @@ static void WINAPI pulse_read(struct pulse_stream *stream)
}
}
static HRESULT WINAPI pulse_stop(struct pulse_stream *stream)
{
HRESULT hr = S_OK;
pa_operation *o;
int success;
pulse_lock();
if (!pulse_stream_valid(stream))
{
pulse_unlock();
return AUDCLNT_E_DEVICE_INVALIDATED;
}
if (!stream->started)
{
pulse_unlock();
return S_FALSE;
}
if (stream->dataflow == eRender)
{
o = pa_stream_cork(stream->stream, 1, pulse_op_cb, &success);
if (o)
{
while(pa_operation_get_state(o) == PA_OPERATION_RUNNING)
pulse_cond_wait();
pa_operation_unref(o);
}
else
success = 0;
if (!success)
hr = E_FAIL;
}
if (SUCCEEDED(hr))
stream->started = FALSE;
pulse_unlock();
return hr;
}
static const struct unix_funcs unix_funcs =
{
pulse_lock,
......@@ -961,6 +1012,7 @@ static const struct unix_funcs unix_funcs =
pulse_create_stream,
pulse_release_stream,
pulse_read,
pulse_stop,
pulse_test_connect,
};
......
......@@ -78,5 +78,6 @@ struct unix_funcs
struct pulse_stream **ret);
void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer);
void (WINAPI *read)(struct pulse_stream *stream);
HRESULT (WINAPI *stop)(struct pulse_stream *stream);
HRESULT (WINAPI *test_connect)(const char *name, struct pulse_config *config);
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment