From cb79f22ad1f090d961d41fe7319063d154894cdd Mon Sep 17 00:00:00 2001 From: Ivan Sekovanikj Date: Fri, 12 Jun 2026 21:59:26 +0200 Subject: [PATCH] fix: nitro sound audio recording --- .../src/optionalDependencies/Audio.ts | 14 ++++++++++++++ package/src/types/types.ts | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/package/native-package/src/optionalDependencies/Audio.ts b/package/native-package/src/optionalDependencies/Audio.ts index 5c76ddcba4..58b1b8c436 100644 --- a/package/native-package/src/optionalDependencies/Audio.ts +++ b/package/native-package/src/optionalDependencies/Audio.ts @@ -111,6 +111,15 @@ class _Audio { audioSet: { // Android specific properties AudioEncoderAndroid: AudioEncoderAndroidType.AAC, + // Pin nitro-sound 0.2.10+'s bitrate to 128 kbps. Its `.high` quality + // preset otherwise defaults to (48 kHz, 2ch, 192 kbps), a combination + // the iOS hardware AAC encoder rejects with + // kAudioFormatUnsupportedDataFormatError ('fmt?', OSStatus 1718449215) + // in AppStore signed binaries. + // https://www.osstatus.com/search/results?search=1718449215 + // Older nitro-sound and the legacy `react-native-audio-recorder-player` + // ignore this key. + AudioEncodingBitRate: 128000, AudioSourceAndroid: AudioSourceAndroidType.MIC, OutputFormatAndroid: OutputFormatAndroidType.AAC_ADTS, @@ -121,6 +130,11 @@ class _Audio { ? AVModeIOSOptionNitroSound.spokenaudio : AVModeIOSOption.spokenaudio, AVNumberOfChannelsKeyIOS: 2, + // Pair with `AudioEncodingBitRate` above override nitro-sound 0.2.10+'s + // 48 kHz default back to 44.1 kHz so the encoder gets the combo that + // 0.2.9 was implicitly using. Idempotent for older nitro-sound and the + // legacy lib (their default is already 44.1 kHz). + AVSampleRateKeyIOS: 44100, }, isMeteringEnabled: true, }, diff --git a/package/src/types/types.ts b/package/src/types/types.ts index 27a4ef5e50..90e10bfe10 100644 --- a/package/src/types/types.ts +++ b/package/src/types/types.ts @@ -501,6 +501,15 @@ type AVEncodingType = export interface AudioSet { AudioChannelsAndroid?: number; AudioEncoderAndroid?: AudioEncoderAndroidType; + /** + * Cross-platform bitrate hint introduced in `react-native-nitro-sound` 0.2.10+. + * Sits alongside the iOS-native `AVEncoderBitRateKeyIOS` because nitro-sound + * reads `AudioEncodingBitRate` on iOS (mapping it to `AVEncoderBitRateKey`), + * not the platform-specific key. Older nitro-sound builds and the legacy + * `react-native-audio-recorder-player` ignore this field, so it's safe to + * include unconditionally. + */ + AudioEncodingBitRate?: number; AudioEncodingBitRateAndroid?: number; AudioSamplingRateAndroid?: number; AudioSourceAndroid?: AudioSourceAndroidType;