Retire legacy sources and verify managed iOS deployment
This commit is contained in:
@@ -107,7 +107,7 @@ scripts/build-xcframework.sh --all
|
||||
The `apple-dev` CMake preset produces a 1.9 MB `libvoicecat.a` containing only voicecat's
|
||||
own object files — vcpkg's static dependencies (protobuf, mbedtls, libsodium, opus, sqlite3,
|
||||
spdlog, asio, abseil, …) are 107 separate `.a` files under `vcpkg_installed/arm64-osx/lib/`,
|
||||
and the vendored RNNoise noise-suppression lib (`third_party/rnnoise/`, built as a CMake
|
||||
and the vendored RNNoise noise-suppression lib (`native/rnnoise/`, built as a CMake
|
||||
target → `build/<preset>/lib/librnnoise.a`) is another. A Swift Package binary target can
|
||||
only link ONE `.a` per XCFramework slice, so `build-xcframework.sh` merges them all — vcpkg
|
||||
deps plus the locally-built vendored libs — into a single self-contained `libvoicecat-fat.a`
|
||||
|
||||
@@ -4,14 +4,14 @@
|
||||
|
||||
The managed client now implements the Swift client's functional surface: profiles and Keychain authentication, TOFU, protected channels, hierarchical channel presentation and roster state, channel and modeless private text, microphone/auxiliary/screen-audio streams, selectable Core Audio devices, VAD/PTT/always-on input, stereo microphone, RNNoise, per-stream receive tuning, self/server mute and deafen, full channel configuration, moderation, permissions, account administration, event sounds and speech. It imports the legacy Swift profile, TOFU and Keychain state during cutover. Capture is converted to interleaved 48 kHz int16 PCM through `AVAudioConverter`; playback converts the shared bounded `PcmRing` into Core Audio's native planar Float32 layout inside an allocation-free, non-blocking `AVAudioSourceNode` callback.
|
||||
|
||||
The Swift app remains the release oracle until the managed app passes the manual VoiceOver and real multi-human call matrix. Produce and validate an ad-hoc Release bundle with `zsh clients/apple/dotnet/publish-macos.sh --dry-run`. The script prefers `/usr/local/share/dotnet/dotnet`, where the pinned Apple workload is installed; set `VOICECAT_DOTNET` to override that host. Signing is performed on `bin/Release/distribution/VoiceCat.app`, leaving MSBuild's incremental app bundle untouched. For distribution, set `VOICECAT_CODESIGN_IDENTITY`; setting `APPLE_ID`, `APPLE_TEAM_ID`, and `APPLE_APP_PASSWORD` additionally submits, staples, and Gatekeeper-validates the notarized bundle.
|
||||
The managed clients are the supported implementation. Manual VoiceOver and real multi-human call validation remain release gates. Produce and validate an ad-hoc Release bundle with `zsh clients/apple/dotnet/publish-macos.sh --dry-run`. The script prefers `/usr/local/share/dotnet/dotnet`, where the pinned Apple workload is installed; set `VOICECAT_DOTNET` to override that host. Signing is performed on `bin/Release/distribution/VoiceCat.app`, leaving MSBuild's incremental app bundle untouched. For distribution, set `VOICECAT_CODESIGN_IDENTITY`; setting `APPLE_ID`, `APPLE_TEAM_ID`, and `APPLE_APP_PASSWORD` additionally submits, staples, and Gatekeeper-validates the notarized bundle.
|
||||
|
||||
Build on Apple Silicon macOS 27 with Xcode 27, .NET SDK 10.0.401 and workload set 10.0.401. Homebrew `protobuf` supplies a native arm64 `protoc`; the current `Grpc.Tools` package contains only an x64 macOS compiler.
|
||||
|
||||
```bash
|
||||
sudo dotnet workload install macos ios --version 10.0.401
|
||||
brew install protobuf # if /opt/homebrew/bin/protoc is not already present
|
||||
cmake -S dotnet/native -B dotnet/artifacts/native-build -DCMAKE_BUILD_TYPE=Release -DVOICECAT_DOTNET_RID=osx-arm64
|
||||
cmake -S native/media -B dotnet/artifacts/native-build -DCMAKE_BUILD_TYPE=Release -DVOICECAT_DOTNET_RID=osx-arm64
|
||||
cmake --build dotnet/artifacts/native-build --config Release --target voicecat_media --parallel 2
|
||||
cmake --install dotnet/artifacts/native-build --config Release --component DotnetMedia --prefix dotnet/artifacts/native
|
||||
dotnet restore clients/apple/dotnet/VoiceCat.Apple.slnx
|
||||
@@ -29,7 +29,10 @@ dotnet build clients/apple/dotnet/VoiceCat.iOS/VoiceCat.iOS.csproj -c Debug -r i
|
||||
For a physical device, use the checked-in build and deployment wrappers. The iPhone must be
|
||||
paired and trusted, and Xcode must have an Apple Development identity and provisioning profile
|
||||
for both `me.iamtalon.voicecat` and `me.iamtalon.voicecat.broadcast`. Let automatic signing
|
||||
select them, or set `VOICECAT_CODESIGN_KEY` and `VOICECAT_CODESIGN_PROVISION` before building.
|
||||
select them, or set `VOICECAT_CODESIGN_KEY`, `VOICECAT_CODESIGN_PROVISION`, and
|
||||
`VOICECAT_DEVELOPMENT_TEAM` before building. The development team is required by the retained
|
||||
ReplayKit extension's Xcode build. Set `VOICECAT_ALLOW_PROVISIONING_UPDATES=1` only when Xcode
|
||||
needs to create or download a profile.
|
||||
|
||||
```bash
|
||||
clients/apple/dotnet/build-ios-device.sh --configuration Debug
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../../dotnet/src/VoiceCat.Core/VoiceCat.Core.csproj" />
|
||||
<BundleResource Include="../../Sources/VoiceCatCore/Sounds/*.wav" Link="Sounds/%(Filename)%(Extension)" />
|
||||
<BundleResource Include="../../../../assets/sounds/*.wav" Link="Sounds/%(Filename)%(Extension)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Every managed media project stages the same dylib for ordinary .NET consumers.
|
||||
|
||||
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
@@ -42,8 +42,8 @@
|
||||
<BuildOutput>.</BuildOutput>
|
||||
<CodesignEntitlements>$(VoiceCatBroadcastOutput)/VoiceCatBroadcast.xcent</CodesignEntitlements>
|
||||
</AdditionalAppExtensions>
|
||||
<BundleResource Include="../../Sources/VoiceCatCore/Sounds/*.wav" Link="Sounds/%(Filename)%(Extension)" />
|
||||
<ImageAsset Include="../../iOS/VoiceCatiOS/Assets.xcassets/**" Link="Assets.xcassets/%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
<BundleResource Include="../../../../assets/sounds/*.wav" Link="Sounds/%(Filename)%(Extension)" />
|
||||
<ImageAsset Include="Assets.xcassets/**" Link="Assets.xcassets/%(RecursiveDir)%(Filename)%(Extension)" />
|
||||
</ItemGroup>
|
||||
<Target Name="VoiceCatBuildBroadcastExtension" BeforeTargets="_ResolveAppExtensionReferences">
|
||||
<Exec Command=""$(MSBuildThisFileDirectory)build-broadcast-extension.sh" "$(Configuration)" "$(VoiceCatBroadcastSdk)" "$(VoiceCatBroadcastArch)" "$(VoiceCatBroadcastOutput)"" />
|
||||
|
||||
@@ -6,26 +6,32 @@ sdk="${2:?sdk is required}"
|
||||
architecture="${3:?architecture is required}"
|
||||
output="${4:?output directory is required}"
|
||||
script_dir="${0:A:h}"
|
||||
project="$script_dir/../../iOS/VoiceCatiOS.xcodeproj"
|
||||
project="$script_dir/../../../../native/apple/broadcast/VoiceCatBroadcast.xcodeproj"
|
||||
|
||||
mkdir -p "$output"
|
||||
signing=()
|
||||
if [[ "$sdk" == "iphonesimulator" ]]; then
|
||||
signing+=(CODE_SIGNING_ALLOWED=NO)
|
||||
elif [[ -n "${VOICECAT_DEVELOPMENT_TEAM:-}" ]]; then
|
||||
signing+=(DEVELOPMENT_TEAM="$VOICECAT_DEVELOPMENT_TEAM" CODE_SIGN_STYLE=Automatic)
|
||||
if [[ "${VOICECAT_ALLOW_PROVISIONING_UPDATES:-}" == "1" ]]; then
|
||||
signing=(-allowProvisioningUpdates "${signing[@]}")
|
||||
fi
|
||||
fi
|
||||
xcodebuild \
|
||||
-project "$project" \
|
||||
-target VoiceCatBroadcast \
|
||||
-scheme VoiceCatBroadcast \
|
||||
-configuration "$configuration" \
|
||||
-sdk "$sdk" \
|
||||
-arch "$architecture" \
|
||||
-derivedDataPath "$output/derived" \
|
||||
CONFIGURATION_BUILD_DIR="$output" \
|
||||
"${signing[@]}" \
|
||||
build
|
||||
|
||||
xcent="$script_dir/../../iOS/build/VoiceCatiOS.build/${configuration}-${sdk}/VoiceCatBroadcast.build/VoiceCatBroadcast.appex.xcent"
|
||||
xcent=$(find "$output/derived" -name 'VoiceCatBroadcast.appex.xcent' -print -quit)
|
||||
if [[ -f "$xcent" ]]; then
|
||||
cp "$xcent" "$output/VoiceCatBroadcast.xcent"
|
||||
else
|
||||
cp "$script_dir/../../iOS/VoiceCatBroadcast/VoiceCatBroadcast.entitlements" "$output/VoiceCatBroadcast.xcent"
|
||||
cp "$script_dir/../../../../native/apple/broadcast/VoiceCatBroadcast.entitlements" "$output/VoiceCatBroadcast.xcent"
|
||||
fi
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
import Foundation
|
||||
import Darwin
|
||||
|
||||
// Darwin notification names the extension posts and the host observes, so the host can react to
|
||||
// broadcast start/stop promptly instead of only polling the ring's active flag. Shared (compiled
|
||||
// into both targets) so the names can't drift.
|
||||
enum BroadcastNotification {
|
||||
static let started = "cat.voice.VoiceCat.broadcast.started"
|
||||
static let finished = "cat.voice.VoiceCat.broadcast.finished"
|
||||
}
|
||||
|
||||
// BroadcastAudioRing — cross-process single-producer/single-consumer int16 PCM ring over an
|
||||
// mmap'd file in the shared App Group container. Compiled into BOTH the host app and the
|
||||
// ReplayKit broadcast upload extension (docs/voice.md §9, iOS detail).
|
||||
//
|
||||
// producer = the broadcast extension's RPBroadcastSampleHandler (captured system audio)
|
||||
// consumer = the host app's BroadcastAudioPump (drains and feeds the core via feedPcm)
|
||||
//
|
||||
// Why a hand-rolled ring instead of Swift's `Atomic`: the storage lives in shared memory mapped
|
||||
// into two processes, so the synchronization words must sit in that mapping — Swift's managed
|
||||
// atomics can't. For strict SPSC, aligned 64-bit monotonic indices with full memory barriers
|
||||
// (`OSMemoryBarrier`) give correct acquire/release ordering. The extension does NOT link
|
||||
// libvoicecat — it only writes PCM here; all encode/crypto/UDP happens in the host.
|
||||
//
|
||||
// Lifecycle: the host opens the ring at connect (and thus initializes the header first); the
|
||||
// extension opens it later when a broadcast starts. On a rising edge of `isActive` the host
|
||||
// calls `drainStale()` to discard any pre-roll, then drains in whole 20 ms frames.
|
||||
final class BroadcastAudioRing {
|
||||
|
||||
static let appGroupId = "group.me.iamtalon.voicecat"
|
||||
|
||||
enum RingError: Error { case noContainer, openFailed, mapFailed }
|
||||
|
||||
// Header layout (byte offsets into the mmap). Indices are 8-byte aligned; mmap is
|
||||
// page-aligned so offsets 24/32 satisfy that.
|
||||
private static let magic: UInt32 = 0x5643_4252 // "VCBR"
|
||||
private static let version: UInt32 = 1
|
||||
private static let headerBytes = 64
|
||||
/// 1 second of 48 kHz stereo int16 — ample slack for ~10 ms host drains.
|
||||
static let capacitySamples = 48_000 * 2
|
||||
|
||||
private static let offMagic = 0
|
||||
private static let offVersion = 4
|
||||
private static let offChannels = 8
|
||||
private static let offSampleRate = 12
|
||||
private static let offActive = 16
|
||||
private static let offWrite = 24
|
||||
private static let offRead = 32
|
||||
|
||||
private let fd: Int32
|
||||
private let mapBase: UnsafeMutableRawPointer
|
||||
private let mapSize: Int
|
||||
private let data: UnsafeMutablePointer<Int16>
|
||||
private let capacity: Int
|
||||
|
||||
init() throws {
|
||||
guard let container = FileManager.default.containerURL(
|
||||
forSecurityApplicationGroupIdentifier: Self.appGroupId) else {
|
||||
throw RingError.noContainer
|
||||
}
|
||||
let dir = container.appendingPathComponent("voicecat", isDirectory: true)
|
||||
try? FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
|
||||
let path = dir.appendingPathComponent("broadcast_audio.ring").path
|
||||
|
||||
capacity = Self.capacitySamples
|
||||
mapSize = Self.headerBytes + capacity * MemoryLayout<Int16>.size
|
||||
|
||||
let f = open(path, O_RDWR | O_CREAT, 0o644)
|
||||
guard f >= 0 else { throw RingError.openFailed }
|
||||
if ftruncate(f, off_t(mapSize)) != 0 { close(f); throw RingError.openFailed }
|
||||
|
||||
let p = mmap(nil, mapSize, PROT_READ | PROT_WRITE, MAP_SHARED, f, 0)
|
||||
guard let p, p != MAP_FAILED else { close(f); throw RingError.mapFailed }
|
||||
|
||||
fd = f
|
||||
mapBase = p
|
||||
data = (p + Self.headerBytes).assumingMemoryBound(to: Int16.self)
|
||||
|
||||
// First opener initializes the header (host opens first, before any broadcast).
|
||||
if load32(Self.offMagic) != Self.magic {
|
||||
store32(Self.offWrite, 0); store32(Self.offWrite + 4, 0)
|
||||
store32(Self.offRead, 0); store32(Self.offRead + 4, 0)
|
||||
store32(Self.offChannels, 0)
|
||||
store32(Self.offSampleRate, 0)
|
||||
store32(Self.offActive, 0)
|
||||
store32(Self.offVersion, Self.version)
|
||||
OSMemoryBarrier()
|
||||
store32(Self.offMagic, Self.magic)
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
munmap(mapBase, mapSize)
|
||||
close(fd)
|
||||
}
|
||||
|
||||
// MARK: - Header accessors
|
||||
|
||||
var isActive: Bool { OSMemoryBarrier(); return load32(Self.offActive) != 0 }
|
||||
var channels: UInt32 { load32(Self.offChannels) }
|
||||
var sampleRate: UInt32 { load32(Self.offSampleRate) }
|
||||
|
||||
/// Producer: advertise the canonical capture format and toggle the active flag. Called from
|
||||
/// `broadcastStarted`/`broadcastFinished`.
|
||||
func setActive(_ active: Bool, channels: UInt32 = 0, sampleRate: UInt32 = 0) {
|
||||
if active {
|
||||
store32(Self.offChannels, channels)
|
||||
store32(Self.offSampleRate, sampleRate)
|
||||
}
|
||||
OSMemoryBarrier()
|
||||
store32(Self.offActive, active ? 1 : 0)
|
||||
}
|
||||
|
||||
// MARK: - Producer (extension)
|
||||
|
||||
/// Append interleaved int16 samples. Drops the whole chunk if it doesn't fit — skipping a
|
||||
/// chunk is better than tearing a frame. Single producer only.
|
||||
func push(_ samples: UnsafeBufferPointer<Int16>) {
|
||||
let n = samples.count
|
||||
guard n > 0, n <= capacity, let src = samples.baseAddress else { return }
|
||||
let w = load64(Self.offWrite) // producer owns the write index
|
||||
let r = loadAcquire64(Self.offRead)
|
||||
if capacity - Int(w &- r) < n { return } // full: drop
|
||||
var idx = Int(w % UInt64(capacity))
|
||||
var off = 0
|
||||
var rem = n
|
||||
while rem > 0 {
|
||||
let chunk = min(rem, capacity - idx)
|
||||
(data + idx).update(from: src + off, count: chunk)
|
||||
idx = (idx + chunk) % capacity
|
||||
off += chunk
|
||||
rem -= chunk
|
||||
}
|
||||
storeRelease64(Self.offWrite, w &+ UInt64(n))
|
||||
}
|
||||
|
||||
// MARK: - Consumer (host)
|
||||
|
||||
/// Read up to `out.count` interleaved int16 samples. Returns the number read. Single
|
||||
/// consumer only.
|
||||
func read(into out: UnsafeMutableBufferPointer<Int16>) -> Int {
|
||||
guard let dst = out.baseAddress else { return 0 }
|
||||
let r = load64(Self.offRead) // consumer owns the read index
|
||||
let w = loadAcquire64(Self.offWrite)
|
||||
let available = Int(w &- r)
|
||||
if available <= 0 { return 0 }
|
||||
let n = min(available, out.count)
|
||||
var idx = Int(r % UInt64(capacity))
|
||||
var off = 0
|
||||
var rem = n
|
||||
while rem > 0 {
|
||||
let chunk = min(rem, capacity - idx)
|
||||
(dst + off).update(from: data + idx, count: chunk)
|
||||
idx = (idx + chunk) % capacity
|
||||
off += chunk
|
||||
rem -= chunk
|
||||
}
|
||||
storeRelease64(Self.offRead, r &+ UInt64(n))
|
||||
return n
|
||||
}
|
||||
|
||||
/// Consumer: discard everything currently buffered (catch the read index up to write).
|
||||
func drainStale() { storeRelease64(Self.offRead, loadAcquire64(Self.offWrite)) }
|
||||
|
||||
// MARK: - Memory-ordered accessors
|
||||
|
||||
private func ptr32(_ off: Int) -> UnsafeMutablePointer<UInt32> {
|
||||
(mapBase + off).assumingMemoryBound(to: UInt32.self)
|
||||
}
|
||||
private func ptr64(_ off: Int) -> UnsafeMutablePointer<UInt64> {
|
||||
(mapBase + off).assumingMemoryBound(to: UInt64.self)
|
||||
}
|
||||
private func load32(_ off: Int) -> UInt32 { ptr32(off).pointee }
|
||||
private func store32(_ off: Int, _ v: UInt32) { ptr32(off).pointee = v }
|
||||
private func load64(_ off: Int) -> UInt64 { ptr64(off).pointee }
|
||||
private func loadAcquire64(_ off: Int) -> UInt64 { let v = ptr64(off).pointee; OSMemoryBarrier(); return v }
|
||||
private func storeRelease64(_ off: Int, _ v: UInt64) { OSMemoryBarrier(); ptr64(off).pointee = v }
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>VoiceCat Screen Audio</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.0.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>NSExtension</key>
|
||||
<dict>
|
||||
<key>NSExtensionPointIdentifier</key>
|
||||
<string>com.apple.broadcast-services-upload</string>
|
||||
<key>NSExtensionPrincipalClass</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SampleHandler</string>
|
||||
<key>RPBroadcastProcessMode</key>
|
||||
<string>RPBroadcastProcessModeSampleBuffer</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,88 +0,0 @@
|
||||
import ReplayKit
|
||||
import AVFoundation
|
||||
|
||||
// SampleHandler — the ReplayKit broadcast upload extension entry point (docs/voice.md §9, iOS).
|
||||
//
|
||||
// This runs in a SEPARATE process with a ~50 MB memory cap. It captures system/app audio
|
||||
// (`.audioApp`), drops video and mic buffers, converts each chunk to the core's canonical
|
||||
// format (48 kHz, int16, stereo interleaved) with AVAudioConverter, and writes it into the
|
||||
// App Group shared-memory ring. The host app's BroadcastAudioPump drains the ring and feeds the
|
||||
// already-connected VoiceCatClient — so all Opus/AEAD/UDP work happens in the host, and the
|
||||
// extension stays tiny and well inside the memory budget (no libvoicecat here).
|
||||
class SampleHandler: RPBroadcastSampleHandler {
|
||||
|
||||
private var ring: BroadcastAudioRing?
|
||||
private var converter: AVAudioConverter?
|
||||
private var inputFormat: AVAudioFormat?
|
||||
private let outputFormat = AVAudioFormat(commonFormat: .pcmFormatInt16,
|
||||
sampleRate: 48_000, channels: 2, interleaved: true)!
|
||||
|
||||
override func broadcastStarted(withSetupInfo setupInfo: [String: NSObject]?) {
|
||||
ring = try? BroadcastAudioRing()
|
||||
ring?.setActive(true, channels: 2, sampleRate: 48_000)
|
||||
postDarwin(BroadcastNotification.started)
|
||||
}
|
||||
|
||||
override func broadcastFinished() {
|
||||
ring?.setActive(false)
|
||||
postDarwin(BroadcastNotification.finished)
|
||||
ring = nil
|
||||
}
|
||||
|
||||
override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer,
|
||||
with sampleBufferType: RPSampleBufferType) {
|
||||
// App/system audio only — drop video (the memory hog) and the device mic (the host
|
||||
// already captures and sends the user's voice).
|
||||
guard sampleBufferType == .audioApp, let ring else { return }
|
||||
guard let input = makeInputBuffer(sampleBuffer),
|
||||
let conv = converter(for: input.format) else { return }
|
||||
|
||||
let ratio = outputFormat.sampleRate / input.format.sampleRate
|
||||
let capacity = AVAudioFrameCount(Double(input.frameLength) * ratio) + 1024
|
||||
guard let output = AVAudioPCMBuffer(pcmFormat: outputFormat, frameCapacity: capacity) else { return }
|
||||
|
||||
var supplied = false
|
||||
var error: NSError?
|
||||
let status = conv.convert(to: output, error: &error) { _, outStatus in
|
||||
if supplied { outStatus.pointee = .noDataNow; return nil }
|
||||
supplied = true
|
||||
outStatus.pointee = .haveData
|
||||
return input
|
||||
}
|
||||
guard status != .error, output.frameLength > 0,
|
||||
let mData = output.audioBufferList.pointee.mBuffers.mData else { return }
|
||||
|
||||
// Interleaved int16 → one buffer of frameLength * channels samples.
|
||||
let count = Int(output.frameLength) * Int(outputFormat.channelCount)
|
||||
ring.push(UnsafeBufferPointer(start: mData.assumingMemoryBound(to: Int16.self), count: count))
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
/// Wrap the ReplayKit CMSampleBuffer's PCM in an AVAudioPCMBuffer matching its native format.
|
||||
private func makeInputBuffer(_ sb: CMSampleBuffer) -> AVAudioPCMBuffer? {
|
||||
guard let fmtDesc = CMSampleBufferGetFormatDescription(sb),
|
||||
var asbd = CMAudioFormatDescriptionGetStreamBasicDescription(fmtDesc)?.pointee,
|
||||
let fmt = AVAudioFormat(streamDescription: &asbd) else { return nil }
|
||||
let frames = AVAudioFrameCount(CMSampleBufferGetNumSamples(sb))
|
||||
guard frames > 0, let buf = AVAudioPCMBuffer(pcmFormat: fmt, frameCapacity: frames) else { return nil }
|
||||
buf.frameLength = frames
|
||||
let status = CMSampleBufferCopyPCMDataIntoAudioBufferList(
|
||||
sb, at: 0, frameCount: Int32(frames), into: buf.mutableAudioBufferList)
|
||||
return status == noErr ? buf : nil
|
||||
}
|
||||
|
||||
/// Reuse the converter while the input format is stable; rebuild if ReplayKit changes it.
|
||||
private func converter(for inFmt: AVAudioFormat) -> AVAudioConverter? {
|
||||
if let converter, inputFormat == inFmt { return converter }
|
||||
inputFormat = inFmt
|
||||
converter = AVAudioConverter(from: inFmt, to: outputFormat)
|
||||
return converter
|
||||
}
|
||||
|
||||
private func postDarwin(_ name: String) {
|
||||
CFNotificationCenterPostNotification(
|
||||
CFNotificationCenterGetDarwinNotifyCenter(),
|
||||
CFNotificationName(name as CFString), nil, nil, true)
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.application-groups</key>
|
||||
<array>
|
||||
<string>group.me.iamtalon.voicecat</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -123,7 +123,7 @@ build_slice() {
|
||||
# Two source dirs:
|
||||
# - vcpkg_target_lib_dir: vcpkg-installed deps (protobuf, mbedtls, sodium, opus, …).
|
||||
# - local_lib_dir: CMake static-lib targets built in this tree that are NOT vcpkg deps —
|
||||
# e.g. the vendored RNNoise lib (third_party/rnnoise, VOICECAT_HAS_NS). Without it the
|
||||
# e.g. the vendored RNNoise lib (native/rnnoise, VOICECAT_HAS_NS). Without it the
|
||||
# fat lib references _rnnoise_* symbols that nothing defines → undefined-symbol link
|
||||
# errors in Xcode. Exclude libvoicecat* (the main lib is $lib; libvoicecat-fat.a is the
|
||||
# output we're building here).
|
||||
|
||||
Reference in New Issue
Block a user