diff options
author | Chris Robinson <[email protected]> | 2012-03-05 07:11:09 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2012-03-05 07:11:09 -0800 |
commit | fe6e532c876bf3ec6776f76f9542038ac9c94d68 (patch) | |
tree | 31d29eb21462dbc02287030d8e3b6174dcab92cc /Alc/backends/portaudio.c | |
parent | 5cdeeb47f3b4dedefd1ceb2b32c2f7754abc058d (diff) |
Use a separate backend callback to start playback of the device
This allows us to properly update the ALCdevice and its resources with the new
parameters before starting playback, instead of expecting the mixer to block
and wait after it has begun.
This also lets us avoid holding the device lock while resetting and starting
the device, which helps prevent lock inversion on some backends (ie, one thread
locking A then B, and another thread locking B then A), ultimately allowing
certain backends to asynchronously update the ALCdevice without risk of lockup.
Capture still has issues here, however.
Diffstat (limited to 'Alc/backends/portaudio.c')
-rw-r--r-- | Alc/backends/portaudio.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Alc/backends/portaudio.c b/Alc/backends/portaudio.c index 154b6349..03e54d14 100644 --- a/Alc/backends/portaudio.c +++ b/Alc/backends/portaudio.c @@ -261,12 +261,19 @@ static ALCboolean pa_reset_playback(ALCdevice *device) { pa_data *data = (pa_data*)device->ExtraData; const PaStreamInfo *streamInfo; - PaError err; streamInfo = Pa_GetStreamInfo(data->stream); device->Frequency = streamInfo->sampleRate; device->UpdateSize = data->update_size; + return ALC_TRUE; +} + +static ALCboolean pa_start_playback(ALCdevice *device) +{ + pa_data *data = (pa_data*)device->ExtraData; + PaError err; + err = Pa_StartStream(data->stream); if(err != paNoError) { @@ -409,6 +416,7 @@ static const BackendFuncs pa_funcs = { pa_open_playback, pa_close_playback, pa_reset_playback, + pa_start_playback, pa_stop_playback, pa_open_capture, pa_close_capture, |