Skip to content

Commit ebf6708

Browse files
committed
qb/Makefile: wire up AVFoundation camera + recording drivers (HAVE_AVF, macOS 10.7+)
camera/drivers/avfoundation.m and record/drivers/record_avfoundation.m were already included by the Xcode builds (via griffin_objc.m under HAVE_AVF) but had no path to get compiled by the qb-driven top-level Makefile. On a plain 'make' on macOS the AVFoundation camera driver simply did not exist in the binary. Wire it up: * qb/config.params.sh: add 'HAVE_AVF=auto'. The qb machinery auto-derives USER_AVF and the --enable-avf / --disable-avf flags from this declaration. * qb/config.libs.sh: inside the Darwin block, decide HAVE_AVF based on (user override) && (framework available) && either HAVE_COCOATOUCH (iOS/tvOS builds - always modern enough) or macos_target_pre_10_7 = no. Matches the 10.7 gate already used for Metal / Vulkan / microphone in the same block. The pre-existing 'check_lib "" AVFOUNDATION "-framework AVFoundation"' was detecting the framework but its result was never consumed anywhere; move it up so the version gate and framework gate run together before macos_target_* are unset, and consume HAVE_AVFOUNDATION directly. A forced --enable-avf on a target missing the framework now fails loudly instead of silently. * Makefile.common: add a new block (next to Video4Linux 2) that compiles camera/drivers/avfoundation.o and record/drivers/ record_avfoundation.o when HAVE_AVF is on, defines -DHAVE_AVF so camera_driver.c / record_driver.c register the drivers, and links -framework AVFoundation/CoreVideo/CoreMedia/Accelerate (plus UIKit on HAVE_COCOATOUCH for the rotation-detection code path in avfoundation.m). The 10.7 floor is chosen to match the APIs the two .m files actually use: AVCaptureSession, dispatch_queue_t blocks, @autoreleasepool as a statement. On Tiger/Leopard / PowerPC / Xcode 3.1 those are absent, so the drivers can't be built there; they're silently disabled with a die:notice matching the pattern used for microphone and Metal. Note: -framework AVFoundation already appears on the link line when HAVE_MICROPHONE=1 (coreaudio_mic_macos.o) or HAVE_COREAUDIO3=1. make tolerates the repeat and the linker de-duplicates; cleaning this up into a shared AVFOUNDATION_LIBS guard is a separate refactor. No behavior change for non-Darwin builds or for Xcode/iOS builds (both paths already define HAVE_AVF through their own toolchains).
1 parent 141d2a6 commit ebf6708

3 files changed

Lines changed: 46 additions & 2 deletions

File tree

Makefile.common

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,6 +2263,23 @@ ifeq ($(HAVE_V4L2),1)
22632263
LIBS += $(V4L2_LIBS)
22642264
endif
22652265

2266+
# AVFoundation camera + recording (Apple, macOS 10.7+ / iOS). The
2267+
# 10.7 gate is enforced in qb/config.libs.sh (see the HAVE_AVF block
2268+
# there); this section just wires the object files and frameworks in
2269+
# when HAVE_AVF is on. Note that HAVE_MICROPHONE and HAVE_COREAUDIO3
2270+
# above also add -framework AVFoundation for their own reasons; make
2271+
# tolerates the repeat and the linker de-duplicates.
2272+
ifeq ($(HAVE_AVF), 1)
2273+
DEFINES += -DHAVE_AVF
2274+
OBJ += camera/drivers/avfoundation.o \
2275+
record/drivers/record_avfoundation.o
2276+
LIBS += -framework AVFoundation -framework CoreVideo \
2277+
-framework CoreMedia -framework Accelerate
2278+
ifeq ($(HAVE_COCOATOUCH), 1)
2279+
LIBS += -framework UIKit
2280+
endif
2281+
endif
2282+
22662283
# FFmpeg
22672284

22682285
ifeq ($(HAVE_FFMPEG), 1)

qb/config.libs.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,33 @@ if [ "$OS" = 'Darwin' ]; then
330330
else
331331
HAVE_RETROARCH_PLAYLIST_MANAGER=no
332332
fi
333+
334+
# AVFoundation camera + recording drivers. The framework itself
335+
# is Apple-wide, but the RetroArch driver sources (camera/drivers/
336+
# avfoundation.m, record/drivers/record_avfoundation.m) use APIs
337+
# that landed in macOS 10.7 (AVCaptureSession, dispatch_queue_t
338+
# blocks, @autoreleasepool as a statement). On iOS/tvOS any
339+
# HAVE_COCOATOUCH build is modern enough in practice. On macOS
340+
# gate on the same 10.7 threshold we already use for
341+
# Metal/Vulkan/microphone. Also requires the AVFoundation
342+
# framework to be present in the SDK (checked immediately below);
343+
# we pre-check it here so the version gate and framework gate are
344+
# evaluated together before macos_target_ver goes out of scope.
345+
check_lib '' AVFOUNDATION "-framework AVFoundation"
346+
if [ "${USER_AVF:-}" = 'no' ]; then
347+
HAVE_AVF=no
348+
elif [ "$HAVE_AVFOUNDATION" != 'yes' ]; then
349+
HAVE_AVF=no
350+
[ "${USER_AVF:-}" = 'yes' ] && \
351+
die 1 "Forced AVFoundation enable but -framework AVFoundation is not available in the SDK."
352+
elif [ "$HAVE_COCOATOUCH" = 'yes' ] || \
353+
[ "$macos_target_pre_10_7" = 'no' ]; then
354+
HAVE_AVF=yes
355+
else
356+
HAVE_AVF=no
357+
die : "Notice: macOS target $macos_target_ver is pre-10.7; disabling AVFoundation camera/recording drivers. Override with --enable-avf."
358+
fi
359+
333360
unset macos_target_ver macos_target_pre_10_7 macos_target_pre_10_11
334361

335362
if [ "$HAVE_METAL" = yes ] || [ "$HAVE_VULKAN" = yes ]; then
@@ -338,7 +365,6 @@ if [ "$OS" = 'Darwin' ]; then
338365
check_lib '' COCOA "-framework AppKit" NSApplicationMain
339366
fi
340367

341-
check_lib '' AVFOUNDATION "-framework AVFoundation"
342368
check_lib '' CORELOCATION "-framework CoreLocation"
343369
check_lib '' IOHIDMANAGER "-framework IOKit" IOHIDManagerCreate
344370
check_lib '' AL "-framework OpenAL" alcOpenDevice

qb/config.params.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,5 @@ HAVE_SMBCLIENT=auto # SMB client support
216216
HAVE_BUILTINSMBCLIENT=no # Use builtin libsmb2
217217
HAVE_COCOA=auto # Cocoa support (Darwin/Apple)
218218
HAVE_RETROARCH_PLAYLIST_MANAGER=auto # iOS/tvOS + macOS 10.11+ playlist helper (see qb/config.libs.sh)
219-
HAVE_MFI=auto # GameController.framework joypad support (Apple)
219+
HAVE_MFI=auto # GameController.framework joypad support (Apple)
220+
HAVE_AVF=auto # AVFoundation camera + recording drivers (Apple, macOS 10.7+ / iOS)

0 commit comments

Comments
 (0)