Skip to content

Commit 3498771

Browse files
committed
Makefile: build coreaudio3.m with -fobjc-arc
audio/drivers/coreaudio3.m is written assuming ARC: - Uses __bridge / __bridge_retained / __bridge_transfer casts in the coreaudio3_init / coreaudio3_write / coreaudio3_free hooks to move an NSObject through the void* driver-interface without the caller needing to know its real type. - Zero manual [x retain] / [x release] / [x autorelease] calls anywhere in the file. - Assigns Obj-C locals to ivars ('_au = au') and relies on ARC's strong-ivar semantics to retain them; dealloc has no matching releases. - Leaks every +1 local (renderFormat at line 253 / 268, the dispatch_semaphore at line 218) under MRC because nothing releases them. The file was enabled by '--enable-coreaudio3' (off by default, per qb/config.params.sh line 127), but when enabled the top-level qb Makefile build compiled it without -fobjc-arc - since it was not in the per-file override list at the top of this Makefile alongside metal.o and mfi_joypad.o. Under MRC compilation the file silently leaks every Obj-C object it creates, which in audio-driver code means a steady accumulation with every driver reinit (device hotplug, latency change, etc.). The __bridge* casts still compile under MRC (they're ARC's ownership-casts but are also valid non-ARC syntax), so the build succeeded and nothing fired - the leaks were invisible until you ran Instruments. No Xcode project references this file (grepped all of pkg/apple/*/ project.pbxproj - empty result), so the Xcode-side per-file CLANG_ENABLE_OBJC_ARC=YES path doesn't exist for it yet. If that integration ever lands, the Xcode target would also need to flip it on. Added coreaudio3.o to the ARC override list alongside metal.o and mfi_joypad.o. Also updated the now-stale 'These three Objective-C files' comment (it had said three but only listed two) and broadened the ARC-constructs example from '__weak, etc.' to '__weak, __bridge*, no manual retain/release' to cover this file's shape too. Thread-safety: unchanged - this is a compile-flag change, no runtime behaviour is touched. With ARC on, the existing ivar assignments and bridge casts produce the intended retain counts; the per-init-call leaks are reclaimed when the CoreAudio3 instance is released. Reachability: anyone who enables --enable-coreaudio3. Default builds are unaffected.
1 parent 648558d commit 3498771

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,16 @@ $(OBJDIR)/%.o: %.m
266266
@$(if $(Q), $(shell echo echo OBJC $<),)
267267
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
268268

269-
# ARC (Automatic Reference Counting) overrides. These three Objective-C
270-
# files use ARC-only constructs (__weak, etc.) and must be built with
271-
# -fobjc-arc. The rest of the RetroArch Objective-C code is MRC-written
272-
# (explicit retain/release, NSAutoreleasePool, etc.) and would fail to
273-
# compile under ARC — so we cannot set -fobjc-arc globally. Xcode does
274-
# the equivalent via per-file CLANG_ENABLE_OBJC_ARC=YES build settings.
269+
# ARC (Automatic Reference Counting) overrides. These Objective-C
270+
# files use ARC-only constructs (__weak, __bridge*, no manual
271+
# retain/release) and must be built with -fobjc-arc. The rest of the
272+
# RetroArch Objective-C code is MRC-written (explicit retain/release,
273+
# NSAutoreleasePool, etc.) and would fail to compile under ARC — so
274+
# we cannot set -fobjc-arc globally. Xcode does the equivalent via
275+
# per-file CLANG_ENABLE_OBJC_ARC=YES build settings.
275276
$(OBJDIR)/gfx/drivers/metal.o: OBJCFLAGS += -fobjc-arc
276277
$(OBJDIR)/input/drivers_joypad/mfi_joypad.o: OBJCFLAGS += -fobjc-arc
278+
$(OBJDIR)/audio/drivers/coreaudio3.o: OBJCFLAGS += -fobjc-arc
277279

278280
$(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS)
279281
@mkdir -p $(dir $@)

0 commit comments

Comments
 (0)