mac-virtualcam: Use IOSurfaceLock on Intel-based Macs only

Apple Silicon-based Macs have a unified memory architecture, as such
an IOSurface will always be available in memory accessible to the CPU
and GPU (and an off-load of the IOSurface will not take place).

eGPUs are not supported on Apple Silicon-based Macs either, so an
IOSurface lock to ensure data is copied back to CPU memory is not
necessary.
This commit is contained in:
PatTheMav
2022-10-19 00:53:30 +02:00
parent 36a86f5217
commit a754cacc7f

View File

@@ -10,7 +10,6 @@
#import "Logging.h"
@interface OBSDALMachClient () <NSPortDelegate> {
uint32_t _seed;
NSPort *_receivePort;
}
@end
@@ -123,11 +122,20 @@
return;
}
IOSurfaceLock(surface, 0, &_seed);
/*
* IOSurfaceLocks are only necessary on non Apple Silicon devices, as those have
* unified memory. On Intel machines, the lock ensures that the IOSurface is copied back
* from GPU memory to CPU memory so we can process the pixel buffer.
*/
#ifndef __aarch64__
IOSurfaceLock(surface, kIOSurfaceLockReadOnly, NULL);
#endif
CVPixelBufferRef frame;
CVPixelBufferCreateWithIOSurface(kCFAllocatorDefault,
surface, NULL, &frame);
IOSurfaceUnlock(surface, 0, &_seed);
#ifndef __aarch64__
IOSurfaceUnlock(surface, kIOSurfaceLockReadOnly, NULL);
#endif
CFRelease(surface);
uint64_t timestamp;