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/wave.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/wave.c')
-rw-r--r-- | Alc/backends/wave.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c index ad187896..d9f1fdc7 100644 --- a/Alc/backends/wave.c +++ b/Alc/backends/wave.c @@ -258,10 +258,18 @@ static ALCboolean wave_reset_playback(ALCdevice *device) ERR("Error writing header: %s\n", strerror(errno)); return ALC_FALSE; } - data->DataStart = ftell(data->f); - data->size = device->UpdateSize * channels * bits / 8; + SetDefaultWFXChannelOrder(device); + + return ALC_TRUE; +} + +static ALCboolean wave_start_playback(ALCdevice *device) +{ + wave_data *data = (wave_data*)device->ExtraData; + + data->size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); data->buffer = malloc(data->size); if(!data->buffer) { @@ -269,8 +277,6 @@ static ALCboolean wave_reset_playback(ALCdevice *device) return ALC_FALSE; } - SetDefaultWFXChannelOrder(device); - data->thread = StartThread(WaveProc, device); if(data->thread == NULL) { @@ -316,6 +322,7 @@ static const BackendFuncs wave_funcs = { wave_open_playback, wave_close_playback, wave_reset_playback, + wave_start_playback, wave_stop_playback, NULL, NULL, |