diff options
author | Chris Robinson <[email protected]> | 2021-03-09 02:55:01 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2021-03-09 02:55:01 -0800 |
commit | e6c7cdc1baa07b64cb65fd81c1748c67dc99c3d2 (patch) | |
tree | d9f6a3907c2de3c3d9cbb62c807755daf9e20212 /alc/backends/coreaudio.cpp | |
parent | 1d57db6836fd577e66bafc84095d672d288e4552 (diff) |
Initialize the new audio unit before disposing the old one
Diffstat (limited to 'alc/backends/coreaudio.cpp')
-rw-r--r-- | alc/backends/coreaudio.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp index 977bdc78..43c78063 100644 --- a/alc/backends/coreaudio.cpp +++ b/alc/backends/coreaudio.cpp @@ -123,6 +123,12 @@ void CoreAudioPlayback::open(const char *name) if(err != noErr) throw al::backend_exception{al::backend_error::NoDevice, "Could not create component instance: %u", err}; + + err = AudioUnitInitialize(audioUnit); + if(err != noErr) + throw al::backend_exception{al::backend_error::DeviceError, + "Could not initialize audio unit: %u", err}; + /* WARNING: I don't know if "valid" audio unit values are guaranteed to be * non-0. If not, this logic is broken. */ @@ -133,12 +139,6 @@ void CoreAudioPlayback::open(const char *name) } mAudioUnit = audioUnit; - /* init and start the default audio unit... */ - err = AudioUnitInitialize(mAudioUnit); - if(err != noErr) - throw al::backend_exception{al::backend_error::DeviceError, - "Could not initialize audio unit: %u", err}; - mDevice->DeviceName = name; } |