From fe6e532c876bf3ec6776f76f9542038ac9c94d68 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 5 Mar 2012 07:11:09 -0800 Subject: 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. --- Alc/backends/oss.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Alc/backends/oss.c') diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index bd489e3e..a577d8be 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -268,11 +268,18 @@ static ALCboolean oss_reset_playback(ALCdevice *device) device->UpdateSize = info.fragsize / frameSize; device->NumUpdates = info.fragments + 1; - data->data_size = device->UpdateSize * frameSize; - data->mix_data = calloc(1, data->data_size); - SetDefaultChannelOrder(device); + return ALC_TRUE; +} + +static ALCboolean oss_start_playback(ALCdevice *device) +{ + oss_data *data = (oss_data*)device->ExtraData; + + data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); + data->mix_data = calloc(1, data->data_size); + data->thread = StartThread(OSSProc, device); if(data->thread == NULL) { @@ -473,6 +480,7 @@ static const BackendFuncs oss_funcs = { oss_open_playback, oss_close_playback, oss_reset_playback, + oss_start_playback, oss_stop_playback, oss_open_capture, oss_close_capture, -- cgit v1.2.3