Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Let the remix node forward Stop when its session is skipped

Jacky830aa89dbd9d
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.md
index a32a12da..8ac1b70f 100644
--- a/Research/0_binary_patch_comparison.md
+++ b/Research/0_binary_patch_comparison.md
@@ -524,7 +524,7 @@ do NOT execute these).
| 19 | **Superseded 2026-09-30, as row 18.** The same `libmisfix.dylib` injected into `misagent`, where it interposes `MGCopyAnswer` / `MGCopyAnswerWithError` and answers `UniqueDeviceID` from a config file — **all bases** | `/usr/libexec/misagent` (+ `/usr/lib/libmisfix.plist`) | **Let a provisioning profile written for a device you already own install on the guest.** `0xE8008012` (`misagent: attempt to install invalid profile`) is the ordinary refusal when the profile's `ProvisionedDevices` does not list this device — correct behaviour, and distinct from row 17's `0xE8008026`. It blocks the case the user actually wants: reusing a paid team's already-registered device rather than burning a registration slot on every VM. The UDID being compared comes from `MGCopyAnswer(kMGUniqueDeviceID)`, and three cheaper routes were ruled out by measurement before any hook was written. (1) **AMFI cannot supply it**: `security.codesigning.config` is a 4-byte flags word (read back as `0x000000CC`), not a string, so `amfi_emulate_device_udid` is dead on this board. (2) **No daemon can write it**: `/private/var/root/Library/Lockdown/data_ark.plist` carries no `UniqueDeviceID` — lockdown derives it each boot. (3) **The real source is out of reach**: TXM composes `UniqueDeviceID` from the device tree's `/chosen/chip-id`, `/chosen/unique-chip-id` and `/product/udid-version` *before the kernel runs*, and `chip-id` is fixed at `0x0000FE01` while `unique-chip-id` is the ECID the SHSH blob is bound to — changing it means the VM no longer restores. So `MGCopyAnswer` is necessarily where this is done. Fix: interpose it in `misagent` only, return a `+1` copy (matching `MGCopyAnswer`'s contract) of the configured string for `UniqueDeviceID`, and fall through untouched for every other property. Configuration is `/var/db/vphone/misfix.plist`, falling back to `/usr/lib/libmisfix.plist`, cached against mtime and size so editing the file takes effect on the next query with no restart — that is the "put it in the plist and it applies" entry point. The shipped plist is **empty**: with no `UniqueDeviceID` key the interpose returns NULL and the patch is inert, so it changes nothing until someone deliberately pastes a real device's UDID in. `installMISFixDefaults` writes the fallback plist **only when it is absent**, so re-running `cfw install` never clobbers a configured value. **Accepted inconsistency, agreed with the user rather than hidden:** only `misagent`'s profile matching sees the borrowed UDID. Xcode, lockdown and `devicectl` keep reporting the VM's own (`0000FE01-…`), because those come from a different process that is not hooked. The two therefore disagree, which is exactly what makes the profile match while the device stays identifiable as itself. Declared `system-misagent-cfw-device_identity` in `com.vphone.patchset.guest.system`; no `applicability`, not `bootEssential`, on in `standard` but inert without a configured UDID. **Partially validated (2026-09-30, `06-xcode-27`):** `cfw install` reports `[+] LC_LOAD_WEAK_DYLIB /usr/lib/libmisfix.dylib -> misagent` and `misagent` runs normally on the booted guest. Installing a real paid-team IPA against a borrowed UDID is **not** yet demonstrated, for the same host-side `devicectl` reason as row 18. See `VPhoneGuestComponents/MISFix/MISFixDeviceIdentity.c`, `MISFixConfig.c` and `Research/Guest/xcode_install_signature_gate.md`. | Y | Y | Y |
| 20 | No binary change: the launchd hook inserts `libmisfix.dylib` into `SpringBoard` at spawn, beside SystemHook, and both spawn hooks do the same for `installd`, `misagent`, `lockdownd` and `remoted` (the last two for the UDID override only) — **all bases** | none (the guest environment's `launchdhook-vphone.dylib` and `SystemHook-vphone.dylib`) | **Let an installed developer-signed app launch.** SpringBoard validates the app with MIS again before launch and, on a hacktivated guest, fails row 17's `checkTrustAndAuthorization` with `0xE8008026` ("Unable to Verify App"). The hook's `MISValidateSignatureAndCopyInfoWithProgress` detour passes `RespectUppTrustAndAuthorization = false`, so the check is never called — row 17's effect with no shared-cache write, which is what makes it usable on 27.0. launchd starts SpringBoard itself rather than through xpcproxy, so the libraries it gets are the launchd hook's choice; that hook now asks the same `vpIsMISFixTarget` SystemHook does. `MISFixInstallPolicy` stays out of it. No declaration of its own: it ships with `system-launchdaemons-boot-environment`. A load-command version (`/mf` alias, `LC_SOURCE_VERSION` dropped) was committed and reverted the same day. See "One route for libmisfix, SpringBoard included (2026-09-30)" below. | Y | Y | Y |
| 21 | No binary change: SystemHook `dlopen`s `libhapticsfix.dylib` into `SpringBoard` at startup, where it replaces every `CHHapticEngine` initialiser's IMP so the initialiser returns nil — **all bases** | none (new guest dylib `VPhoneGuestComponents/HapticsFix/libhapticsfix.c`, installed at `/usr/lib/libhapticsfix.dylib`) | **Stop SpringBoard dying the first time UIKit plays a haptic.** The VM has no haptic device — Virtualization.framework exposes none on any base — and a real device without one gets nil from `CHHapticEngine`'s initialisers, so UIKit runs with no feedback, as on every non-Pro iPad. A guest reporting an iPad Pro model instead has an OS that *expects* the haptic stack, and CoreHaptics treats its absence as an internal error: measured on `iPad16,1 26.6.2 (23G90)`, 4h14m after launch, the first feedback event ran `-[_UIFeedbackCoreHapticsIgnoreCaptureHapticsOnlyEngine _internal_createCoreHapticsEngine]` → `-[CHHapticEngine initWithAudioSession:sessionIsShared:options:error:]` → `createHapticPlayerWithOptions:` → `Haptic_RaiseException` → `objc_exception_throw`, and the unwind resumed at an address inside a `---/---` Memory Tag 255 COW region next to the commpage — `EXC_BAD_ACCESS (SIGBUS)`, `KERN_PROTECTION_FAILURE`, a dead SpringBoard. The hook restores the no-hardware answer before UIKit can reach an initialiser: the constructor `dlopen`s CoreHaptics (it is not loaded that early, and the class must be in the runtime before UIKit asks), then `method_setImplementation` on every selector that is `init` or `init` + uppercase part — covering `initWithAudioSession:sessionIsShared:options:error:` today and any renamed sibling on other bases — with one IMP that ignores its arguments and returns nil, the framework's own answer on haptic-less hardware. Scope is SpringBoard only (`vpIsSpringBoard` in SystemHook, loaded before the app/bootstrap gate that would otherwise return first): it is the one UIKit process measured creating the haptics-only engine without asking CoreHaptics first, and apps that follow the documented `capabilitiesForHardware` path already answer no on the guest. Loaded like the camera hooks rather than inserted like libmisfix because interposing must be in place at launch while a method swizzle just has to run before first use; `DISABLE_TWEAKS` and safe mode skip it with everything else SystemHook loads. Ships with `system-launchdaemons-boot-environment`; existing guests receive it through the vphoned environment update (a missing file reports no hash, which is what triggers the push) and need a respring, which is deliberately the caller's call. See `VPhoneGuestComponents/HapticsFix/libhapticsfix.c`. | Y | Y | Y |
-| 22 | No binary change: `libvcamcaptured.dylib` (already loaded into `cameracaptured` by SystemHook) wraps `+[FigCaptureSourceBackingsProvider sharedCaptureSourceBackingsProvider]` from its constructor; when the original returns nil it returns a microphone-only provider instead — **iOS 26.6+ layout, measured on iOS 27.0** | none (`VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneSource.m`) | **Give an audio-only `AVCaptureSession` its microphone on a guest with no camera.** The built-in sources come from one provider that CMCapture builds only after `BWFigCaptureDeviceVendor` creates the `Default` camera device; a VM has no ISP plugin, so `Cannot create device without create function!`, -12786, `Wiping com.apple.cameracapture.volatile`, and no provider — the microphone, described by the same `AVCaptureSession.plist` call, is lost with the camera, and iOS 27 Voice Memos fails with `CaptureSessionRecorderError` 1 (`failedToCreateAudioDevice`). The wrapper feeds the exported `FigCaptureCreateSourceInfoArrayFromDeviceAndModelSpecificPlist` a NULL device and the shipped product plist (the guest's own `VPHONE600` has none; `D47` on the iPhone17,3 image) reduced to its `"soun"` entries, without persisting, and builds the provider with `-initWithSourceInfoDictionaries:commonSettings:`. A provider the daemon built itself passes through untouched. While that provider is in use, the same dylib also makes `-[AudioRemixSessionManager startNewSessionBlocking]` return -16992 (its own session-failed code) without building the SoundAnalysis Audio Mix session, whose neural net faults cameracaptured 2 s into every spatial recording on the guest (`BNNSGraphContextMakeStreaming`, `KERN_INVALID_ADDRESS 0x300`); `BWAudioRemixAnalysisMetadataNode` already passes audio through when the session does not start. `VCamCaptured/Microphone/VCamMicrophoneRemix.m`. See `Research/Guest/ios27_capture_microphone_source.md`. | Y | Y | Y |
+| 22 | No binary change: `libvcamcaptured.dylib` (already loaded into `cameracaptured` by SystemHook) wraps `+[FigCaptureSourceBackingsProvider sharedCaptureSourceBackingsProvider]` from its constructor; when the original returns nil it returns a microphone-only provider instead — **iOS 26.6+ layout, measured on iOS 27.0** | none (`VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneSource.m`) | **Give an audio-only `AVCaptureSession` its microphone on a guest with no camera.** The built-in sources come from one provider that CMCapture builds only after `BWFigCaptureDeviceVendor` creates the `Default` camera device; a VM has no ISP plugin, so `Cannot create device without create function!`, -12786, `Wiping com.apple.cameracapture.volatile`, and no provider — the microphone, described by the same `AVCaptureSession.plist` call, is lost with the camera, and iOS 27 Voice Memos fails with `CaptureSessionRecorderError` 1 (`failedToCreateAudioDevice`). The wrapper feeds the exported `FigCaptureCreateSourceInfoArrayFromDeviceAndModelSpecificPlist` a NULL device and the shipped product plist (the guest's own `VPHONE600` has none; `D47` on the iPhone17,3 image) reduced to its `"soun"` entries, without persisting, and builds the provider with `-initWithSourceInfoDictionaries:commonSettings:`. A provider the daemon built itself passes through untouched. While that provider is in use, the same dylib also makes `-[AudioRemixSessionManager startNewSessionBlocking]` report success (0) without building the SoundAnalysis Audio Mix session, whose neural net faults cameracaptured 2 s into every spatial recording on the guest (`BNNSGraphContextMakeStreaming`, `KERN_INVALID_ADDRESS 0x300`). Success, not an error: `BWAudioRemixAnalysisMetadataNode` forwards a Stop marker on its metadata output only when the next session starts, and an error there left the movie-file sink waiting forever (measured with the first version, which returned -16992). With no session the node passes audio through and the Audio Mix metadata track is written without samples. It also logs the level of the audio passing the node. `VCamCaptured/Microphone/VCamMicrophoneRemix.m`. See `Research/Guest/ios27_capture_microphone_source.md`. | Y | Y | Y |
### Swift port status — the eight DSC patchers (2026-09-23)
diff --git a/Research/Guest/ios27_capture_microphone_source.md b/Research/Guest/ios27_capture_microphone_source.md
index 2617e1fa..fa530572 100644
--- a/Research/Guest/ios27_capture_microphone_source.md
+++ b/Research/Guest/ios27_capture_microphone_source.md
@@ -244,27 +244,73 @@ not have is a guess.
### What the hook does
-The node is written for a session that does not start
+How the node treats markers
(`-[BWAudioRemixAnalysisMetadataNode renderSampleBuffer:forInput:]`,
-0x1b0600d88):
-
-* a non-zero return from `startNewSessionBlocking` (0x1b06010bc `cbnz w0`)
- skips setting `_shouldSendData` and goes to `emitSampleBuffer:` — the audio
- passes through;
-* `submitAudioBuffer:` is called only after `sessionReady` returns YES;
-* `-finishAndGetResultsBlockingWithStartingPTS:andEndingPTS:` returns an
- error when there is no subscriber (`ldr x0, [x0, #0x10]; cbz`) instead of
- blocking, and `_sendRemixMetadataSampleBuffer` ignores its result.
-
-`VCamCaptured/Microphone/VCamMicrophoneRemix.m` replaces
-`-[AudioRemixSessionManager startNewSessionBlocking]` (`- (int)`, checked
-against the runtime type encoding before wrapping). While the daemon is
-running on the microphone-only provider, it returns -16992, the code the
-method's own failure path signals, without creating the session; otherwise it
-calls the original. The recording keeps its ambisonic audio and loses only the
-Audio Mix analysis track's data.
-
-Not yet run in a guest. To check: `vcamcaptured.log` has `remix: wrapped …` at load and
-`Audio Mix analysis session not started (-16992)` at the first recording;
-cameracaptured's pid survives a recording; then the `vpquery.log` line and a
-non-silent `.m4a`.
+0x1b0600d88, and its outlined `.cold.7` / `.cold.9`):
+
+* Start or Resume: when `_expectsToRecordOnlyOnce` is set and `sessionReady`
+ is NO it calls `startNewSessionBlocking`. Success (0x1b06010bc `cbnz w0`
+ not taken) sets `_shouldSendData` and goes to `.cold.9`, which emits the
+ marker on the node's audio output and a copy, with the track format
+ description attached, on its metadata output
+ (`_emitCopyOfMarkerBuffer:onOutput:isStartMarkerBuffer:`). Failure goes to
+ 0x1b0600f60, which emits on the audio output only.
+* Stop (`.cold.7`): clears `_shouldSendData`, calls
+ `_sendRemixMetadataSampleBuffer`, then either `abortSessionIfNeeded` (record
+ once) or `startNewSessionBlocking` for the next recording. It returns 1 —
+ marker on both outputs through `.cold.9` — unless that start fails; then the
+ Stop goes to the audio output only.
+* Audio buffers: `submitAudioBuffer:` only after `sessionReady` returns YES;
+ the buffer itself is always emitted on the audio output.
+* `-finishAndGetResultsBlockingWithStartingPTS:andEndingPTS:` with no
+ subscriber (`ldr x0, [x0, #0x10]; cbz`) signals -16992 at line 656
+ (`.cold.1`, `mov w4, #0x290`) and returns; `_sendRemixMetadataSampleBuffer`
+ ignores the result.
+
+The first version of the hook (a6589ad) returned -16992 from
+`startNewSessionBlocking`. Measured on `mictest-iphone` (bundle
+`2.4.0-local.073c7081`): no crash, the recording ran (`stream 0: 293.25 s,
+3421 reads …`, an APAC 4-channel encoder), but at Stop the movie-file sink
+logged `received marker Stop` on inputs 0 and 1 and never on input 2 (presumably
+the node's metadata output), with `signalled err=-16992 at <>:656` in between:
+Voice Memos' recording never finished. That is the Stop branch above with
+its session start failing.
+
+`VCamCaptured/Microphone/VCamMicrophoneRemix.m` now has the method report
+success (0) without creating the session, while the daemon is on the
+microphone-only provider; otherwise it calls the original (`- (int)`, checked
+against the runtime type encoding before wrapping). The node then forwards
+Start and Stop on both outputs, `sessionReady` stays NO so no audio is
+submitted to SoundAnalysis, and the finish call takes its no-subscriber error.
+What a recording loses: the Audio Mix metadata track has its format
+description and markers but no samples, so Voice Memos has no Audio Mix data
+for it. The ambisonic audio track is untouched.
+
+Keeping the node out of the graph instead (the metadata configuration that
+`FigCaptureMetadataObjectConfigurationRequiresSpatialAudioMix` reads) would
+avoid the empty track, but the predicate is a C function called inside
+CMCapture, and what puts `kCMMetadataIdentifier_QuickTimeMetadataSpatialAudioMix`
+in Voice Memos' configuration was not traced. It is the fallback if the
+writer refuses a metadata track with no samples.
+
+The same file wraps the node's `renderSampleBuffer:forInput:` (its own
+override only) to log the level of the audio it passes, about every 2 s, as
+`remix input: <ch> ch, <n> buffers, <frames> frames, <z> all zero, peak <x>
+dBFS`. That audio is what the movie file gets; the app's
+`AVCaptureAudioDataOutput` has its own sink pipeline ("Microphone Audio Data
+Sink Pipeline"), not this node.
+
+On the a6589ad run Voice Memos' live waveform stayed flat. Not established
+why. audiomxd builds the route with the SpatialCapture DSP chain
+(`flexible_video_recording`), and its converters log `2 ch, 48000 Hz,
+Float32, interleaved` and `6 ch … deinterleaved`; if the chain reads the plugin's two channels as a six-microphone array, the beamforming
+for D47's microphone array gets two real channels and four it has to invent;
+silence or near-silence after that chain is a possibility, not a finding.
+The level log above tells whether the recording itself carries sound.
+
+Not yet run in a guest. To check: `vcamcaptured.log` has `remix: wrapped …`
+and `remix: measuring …` at load, `Audio Mix analysis session not created` and
+`remix input:` lines during a recording; at Stop the sink logs `received marker
+Stop` on all three inputs and Voice Memos leaves the recording sheet; the
+`.m4a` under the app group's `Recordings/` decodes to something that is not
+zeros and opens in Voice Memos.
diff --git a/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneRemix.m b/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneRemix.m
index 7fca029d..e57a423a 100644
--- a/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneRemix.m
+++ b/VPhoneGuestComponents/VCamCaptured/Microphone/VCamMicrophoneRemix.m
@@ -3,26 +3,34 @@
// A spatial recording (Voice Memos on iOS 27 records first-order ambisonics,
// because the microphone source built from the product plist advertises
// cinematic audio) gets a BWAudioRemixAnalysisMetadataNode in its movie-file
-// pipeline. At the start marker the node calls
-// -[AudioRemixSessionManager startNewSessionBlocking], which builds a
-// SoundAnalysis movie-remix session; initialising that session's neural net
-// faults in cameracaptured on the guest (BNNSGraphContextMakeStreaming,
-// KERN_INVALID_ADDRESS 0x300), about 2 s into every recording.
+// pipeline. The node calls -[AudioRemixSessionManager startNewSessionBlocking]
+// to build a SoundAnalysis movie-remix session, and initialising that
+// session's neural net faults in cameracaptured on the guest
+// (BNNSGraphContextMakeStreaming, KERN_INVALID_ADDRESS 0x300), about 2 s into
+// every recording.
//
-// The node already copes with a session that does not start: a non-zero
-// return leaves _shouldSendData clear, buffers are passed through
-// (emitSampleBuffer:), submitAudioBuffer: is skipped while sessionReady is NO,
-// and -finishAndGetResultsBlockingWithStartingPTS:andEndingPTS: returns an
-// error instead of waiting when there is no subscriber. So while the daemon
-// runs on the microphone-only provider (no camera device: a VM), the method
-// returns the error its own failure path signals, without creating the
-// session. With a real capture device it runs unchanged.
+// While the daemon runs on the microphone-only provider (no camera device: a
+// VM), the method reports success without creating the session. Success, not
+// an error: at a Stop marker the node starts the next session, and only when
+// that succeeds does it forward the marker on its metadata output too
+// (-renderSampleBuffer:forInput:, its .cold.7 / .cold.9); an error there
+// leaves the movie-file sink waiting for a Stop that never comes. With no
+// session the node still passes audio through: -submitAudioBuffer: is called
+// only after -sessionReady, which stays NO, and
+// -finishAndGetResultsBlockingWithStartingPTS:andEndingPTS: returns an error
+// at once when there is no subscriber. The metadata track gets its format
+// description and its markers and no samples. With a real capture device the
+// method runs unchanged.
+//
+// The node's audio input is the recording's audio, so the same wrapper set
+// logs its level while the guest has no capture hardware.
// See Research/Guest/ios27_capture_microphone_source.md §7.
+#include <math.h>
+
#include "VCamCapturedPrivate.h"
-// The code -startNewSessionBlocking signals when its session does not start.
-static const int kVccRemixSessionNotStarted = -16992;
+// MARK: - session start
static IMP vcc_remix_start_orig = NULL;
static BOOL vcc_remix_skip_logged = NO;
@@ -33,12 +41,89 @@ static int vcc_remix_start_hook(id self, SEL _cmd) {
}
if (!vcc_remix_skip_logged) {
vcc_remix_skip_logged = YES;
- vcc_log(@" mic source: no capture hardware; Audio Mix analysis session not started (%d)",
- kVccRemixSessionNotStarted);
+ vcc_log(@" mic source: no capture hardware; Audio Mix analysis session not created");
}
- return kVccRemixSessionNotStarted;
+ return 0;
}
+// MARK: - recording level (diagnostic)
+
+static IMP vcc_remix_render_orig = NULL;
+static unsigned vcc_level_buffers = 0;
+static unsigned vcc_level_zero_buffers = 0;
+static uint64_t vcc_level_frames = 0;
+static float vcc_level_peak = 0;
+
+static void vcc_measure_level(CMSampleBufferRef sbuf) {
+ CMFormatDescriptionRef fd = CMSampleBufferGetFormatDescription(sbuf);
+ if (!fd || CMFormatDescriptionGetMediaType(fd) != kCMMediaType_Audio) return;
+ const AudioStreamBasicDescription *asbd =
+ CMAudioFormatDescriptionGetStreamBasicDescription(fd);
+ CMItemCount frames = CMSampleBufferGetNumSamples(sbuf);
+ if (!asbd || frames <= 0) return;
+ if (asbd->mFormatID != kAudioFormatLinearPCM ||
+ !(asbd->mFormatFlags & kAudioFormatFlagIsFloat) ||
+ asbd->mBitsPerChannel != 32) {
+ static BOOL logged;
+ if (!logged) {
+ logged = YES;
+ vcc_log(@" remix input: format %u flags 0x%x %u bit, %u ch; level not measured",
+ (unsigned)asbd->mFormatID, (unsigned)asbd->mFormatFlags,
+ (unsigned)asbd->mBitsPerChannel, (unsigned)asbd->mChannelsPerFrame);
+ }
+ return;
+ }
+
+ size_t listSize = 0;
+ if (CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
+ sbuf, &listSize, NULL, 0, NULL, NULL, 0, NULL) != noErr ||
+ listSize == 0) {
+ return;
+ }
+ AudioBufferList *list = malloc(listSize);
+ CMBlockBufferRef block = NULL;
+ if (!list) return;
+ if (CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(
+ sbuf, NULL, list, listSize, NULL, NULL,
+ kCMSampleBufferFlag_AudioBufferList_Assure16ByteAlignment,
+ &block) == noErr) {
+ float peak = 0;
+ for (UInt32 b = 0; b < list->mNumberBuffers; b++) {
+ const float *s = list->mBuffers[b].mData;
+ size_t n = list->mBuffers[b].mDataByteSize / sizeof(float);
+ for (size_t i = 0; s && i < n; i++) {
+ float v = fabsf(s[i]);
+ if (v > peak) peak = v;
+ }
+ }
+ vcc_level_buffers++;
+ vcc_level_frames += (uint64_t)frames;
+ if (peak == 0) vcc_level_zero_buffers++;
+ if (peak > vcc_level_peak) vcc_level_peak = peak;
+ // About every 2 s at 48 kHz.
+ if (vcc_level_frames >= 96000) {
+ vcc_log(@" remix input: %u ch, %u buffers, %llu frames, %u all zero, peak %.1f dBFS",
+ (unsigned)asbd->mChannelsPerFrame, vcc_level_buffers,
+ (unsigned long long)vcc_level_frames, vcc_level_zero_buffers,
+ vcc_level_peak > 0 ? 20 * log10f(vcc_level_peak) : -INFINITY);
+ vcc_level_buffers = vcc_level_zero_buffers = 0;
+ vcc_level_frames = 0;
+ vcc_level_peak = 0;
+ }
+ }
+ if (block) CFRelease(block);
+ free(list);
+}
+
+static void vcc_remix_render_hook(id self, SEL _cmd, CMSampleBufferRef sbuf,
+ id input) {
+ if (sbuf && vcc_microphone_only_source_active()) vcc_measure_level(sbuf);
+ ((void (*)(id, SEL, CMSampleBufferRef, id))vcc_remix_render_orig)(
+ self, _cmd, sbuf, input);
+}
+
+// MARK: - install
+
void vcc_install_remix_session_skip(void) {
Class cls = NSClassFromString(@"AudioRemixSessionManager");
SEL sel = NSSelectorFromString(@"startNewSessionBlocking");
@@ -57,4 +142,15 @@ void vcc_install_remix_session_skip(void) {
vcc_remix_start_orig = method_setImplementation(m, (IMP)vcc_remix_start_hook);
vcc_log(@" remix: wrapped -[AudioRemixSessionManager startNewSessionBlocking] (orig imp=%p)",
vcc_remix_start_orig);
+
+ Class node = NSClassFromString(@"BWAudioRemixAnalysisMetadataNode");
+ Method r = node ? class_getInstanceMethod(
+ node, NSSelectorFromString(@"renderSampleBuffer:forInput:"))
+ : NULL;
+ // Only the node's own override; never rewrite an inherited BWNode method.
+ if (r && r != class_getInstanceMethod(class_getSuperclass(node),
+ method_getName(r))) {
+ vcc_remix_render_orig = method_setImplementation(r, (IMP)vcc_remix_render_hook);
+ vcc_log(@" remix: measuring -[BWAudioRemixAnalysisMetadataNode renderSampleBuffer:forInput:] input");
+ }
}
diff --git a/VPhoneGuestComponents/VCamCaptured/VCamCapturedPrivate.h b/VPhoneGuestComponents/VCamCaptured/VCamCapturedPrivate.h
index 27b33369..6549c989 100644
--- a/VPhoneGuestComponents/VCamCaptured/VCamCapturedPrivate.h
+++ b/VPhoneGuestComponents/VCamCaptured/VCamCapturedPrivate.h
@@ -48,8 +48,9 @@ void vcc_install_microphone_source(void);
BOOL vcc_microphone_only_source_active(void);
// While that provider is in use, -[AudioRemixSessionManager
-// startNewSessionBlocking] fails the way it does when its session cannot
-// start, instead of running the Audio Mix neural net that faults on a guest.
+// startNewSessionBlocking] reports success without creating the Audio Mix
+// session whose neural net faults on a guest, and the remix node's audio
+// input level is logged.
void vcc_install_remix_session_skip(void);
void vcc_install_synthetic(void);