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).
This commit is contained in:
U-DESKTOP-SPFP6AQ\twistedtechre committed 2026-04-23 18:26:10 +02:00
1 parent 141d2a6219
commit ebf670802f
3 files changed
+46 -2

No files matched your search

+17
View File
@@ -2263,6 +2263,23 @@ ifeq ($(HAVE_V4L2),1)
LIBS += $(V4L2_LIBS)
endif
# AVFoundation camera + recording (Apple, macOS 10.7+ / iOS). The
# 10.7 gate is enforced in qb/config.libs.sh (see the HAVE_AVF block
# there); this section just wires the object files and frameworks in
# when HAVE_AVF is on. Note that HAVE_MICROPHONE and HAVE_COREAUDIO3
# above also add -framework AVFoundation for their own reasons; make
# tolerates the repeat and the linker de-duplicates.
ifeq ($(HAVE_AVF), 1)
DEFINES += -DHAVE_AVF
OBJ += camera/drivers/avfoundation.o \
record/drivers/record_avfoundation.o
LIBS += -framework AVFoundation -framework CoreVideo \
-framework CoreMedia -framework Accelerate
ifeq ($(HAVE_COCOATOUCH), 1)
LIBS += -framework UIKit
endif
endif
# FFmpeg
ifeq ($(HAVE_FFMPEG), 1)
+27 -1
View File
@@ -330,6 +330,33 @@ if [ "$OS" = 'Darwin' ]; then
else
HAVE_RETROARCH_PLAYLIST_MANAGER=no
fi
# AVFoundation camera + recording drivers. The framework itself
# is Apple-wide, but the RetroArch driver sources (camera/drivers/
# avfoundation.m, record/drivers/record_avfoundation.m) use APIs
# that landed in macOS 10.7 (AVCaptureSession, dispatch_queue_t
# blocks, @autoreleasepool as a statement). On iOS/tvOS any
# HAVE_COCOATOUCH build is modern enough in practice. On macOS
# gate on the same 10.7 threshold we already use for
# Metal/Vulkan/microphone. Also requires the AVFoundation
# framework to be present in the SDK (checked immediately below);
# we pre-check it here so the version gate and framework gate are
# evaluated together before macos_target_ver goes out of scope.
check_lib '' AVFOUNDATION "-framework AVFoundation"
if [ "${USER_AVF:-}" = 'no' ]; then
HAVE_AVF=no
elif [ "$HAVE_AVFOUNDATION" != 'yes' ]; then
HAVE_AVF=no
[ "${USER_AVF:-}" = 'yes' ] && \
die 1 "Forced AVFoundation enable but -framework AVFoundation is not available in the SDK."
elif [ "$HAVE_COCOATOUCH" = 'yes' ] || \
[ "$macos_target_pre_10_7" = 'no' ]; then
HAVE_AVF=yes
else
HAVE_AVF=no
die : "Notice: macOS target $macos_target_ver is pre-10.7; disabling AVFoundation camera/recording drivers. Override with --enable-avf."
fi
unset macos_target_ver macos_target_pre_10_7 macos_target_pre_10_11
if [ "$HAVE_METAL" = yes ] || [ "$HAVE_VULKAN" = yes ]; then
@@ -338,7 +365,6 @@ if [ "$OS" = 'Darwin' ]; then
check_lib '' COCOA "-framework AppKit" NSApplicationMain
fi
check_lib '' AVFOUNDATION "-framework AVFoundation"
check_lib '' CORELOCATION "-framework CoreLocation"
check_lib '' IOHIDMANAGER "-framework IOKit" IOHIDManagerCreate
check_lib '' AL "-framework OpenAL" alcOpenDevice
+2 -1
View File
@@ -216,4 +216,5 @@ HAVE_SMBCLIENT=auto # SMB client support
HAVE_BUILTINSMBCLIENT=no # Use builtin libsmb2
HAVE_COCOA=auto # Cocoa support (Darwin/Apple)
HAVE_RETROARCH_PLAYLIST_MANAGER=auto # iOS/tvOS + macOS 10.11+ playlist helper (see qb/config.libs.sh)
HAVE_MFI=auto # GameController.framework joypad support (Apple)
HAVE_MFI=auto # GameController.framework joypad support (Apple)
HAVE_AVF=auto # AVFoundation camera + recording drivers (Apple, macOS 10.7+ / iOS)