diff --git a/desmume/src/cocoa/cocoa_output.mm b/desmume/src/cocoa/cocoa_output.mm index 9ef76612e..0129dcd0e 100644 --- a/desmume/src/cocoa/cocoa_output.mm +++ b/desmume/src/cocoa/cocoa_output.mm @@ -543,9 +543,9 @@ - (NSSize) displaySize { - OSSpinLockLock(&spinlockDisplayType); + pthread_rwlock_rdlock(self.rwlockProducer); NSSize size = NSMakeSize((CGFloat)GPU_GetFramebufferWidth(), (displayMode == DS_DISPLAY_TYPE_DUAL) ? (CGFloat)(GPU_GetFramebufferHeight() * 2): (CGFloat)GPU_GetFramebufferHeight()); - OSSpinLockUnlock(&spinlockDisplayType); + pthread_rwlock_unlock(self.rwlockProducer); return size; } @@ -616,6 +616,8 @@ - (void) handleEmuFrameProcessed { + pthread_rwlock_rdlock(self.rwlockProducer); + const uint16_t newGpuWidth = GPU_GetFramebufferWidth(); const uint16_t newGpuHeight = GPU_GetFramebufferHeight(); @@ -624,6 +626,8 @@ _gpuFrame.width = newGpuWidth; _gpuFrame.height = (_gpuFrame.displayModeID == DS_DISPLAY_TYPE_DUAL) ? newGpuHeight * 2 : newGpuHeight; + pthread_rwlock_unlock(self.rwlockProducer); + if (newGpuWidth != _gpuCurrentWidth || newGpuHeight != _gpuCurrentHeight) { if (delegate != nil && [delegate respondsToSelector:@selector(doDisplaySizeChanged:)])