From d412d64ef96d80b5f66397929d0b3670426193bf Mon Sep 17 00:00:00 2001 From: andrewsoncha <65234283+andrewsoncha@users.noreply.github.com> Date: Wed, 1 Apr 2026 16:10:12 -0400 Subject: [PATCH] plugins: Fix build issues in Xcode 26.4 Replaced implicit type conversion within macOS plugins (mac-capture, mac-syphon, mac-videotoolbox, mac-virtualcam) with explicit type conversions to clear compile errors with Apple Clang 21.0 and Xcode 26.4. Co-authored-by: PatTheMav Co-authored-by: jcm <6864788+jcm93@users.noreply.github.com> --- plugins/mac-capture/mac-audio.c | 11 +---------- plugins/mac-capture/mac-sck-common.m | 9 ++++++--- plugins/mac-syphon/syphon.m | 9 ++++++--- plugins/mac-videotoolbox/encoder.c | 9 +++++---- .../src/dal-plugin/CMSampleBufferUtils.mm | 3 ++- .../mac-virtualcam/src/dal-plugin/OBSDALStream.mm | 13 +++++++------ 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/plugins/mac-capture/mac-audio.c b/plugins/mac-capture/mac-audio.c index 8d9dca997..9e6111a42 100644 --- a/plugins/mac-capture/mac-audio.c +++ b/plugins/mac-capture/mac-audio.c @@ -438,16 +438,7 @@ static OSStatus input_callback(void *data, AudioUnitRenderActionFlags *action_fl : ca->buf_list->mNumberBuffers; audio.format = ca->format; audio.samples_per_sec = ca->sample_rate; - static double factor = 0.; - static mach_timebase_info_data_t info = {0, 0}; - if (info.numer == 0 && info.denom == 0) { - mach_timebase_info(&info); - factor = ((double)info.numer) / info.denom; - } - if (info.numer != info.denom) - audio.timestamp = (uint64_t)(factor * ts_data->mHostTime); - else - audio.timestamp = ts_data->mHostTime; + audio.timestamp = AudioConvertHostTimeToNanos(ts_data->mHostTime); obs_source_output_audio(ca->source, &audio); diff --git a/plugins/mac-capture/mac-sck-common.m b/plugins/mac-capture/mac-sck-common.m index 9dd862f01..1a377802a 100644 --- a/plugins/mac-capture/mac-sck-common.m +++ b/plugins/mac-capture/mac-sck-common.m @@ -275,10 +275,13 @@ API_AVAILABLE(macos(12.5)) void screen_stream_video_update(struct screen_capture needs_to_update_properties = true; } } else { - size_t width = CVPixelBufferGetWidth(image_buffer); - size_t height = CVPixelBufferGetHeight(image_buffer); + int width = CVPixelBufferGetWidth(image_buffer); + int height = CVPixelBufferGetHeight(image_buffer); - if ((sc->frame.size.width != width) || (sc->frame.size.height != height)) { + int frameWidth = (int) sc->frame.size.width; + int frameHeight = (int) sc->frame.size.height; + + if ((frameWidth != width) || (frameHeight != height)) { sc->frame.size.width = width; sc->frame.size.height = height; needs_to_update_properties = true; diff --git a/plugins/mac-syphon/syphon.m b/plugins/mac-syphon/syphon.m index 8336e74cb..953190376 100644 --- a/plugins/mac-syphon/syphon.m +++ b/plugins/mac-syphon/syphon.m @@ -630,10 +630,13 @@ static void syphon_video_tick(void *data, float seconds) if (s->crop) crop = &s->crop_rect; + float origin_x = (float) crop->origin.x; + float origin_y = (float) (s->height - crop->origin.y); + float end_x = (float) (s->width - crop->size.width); + float end_y = (float) crop->size.height; + obs_enter_graphics(); - build_sprite_rect(gs_vertexbuffer_get_data(s->vertbuffer), (float) crop->origin.x, - s->height - (float) crop->origin.y, s->width - (float) crop->size.width, - (float) crop->size.height); + build_sprite_rect(gs_vertexbuffer_get_data(s->vertbuffer), origin_x, origin_y, end_x, end_y); obs_leave_graphics(); } diff --git a/plugins/mac-videotoolbox/encoder.c b/plugins/mac-videotoolbox/encoder.c index acd94c698..ad923eefa 100644 --- a/plugins/mac-videotoolbox/encoder.c +++ b/plugins/mac-videotoolbox/encoder.c @@ -539,12 +539,13 @@ static OSStatus create_encoder(struct vt_encoder *enc) kVTCompressionPropertyKey_AllowFrameReordering, kVTCompressionPropertyKey_ProfileLevel}; - SInt32 key_frame_interval = (SInt32)(enc->keyint * ((float)enc->fps_num / enc->fps_den)); - float expected_framerate = (float)enc->fps_num / enc->fps_den; + int actual_frame_rate = enc->fps_num / enc->fps_den; + int key_frame_interval = enc->keyint * actual_frame_rate; + CFNumberRef MaxKeyFrameInterval = - CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &key_frame_interval); + CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &key_frame_interval); CFNumberRef ExpectedFrameRate = - CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat32Type, &expected_framerate); + CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &actual_frame_rate); CFTypeRef AllowFrameReordering = enc->bframes ? kCFBooleanTrue : kCFBooleanFalse; video_t *video = obs_encoder_video(enc->encoder); diff --git a/plugins/mac-virtualcam/src/dal-plugin/CMSampleBufferUtils.mm b/plugins/mac-virtualcam/src/dal-plugin/CMSampleBufferUtils.mm index 2085b3f9a..47fd2d2d8 100644 --- a/plugins/mac-virtualcam/src/dal-plugin/CMSampleBufferUtils.mm +++ b/plugins/mac-virtualcam/src/dal-plugin/CMSampleBufferUtils.mm @@ -19,7 +19,8 @@ CMSampleTimingInfo CMSampleTimingInfoForTimestamp(uint64_t timestampNanos, uint3 CMTimeScale scale = 600; CMSampleTimingInfo timing; timing.duration = CMTimeMake(fpsDenominator * scale, fpsNumerator * scale); - timing.presentationTimeStamp = CMTimeMakeWithSeconds(timestampNanos / (double) NSEC_PER_SEC, scale); + CMTime timestamp = CMTimeMake(timestampNanos, NSEC_PER_SEC); + timing.presentationTimeStamp = CMTimeConvertScale(timestamp, scale, kCMTimeRoundingMethod_QuickTime); timing.decodeTimeStamp = kCMTimeInvalid; return timing; } diff --git a/plugins/mac-virtualcam/src/dal-plugin/OBSDALStream.mm b/plugins/mac-virtualcam/src/dal-plugin/OBSDALStream.mm index 18a55acd7..036cca5bd 100644 --- a/plugins/mac-virtualcam/src/dal-plugin/OBSDALStream.mm +++ b/plugins/mac-virtualcam/src/dal-plugin/OBSDALStream.mm @@ -123,8 +123,8 @@ { if (NSEqualSizes(_testCardSize, NSZeroSize)) { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSInteger width = [[defaults objectForKey:kTestCardWidthKey] integerValue]; - NSInteger height = [[defaults objectForKey:kTestCardHeightKey] integerValue]; + double width = [[defaults objectForKey:kTestCardWidthKey] doubleValue]; + double height = [[defaults objectForKey:kTestCardHeightKey] doubleValue]; if (width == 0 || height == 0) { _testCardSize = NSMakeSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); } else { @@ -238,9 +238,9 @@ NSParameterAssert(pxdata != NULL); CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB(); - CGContextRef context = CGBitmapContextCreate(pxdata, width, height, 8, - CVPixelBufferGetBytesPerRowOfPlane(pxbuffer, 0), rgbColorSpace, - kCGImageAlphaPremultipliedFirst | kCGImageByteOrder32Big); + CGContextRef context = + CGBitmapContextCreate(pxdata, width, height, 8, CVPixelBufferGetBytesPerRowOfPlane(pxbuffer, 0), rgbColorSpace, + (CGBitmapInfo) kCGImageAlphaPremultipliedFirst | kCGImageByteOrder32Big); CFRelease(rgbColorSpace); NSParameterAssert(context); @@ -249,7 +249,8 @@ NSRect rect = NSMakeRect(0, 0, self.testCardImage.size.width, self.testCardImage.size.height); CGImageRef image = [self.testCardImage CGImageForProposedRect:&rect context:nsContext hints:nil]; - CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image), CGImageGetHeight(image)), image); + CGContextDrawImage(context, CGRectMake(0, 0, (double) CGImageGetWidth(image), (double) CGImageGetHeight(image)), + image); // DrawDialWithFrame( // NSMakeRect(0, 0, width, height),