HRTF: Fix deadlock with restarting motion tracking
Some checks are pending
Check if Cog buildable / Build Universal Cog.app (push) Waiting to run
Some checks are pending
Check if Cog buildable / Build Universal Cog.app (push) Waiting to run
Motion tracking was storing a strong reference to the HRTF DSP node, which was resulting in the DSP not shutting down or restarting properly, leading to playback hanging. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
47f50052be
commit
a0a9f79592
1 changed files with 3 additions and 2 deletions
|
@ -40,7 +40,7 @@ static simd_float4x4 convertMatrix(CMRotationMatrix r) {
|
||||||
|
|
||||||
static NSLock *motionManagerLock = nil;
|
static NSLock *motionManagerLock = nil;
|
||||||
API_AVAILABLE(macos(14.0)) static CMHeadphoneMotionManager *motionManager = nil;
|
API_AVAILABLE(macos(14.0)) static CMHeadphoneMotionManager *motionManager = nil;
|
||||||
static DSPHRTFNode *registeredMotionListener = nil;
|
static DSPHRTFNode __weak *registeredMotionListener = nil;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void registerMotionListener(DSPHRTFNode *listener) {
|
static void registerMotionListener(DSPHRTFNode *listener) {
|
||||||
|
@ -55,6 +55,7 @@ static void registerMotionListener(DSPHRTFNode *listener) {
|
||||||
[motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion * _Nullable motion, NSError * _Nullable error) {
|
[motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion * _Nullable motion, NSError * _Nullable error) {
|
||||||
if(motion) {
|
if(motion) {
|
||||||
[motionManagerLock lock];
|
[motionManagerLock lock];
|
||||||
|
if(registeredMotionListener)
|
||||||
[registeredMotionListener reportMotion:convertMatrix(motion.attitude.rotationMatrix)];
|
[registeredMotionListener reportMotion:convertMatrix(motion.attitude.rotationMatrix)];
|
||||||
[motionManagerLock unlock];
|
[motionManagerLock unlock];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue