From ea951c98b215745224ce6dbae560b680c35fab85 Mon Sep 17 00:00:00 2001 From: Michal Sek Date: Wed, 20 Nov 2024 11:29:01 +0100 Subject: [PATCH] feat: update translations --- packages/react-native-audio-api/android/CMakeLists.txt | 5 ----- packages/react-native-audio-api/ios/AudioAPIModule.h | 4 ++++ .../ios/AudioPlayer/AudioPlayer.m | 10 +++++++++- .../src/core/AudioScheduledSourceNode.ts | 1 - 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/react-native-audio-api/android/CMakeLists.txt b/packages/react-native-audio-api/android/CMakeLists.txt index b91d27fe..9e779096 100644 --- a/packages/react-native-audio-api/android/CMakeLists.txt +++ b/packages/react-native-audio-api/android/CMakeLists.txt @@ -4,11 +4,6 @@ project(react-native-audio-api) set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_CXX_STANDARD 20) -# Detect the operating system -if(APPLE) - set(HAVE_ACCELERATE TRUE) -endif() - # Detect the processor and SIMD support if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") set(HAVE_ARM_NEON_INTRINSICS TRUE) diff --git a/packages/react-native-audio-api/ios/AudioAPIModule.h b/packages/react-native-audio-api/ios/AudioAPIModule.h index 61a47468..7760a435 100644 --- a/packages/react-native-audio-api/ios/AudioAPIModule.h +++ b/packages/react-native-audio-api/ios/AudioAPIModule.h @@ -8,6 +8,10 @@ #import #endif // RCT_NEW_ARCH_ENABLED +#ifndef HAVE_ACCELERATE +#define HAVE_ACCELERATE +#endif + #import @interface AudioAPIModule : RCTEventEmitter diff --git a/packages/react-native-audio-api/ios/AudioPlayer/AudioPlayer.m b/packages/react-native-audio-api/ios/AudioPlayer/AudioPlayer.m index bb79ad81..9042163c 100644 --- a/packages/react-native-audio-api/ios/AudioPlayer/AudioPlayer.m +++ b/packages/react-native-audio-api/ios/AudioPlayer/AudioPlayer.m @@ -54,7 +54,15 @@ - (int)getSampleRate - (int)getBufferSizeInFrames { - return (int)(self.audioSession.IOBufferDuration * self.audioSession.sampleRate); + // Note: might be important in the future. + // For some reason audioSession.IOBufferDuration is always 0.01, which for sample rate of 48k + // gives exactly 480 frames, while at the same time frameCount requested by AVAudioSourceEngine + // might vary f.e. between 555-560. + // preferredIOBufferDuration seems to be double the value (resulting in 960 frames), + // which is safer to base our internal AudioBus sizes. + // Buut no documentation => no guarantee :) + // If something is crackling when it should play silence, start here 📻 + return (int)(self.audioSession.preferredIOBufferDuration * self.audioSession.sampleRate); } - (void)start diff --git a/packages/react-native-audio-api/src/core/AudioScheduledSourceNode.ts b/packages/react-native-audio-api/src/core/AudioScheduledSourceNode.ts index eee8dd85..7c1051c0 100644 --- a/packages/react-native-audio-api/src/core/AudioScheduledSourceNode.ts +++ b/packages/react-native-audio-api/src/core/AudioScheduledSourceNode.ts @@ -23,7 +23,6 @@ export default class AudioScheduledSourceNode extends AudioNode { this.hasBeenStarted = true; (this.node as IAudioScheduledSourceNode).start(when); - this.hasBeenStarted = true; } public stop(when: number = 0): void {