winepulse: Move pulse_start to unix lib.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2a667e28ba
commit
638455136b
|
@ -908,54 +908,23 @@ static HRESULT WINAPI AudioClient_GetDevicePeriod(IAudioClient3 *iface,
|
|||
static HRESULT WINAPI AudioClient_Start(IAudioClient3 *iface)
|
||||
{
|
||||
ACImpl *This = impl_from_IAudioClient3(iface);
|
||||
HRESULT hr = S_OK;
|
||||
int success;
|
||||
pa_operation *o;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)\n", This);
|
||||
|
||||
pulse->lock();
|
||||
hr = pulse_stream_valid(This);
|
||||
if (FAILED(hr)) {
|
||||
pulse->unlock();
|
||||
if (!This->pulse_stream)
|
||||
return AUDCLNT_E_NOT_INITIALIZED;
|
||||
|
||||
hr = pulse->start(This->pulse_stream);
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
if (!This->timer) {
|
||||
This->timer = CreateThread(NULL, 0, pulse_timer_cb, This, 0, NULL);
|
||||
SetThreadPriority(This->timer, THREAD_PRIORITY_TIME_CRITICAL);
|
||||
}
|
||||
|
||||
if ((This->pulse_stream->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) && !This->pulse_stream->event) {
|
||||
pulse->unlock();
|
||||
return AUDCLNT_E_EVENTHANDLE_NOT_SET;
|
||||
}
|
||||
|
||||
if (This->pulse_stream->started) {
|
||||
pulse->unlock();
|
||||
return AUDCLNT_E_NOT_STOPPED;
|
||||
}
|
||||
|
||||
pulse->write(This->pulse_stream);
|
||||
|
||||
if (pa_stream_is_corked(This->pulse_stream->stream)) {
|
||||
o = pa_stream_cork(This->pulse_stream->stream, 0, 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 = TRUE;
|
||||
This->pulse_stream->just_started = TRUE;
|
||||
|
||||
if(!This->timer) {
|
||||
This->timer = CreateThread(NULL, 0, pulse_timer_cb, This, 0, NULL);
|
||||
SetThreadPriority(This->timer, THREAD_PRIORITY_TIME_CRITICAL);
|
||||
}
|
||||
}
|
||||
pulse->unlock();
|
||||
return hr;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI AudioClient_Stop(IAudioClient3 *iface)
|
||||
|
|
|
@ -1007,7 +1007,7 @@ write:
|
|||
return pa_stream_write(stream->stream, buffer, bytes, NULL, 0, PA_SEEK_RELATIVE);
|
||||
}
|
||||
|
||||
static void WINAPI pulse_write(struct pulse_stream *stream)
|
||||
static void pulse_write(struct pulse_stream *stream)
|
||||
{
|
||||
/* write as much data to PA as we can */
|
||||
UINT32 to_write;
|
||||
|
@ -1257,6 +1257,57 @@ static void WINAPI pulse_timer_loop(struct pulse_stream *stream)
|
|||
}
|
||||
}
|
||||
|
||||
static HRESULT WINAPI pulse_start(struct pulse_stream *stream)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
int success;
|
||||
pa_operation *o;
|
||||
|
||||
pulse_lock();
|
||||
if (!pulse_stream_valid(stream))
|
||||
{
|
||||
pulse_unlock();
|
||||
return hr;
|
||||
}
|
||||
|
||||
if ((stream->flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) && !stream->event)
|
||||
{
|
||||
pulse_unlock();
|
||||
return AUDCLNT_E_EVENTHANDLE_NOT_SET;
|
||||
}
|
||||
|
||||
if (stream->started)
|
||||
{
|
||||
pulse_unlock();
|
||||
return AUDCLNT_E_NOT_STOPPED;
|
||||
}
|
||||
|
||||
pulse_write(stream);
|
||||
|
||||
if (pa_stream_is_corked(stream->stream))
|
||||
{
|
||||
o = pa_stream_cork(stream->stream, 0, 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 = TRUE;
|
||||
stream->just_started = TRUE;
|
||||
}
|
||||
pulse_unlock();
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI pulse_stop(struct pulse_stream *stream)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
@ -1314,7 +1365,7 @@ static const struct unix_funcs unix_funcs =
|
|||
pulse_main_loop,
|
||||
pulse_create_stream,
|
||||
pulse_release_stream,
|
||||
pulse_write,
|
||||
pulse_start,
|
||||
pulse_stop,
|
||||
pulse_timer_loop,
|
||||
pulse_set_volumes,
|
||||
|
|
|
@ -78,7 +78,7 @@ struct unix_funcs
|
|||
const WAVEFORMATEX *fmt, UINT32 *channel_count,
|
||||
struct pulse_stream **ret);
|
||||
void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer);
|
||||
void (WINAPI *write)(struct pulse_stream *stream);
|
||||
HRESULT (WINAPI *start)(struct pulse_stream *stream);
|
||||
HRESULT (WINAPI *stop)(struct pulse_stream *stream);
|
||||
void (WINAPI *timer_loop)(struct pulse_stream *stream);
|
||||
void (WINAPI *set_volumes)(struct pulse_stream *stream, float master_volume,
|
||||
|
|
Loading…
Reference in New Issue