Cocoa Port:

- Add some additional locks when reading the GPU framebuffer.
This commit is contained in:
rogerman 2015-07-07 21:24:19 +00:00
parent fbda969347
commit e53e289e77
1 changed files with 6 additions and 2 deletions

View File

@ -543,9 +543,9 @@
- (NSSize) displaySize - (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()); 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; return size;
} }
@ -616,6 +616,8 @@
- (void) handleEmuFrameProcessed - (void) handleEmuFrameProcessed
{ {
pthread_rwlock_rdlock(self.rwlockProducer);
const uint16_t newGpuWidth = GPU_GetFramebufferWidth(); const uint16_t newGpuWidth = GPU_GetFramebufferWidth();
const uint16_t newGpuHeight = GPU_GetFramebufferHeight(); const uint16_t newGpuHeight = GPU_GetFramebufferHeight();
@ -624,6 +626,8 @@
_gpuFrame.width = newGpuWidth; _gpuFrame.width = newGpuWidth;
_gpuFrame.height = (_gpuFrame.displayModeID == DS_DISPLAY_TYPE_DUAL) ? newGpuHeight * 2 : newGpuHeight; _gpuFrame.height = (_gpuFrame.displayModeID == DS_DISPLAY_TYPE_DUAL) ? newGpuHeight * 2 : newGpuHeight;
pthread_rwlock_unlock(self.rwlockProducer);
if (newGpuWidth != _gpuCurrentWidth || newGpuHeight != _gpuCurrentHeight) if (newGpuWidth != _gpuCurrentWidth || newGpuHeight != _gpuCurrentHeight)
{ {
if (delegate != nil && [delegate respondsToSelector:@selector(doDisplaySizeChanged:)]) if (delegate != nil && [delegate respondsToSelector:@selector(doDisplaySizeChanged:)])