react-native-audio-api 0.11.0-alpha.1 → 0.11.0-nightly-bfab178-20251107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -11
- package/RNAudioAPI.podspec +20 -15
- package/android/build.gradle +33 -3
- package/android/src/main/cpp/audioapi/CMakeLists.txt +6 -3
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +5 -0
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +1 -0
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +30 -142
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +13 -40
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +4 -2
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +6 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +31 -3
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +21 -9
- package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +27 -6
- package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +11 -0
- package/android/src/oldarch/NativeAudioAPIModuleSpec.java +4 -0
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +30 -2
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +18 -0
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +1 -0
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +47 -0
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +20 -0
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +18 -97
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +6 -18
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/core/AudioNode.h +3 -2
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +10 -0
- package/common/cpp/audioapi/core/BaseAudioContext.h +2 -0
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +69 -32
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +37 -1
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +210 -0
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +55 -0
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +82 -36
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +31 -52
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +14 -17
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +0 -1
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +8 -14
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +0 -1
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +14 -18
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +64 -64
- package/common/cpp/audioapi/core/sources/StreamerNode.h +38 -10
- package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +5 -0
- package/common/cpp/audioapi/core/utils/Constants.h +2 -1
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +12 -8
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +3 -3
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +1 -1
- package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
- package/common/cpp/audioapi/dsp/Convolver.cpp +213 -0
- package/common/cpp/audioapi/dsp/Convolver.h +45 -0
- package/common/cpp/audioapi/dsp/FFT.cpp +0 -26
- package/common/cpp/audioapi/dsp/FFT.h +26 -2
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +4 -4
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +3 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/defs.h +3 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/packet.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/smpte_436m.h +254 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/version.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +6 -6
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version_major.h +2 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avassert.h +5 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/channel_layout.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/csp.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/dict.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ffversion.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/film_grain_params.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/frame.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hdr_dynamic_vivid_metadata.h +3 -3
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_opencl.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_qsv.h +0 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vulkan.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/iamf.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/lfg.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/log.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mathematics.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/opt.h +4 -4
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rational.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rc4.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/refstruct.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/spherical.h +6 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tdrdi.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tx.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/version.h +3 -3
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/video_hint.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libswresample/swresample.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libswresample/version.h +1 -1
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +2 -3
- package/common/cpp/audioapi/libs/ffmpeg/relinking.md +24 -0
- package/common/cpp/audioapi/utils/AlignedAllocator.hpp +50 -0
- package/common/cpp/audioapi/utils/AudioBus.cpp +28 -0
- package/common/cpp/audioapi/utils/AudioBus.h +3 -0
- package/common/cpp/audioapi/utils/ThreadPool.hpp +59 -1
- package/common/cpp/test/CMakeLists.txt +19 -14
- package/common/cpp/test/src/AudioParamTest.cpp +1 -1
- package/common/cpp/test/src/AudioScheduledSourceTest.cpp +134 -0
- package/common/cpp/test/src/ConstantSourceTest.cpp +1 -1
- package/common/cpp/test/src/GainTest.cpp +1 -1
- package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +4 -4
- package/common/cpp/test/src/OscillatorTest.cpp +1 -1
- package/common/cpp/test/src/StereoPannerTest.cpp +1 -1
- package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +389 -0
- package/common/cpp/test/src/biquad/BiquadFilterChromium.h +64 -0
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +284 -0
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +40 -0
- package/ios/audioapi/ios/AudioAPIModule.h +2 -1
- package/ios/audioapi/ios/AudioAPIModule.mm +13 -0
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +10 -28
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +30 -117
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +9 -4
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +71 -29
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +0 -1
- package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
- package/ios/audioapi/ios/system/AudioSessionManager.h +2 -0
- package/ios/audioapi/ios/system/AudioSessionManager.mm +24 -0
- package/ios/audioapi/ios/system/LockScreenManager.h +0 -1
- package/ios/audioapi/ios/system/LockScreenManager.mm +6 -19
- package/lib/commonjs/api.js +141 -76
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +8 -0
- package/lib/commonjs/api.web.js.map +1 -1
- package/lib/commonjs/core/AudioContext.js +1 -1
- package/lib/commonjs/core/AudioContext.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +13 -171
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +28 -25
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/ConvolverNode.js +37 -0
- package/lib/commonjs/core/ConvolverNode.js.map +1 -0
- package/lib/commonjs/core/OfflineAudioContext.js +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/commonjs/system/AudioManager.js +3 -0
- package/lib/commonjs/system/AudioManager.js.map +1 -1
- package/lib/commonjs/types.js +0 -46
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/index.js +19 -21
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +12 -0
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/ConvolverNode.js +40 -0
- package/lib/commonjs/web-core/ConvolverNode.js.map +1 -0
- package/lib/commonjs/web-core/ConvolverNodeOptions.js +6 -0
- package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +1 -0
- package/lib/commonjs/web-core/OfflineAudioContext.js +12 -0
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/api.js +16 -15
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +1 -0
- package/lib/module/api.web.js.map +1 -1
- package/lib/module/core/AudioContext.js +2 -2
- package/lib/module/core/AudioContext.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +13 -171
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +29 -26
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/ConvolverNode.js +31 -0
- package/lib/module/core/ConvolverNode.js.map +1 -0
- package/lib/module/core/OfflineAudioContext.js +2 -2
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/module/system/AudioManager.js +3 -0
- package/lib/module/system/AudioManager.js.map +1 -1
- package/lib/module/types.js +1 -45
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/index.js +15 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +12 -0
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/module/web-core/ConvolverNode.js +34 -0
- package/lib/module/web-core/ConvolverNode.js.map +1 -0
- package/lib/module/web-core/ConvolverNodeOptions.js +4 -0
- package/lib/module/web-core/ConvolverNodeOptions.js.map +1 -0
- package/lib/module/web-core/OfflineAudioContext.js +12 -0
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +19 -17
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +1 -0
- package/lib/typescript/api.web.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/core/AudioRecorder.d.ts +7 -62
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +3 -1
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/ConvolverNode.d.ts +12 -0
- package/lib/typescript/core/ConvolverNode.d.ts.map +1 -0
- package/lib/typescript/events/types.d.ts +0 -16
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +9 -42
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -0
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
- package/lib/typescript/system/AudioManager.d.ts +1 -0
- package/lib/typescript/system/AudioManager.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +8 -79
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +5 -2
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +3 -0
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/BaseAudioContext.d.ts +2 -0
- package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/ConvolverNode.d.ts +11 -0
- package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -0
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +6 -0
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +1 -0
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +3 -0
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/package.json +14 -5
- package/scripts/download-prebuilt-binaries.sh +61 -0
- package/scripts/rnaa_utils.rb +8 -0
- package/scripts/validate-worklets-version.js +28 -0
- package/src/api.ts +45 -18
- package/src/api.web.ts +1 -0
- package/src/core/AudioContext.ts +3 -2
- package/src/core/AudioRecorder.ts +24 -211
- package/src/core/BaseAudioContext.ts +67 -60
- package/src/core/ConvolverNode.ts +35 -0
- package/src/core/OfflineAudioContext.ts +2 -2
- package/src/events/types.ts +0 -18
- package/src/interfaces.ts +16 -52
- package/src/specs/NativeAudioAPIModule.ts +1 -0
- package/src/system/AudioManager.ts +4 -0
- package/src/types.ts +9 -90
- package/src/utils/index.ts +22 -2
- package/src/web-core/AudioContext.tsx +25 -0
- package/src/web-core/BaseAudioContext.tsx +2 -0
- package/src/web-core/ConvolverNode.tsx +43 -0
- package/src/web-core/ConvolverNodeOptions.tsx +6 -0
- package/src/web-core/OfflineAudioContext.tsx +25 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +0 -37
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +0 -187
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +0 -57
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +0 -34
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +0 -133
- package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +0 -3
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +0 -154
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +0 -41
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +0 -429
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +0 -113
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +0 -47
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +0 -28
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +0 -269
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +0 -47
- package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +0 -31
- package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +0 -18
- package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +0 -32
- package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +0 -111
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +0 -391
- package/ios/audioapi/ios/core/IOSAudioFileOptions.h +0 -36
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +0 -140
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +0 -51
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +0 -223
- package/ios/audioapi/ios/core/IOSRecorderCallback.h +0 -57
- package/ios/audioapi/ios/core/IOSRecorderCallback.mm +0 -189
- package/lib/commonjs/utils/bitEnums.js +0 -33
- package/lib/commonjs/utils/bitEnums.js.map +0 -1
- package/lib/module/utils/bitEnums.js +0 -27
- package/lib/module/utils/bitEnums.js.map +0 -1
- package/lib/typescript/utils/bitEnums.d.ts +0 -4
- package/lib/typescript/utils/bitEnums.d.ts.map +0 -1
- package/src/utils/bitEnums.ts +0 -51
|
@@ -119,7 +119,7 @@ typedef struct AV3DReferenceDisplay {
|
|
|
119
119
|
uint8_t mantissa_ref_display_width;
|
|
120
120
|
|
|
121
121
|
/**
|
|
122
|
-
*
|
|
122
|
+
* The exponent part of the reference viewing distance of the n-th reference display.
|
|
123
123
|
*/
|
|
124
124
|
uint8_t exponent_ref_viewing_distance;
|
|
125
125
|
|
|
@@ -50,7 +50,7 @@ enum AVTXType {
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* Standard MDCT with a sample data type of float, double or int32_t,
|
|
53
|
-
*
|
|
53
|
+
* respectively. For the float and int32 variants, the scale type is
|
|
54
54
|
* 'float', while for the double variant, it's 'double'.
|
|
55
55
|
* If scale is NULL, 1.0 will be used as a default.
|
|
56
56
|
*
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
* Useful to check and match library version in order to maintain
|
|
36
36
|
* backward compatibility.
|
|
37
37
|
*
|
|
38
|
-
* The FFmpeg libraries follow a versioning
|
|
38
|
+
* The FFmpeg libraries follow a versioning scheme very similar to
|
|
39
39
|
* Semantic Versioning (http://semver.org/)
|
|
40
40
|
* The difference is that the component called PATCH is called MICRO in FFmpeg
|
|
41
41
|
* and its value is reset to 100 instead of 0 to keep it above or equal to 100.
|
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
/**
|
|
73
73
|
* @defgroup lavu_ver Version and Build diagnostics
|
|
74
74
|
*
|
|
75
|
-
* Macros and function useful to check at
|
|
75
|
+
* Macros and function useful to check at compile time and at runtime
|
|
76
76
|
* which version of libavutil is in use.
|
|
77
77
|
*
|
|
78
78
|
* @{
|
|
79
79
|
*/
|
|
80
80
|
|
|
81
81
|
#define LIBAVUTIL_VERSION_MAJOR 60
|
|
82
|
-
#define LIBAVUTIL_VERSION_MINOR
|
|
82
|
+
#define LIBAVUTIL_VERSION_MINOR 8
|
|
83
83
|
#define LIBAVUTIL_VERSION_MICRO 100
|
|
84
84
|
|
|
85
85
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
|
@@ -80,7 +80,7 @@ av_video_hint_get_rect(const AVVideoHint *hints, size_t idx) {
|
|
|
80
80
|
* The side data contains a list of rectangles for the portions of the frame
|
|
81
81
|
* which changed from the last encoded one (and the remainder are assumed to be
|
|
82
82
|
* changed), or, alternately (depending on the type parameter) the unchanged
|
|
83
|
-
* ones (and the
|
|
83
|
+
* ones (and the remaining ones are those which changed).
|
|
84
84
|
* Macroblocks will thus be hinted either to be P_SKIP-ped or go through the
|
|
85
85
|
* regular encoding procedure.
|
|
86
86
|
*
|
|
@@ -337,7 +337,7 @@ int64_t swr_next_pts(struct SwrContext *s, int64_t pts);
|
|
|
337
337
|
* @}
|
|
338
338
|
*
|
|
339
339
|
* @name Low-level option setting functions
|
|
340
|
-
* These
|
|
340
|
+
* These functions provide a means to set low-level options that is not possible
|
|
341
341
|
* with the AVOption API.
|
|
342
342
|
* @{
|
|
343
343
|
*/
|
|
@@ -277,8 +277,7 @@ decodeWithMemoryBlock(const void *data, size_t size, int sample_rate) {
|
|
|
277
277
|
MemoryIOContext io_ctx{static_cast<const uint8_t *>(data), size, 0};
|
|
278
278
|
|
|
279
279
|
constexpr size_t buffer_size = 4096;
|
|
280
|
-
|
|
281
|
-
static_cast<uint8_t *>(av_malloc(buffer_size)), &av_free);
|
|
280
|
+
uint8_t *io_buffer = static_cast<uint8_t *>(av_malloc(buffer_size));
|
|
282
281
|
if (io_buffer == nullptr) {
|
|
283
282
|
return nullptr;
|
|
284
283
|
}
|
|
@@ -286,7 +285,7 @@ decodeWithMemoryBlock(const void *data, size_t size, int sample_rate) {
|
|
|
286
285
|
auto avio_ctx =
|
|
287
286
|
std::unique_ptr<AVIOContext, std::function<void(AVIOContext *)>>(
|
|
288
287
|
avio_alloc_context(
|
|
289
|
-
io_buffer
|
|
288
|
+
io_buffer,
|
|
290
289
|
buffer_size,
|
|
291
290
|
0,
|
|
292
291
|
&io_ctx,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
## If you would like to relink ffmpeg to your implementation there are two options:
|
|
2
|
+
|
|
3
|
+
### Option A)
|
|
4
|
+
|
|
5
|
+
you can modify script in scripts/download-prebuilt-binaries.sh
|
|
6
|
+
|
|
7
|
+
- ios dynamic frameworks are in `ffmpeg_ios.zip` directory
|
|
8
|
+
- android shared libraries are in `jniLibs.zip`
|
|
9
|
+
|
|
10
|
+
just replace way of downloading them that links to your binaries
|
|
11
|
+
|
|
12
|
+
### Option B)
|
|
13
|
+
|
|
14
|
+
directly modify libraries in source code
|
|
15
|
+
|
|
16
|
+
- ios dynamic frameworks are placed in `common/cpp/audioapi/external`
|
|
17
|
+
- android shared libraries are placed in `android/src/main/jniLibs`
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
`USED_LIBRARIES`:
|
|
21
|
+
- libavcodec
|
|
22
|
+
- libavformat
|
|
23
|
+
- libavutil
|
|
24
|
+
- libswresample
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <cstddef>
|
|
3
|
+
#include <new>
|
|
4
|
+
|
|
5
|
+
template<typename T, std::size_t Align = 16>
|
|
6
|
+
class AlignedAllocator {
|
|
7
|
+
public:
|
|
8
|
+
using value_type = T;
|
|
9
|
+
using size_type = std::size_t;
|
|
10
|
+
using difference_type = std::ptrdiff_t;
|
|
11
|
+
|
|
12
|
+
AlignedAllocator() noexcept = default;
|
|
13
|
+
template<class U> AlignedAllocator(const AlignedAllocator<U, Align>&) noexcept {}
|
|
14
|
+
|
|
15
|
+
T* allocate(std::size_t n) {
|
|
16
|
+
// We want to maximize performance on hot paths, so we hint unlikely branches
|
|
17
|
+
if (n == 0) [[ unlikely ]] {
|
|
18
|
+
return nullptr;
|
|
19
|
+
}
|
|
20
|
+
std::size_t bytes = n * sizeof(T);
|
|
21
|
+
// C++17 aligned new
|
|
22
|
+
void* p = ::operator new(bytes, std::align_val_t(Align));
|
|
23
|
+
|
|
24
|
+
// We have more serious problems if this happens than speed concerns
|
|
25
|
+
// so we can opt the branch prediction
|
|
26
|
+
if (!p) [[ unlikely ]] {
|
|
27
|
+
throw std::bad_alloc();
|
|
28
|
+
}
|
|
29
|
+
return static_cast<T*>(p);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
void deallocate(T* p, std::size_t) noexcept {
|
|
33
|
+
::operator delete(p, std::align_val_t(Align));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Rebind allocator to type U (required by std::vector)
|
|
37
|
+
template<class U>
|
|
38
|
+
struct rebind { using other = AlignedAllocator<U, Align>; };
|
|
39
|
+
|
|
40
|
+
// Comparison operators (required by std::vector)
|
|
41
|
+
template<typename U, std::size_t UAlign>
|
|
42
|
+
bool operator==(const AlignedAllocator<U, UAlign>&) const noexcept {
|
|
43
|
+
return Align == UAlign;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
template<typename U, std::size_t UAlign>
|
|
47
|
+
bool operator!=(const AlignedAllocator<U, UAlign>&) const noexcept {
|
|
48
|
+
return Align != UAlign;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -34,6 +34,34 @@ AudioBus::AudioBus(const AudioBus &other) {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
AudioBus::AudioBus(AudioBus &&other) noexcept
|
|
38
|
+
: channels_(std::move(other.channels_)),
|
|
39
|
+
numberOfChannels_(other.numberOfChannels_),
|
|
40
|
+
sampleRate_(other.sampleRate_),
|
|
41
|
+
size_(other.size_) {
|
|
42
|
+
other.numberOfChannels_ = 0;
|
|
43
|
+
other.sampleRate_ = 0.0f;
|
|
44
|
+
other.size_ = 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
AudioBus &AudioBus::operator=(const AudioBus &other) {
|
|
48
|
+
if (this == &other) {
|
|
49
|
+
return *this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
numberOfChannels_ = other.numberOfChannels_;
|
|
53
|
+
sampleRate_ = other.sampleRate_;
|
|
54
|
+
size_ = other.size_;
|
|
55
|
+
|
|
56
|
+
createChannels();
|
|
57
|
+
|
|
58
|
+
for (int i = 0; i < numberOfChannels_; i += 1) {
|
|
59
|
+
channels_[i] = std::make_shared<AudioArray>(*other.channels_[i]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return *this;
|
|
63
|
+
}
|
|
64
|
+
|
|
37
65
|
AudioBus::~AudioBus() {
|
|
38
66
|
channels_.clear();
|
|
39
67
|
}
|
|
@@ -24,8 +24,11 @@ class AudioBus {
|
|
|
24
24
|
ChannelSurroundRight = 5,
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
explicit AudioBus() = default;
|
|
27
28
|
explicit AudioBus(size_t size, int numberOfChannels, float sampleRate);
|
|
28
29
|
AudioBus(const AudioBus &other);
|
|
30
|
+
AudioBus(AudioBus &&other) noexcept;
|
|
31
|
+
AudioBus& operator=(const AudioBus& other);
|
|
29
32
|
|
|
30
33
|
~AudioBus();
|
|
31
34
|
|
|
@@ -20,6 +20,11 @@ class ThreadPool {
|
|
|
20
20
|
struct TaskEvent { audioapi::move_only_function<void()> task; };
|
|
21
21
|
using Event = std::variant<TaskEvent, StopEvent>;
|
|
22
22
|
|
|
23
|
+
struct Cntrl {
|
|
24
|
+
std::atomic<bool> waitingForTasks{false};
|
|
25
|
+
std::atomic<size_t> tasksScheduled{0};
|
|
26
|
+
};
|
|
27
|
+
|
|
23
28
|
using Sender = channels::spsc::Sender<Event, channels::spsc::OverflowStrategy::WAIT_ON_FULL, channels::spsc::WaitStrategy::ATOMIC_WAIT>;
|
|
24
29
|
using Receiver = channels::spsc::Receiver<Event, channels::spsc::OverflowStrategy::WAIT_ON_FULL, channels::spsc::WaitStrategy::ATOMIC_WAIT>;
|
|
25
30
|
public:
|
|
@@ -38,8 +43,30 @@ public:
|
|
|
38
43
|
workerSenders.emplace_back(std::move(workerSender));
|
|
39
44
|
}
|
|
40
45
|
loadBalancerThread = std::thread(&ThreadPool::loadBalancerThreadFunc, this, std::move(receiver), std::move(workerSenders));
|
|
46
|
+
controlBlock_ = std::make_unique<Cntrl>();
|
|
47
|
+
}
|
|
48
|
+
ThreadPool(const ThreadPool&) = delete;
|
|
49
|
+
ThreadPool& operator=(const ThreadPool&) = delete;
|
|
50
|
+
ThreadPool(ThreadPool&& other):
|
|
51
|
+
loadBalancerThread(std::move(other.loadBalancerThread)),
|
|
52
|
+
workers(std::move(other.workers)),
|
|
53
|
+
loadBalancerSender(std::move(other.loadBalancerSender)),
|
|
54
|
+
controlBlock_(std::move(other.controlBlock_)) {}
|
|
55
|
+
ThreadPool& operator=(ThreadPool&& other) {
|
|
56
|
+
if (this != &other) {
|
|
57
|
+
loadBalancerThread = std::move(other.loadBalancerThread);
|
|
58
|
+
workers = std::move(other.workers);
|
|
59
|
+
loadBalancerSender = std::move(other.loadBalancerSender);
|
|
60
|
+
controlBlock_ = std::move(other.controlBlock_);
|
|
61
|
+
other.movedFrom_ = true;
|
|
62
|
+
}
|
|
63
|
+
return *this;
|
|
41
64
|
}
|
|
65
|
+
|
|
42
66
|
~ThreadPool() {
|
|
67
|
+
if (movedFrom_) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
43
70
|
loadBalancerSender.send(StopEvent{});
|
|
44
71
|
loadBalancerThread.join();
|
|
45
72
|
for (auto& worker : workers) {
|
|
@@ -59,16 +86,47 @@ public:
|
|
|
59
86
|
/// @note IMPORTANT: This function is not thread-safe and should be called from a single thread only.
|
|
60
87
|
template<typename Func, typename ... Args, typename = std::enable_if_t<std::is_invocable_r_v<void, Func, Args...>>>
|
|
61
88
|
void schedule(Func &&task, Args &&... args) noexcept {
|
|
62
|
-
|
|
89
|
+
controlBlock_->tasksScheduled.fetch_add(1, std::memory_order_release);
|
|
90
|
+
|
|
91
|
+
/// We know that lifetime of each worker thus spsc thus lambda is strongly bounded by ThreadPool lifetime
|
|
92
|
+
/// so we can safely capture control block pointer unsafely here
|
|
93
|
+
Cntrl *cntrl = controlBlock_.get();
|
|
94
|
+
auto boundTask = [cntrl, f= std::forward<Func>(task), ...capturedArgs = std::forward<Args>(args)]() mutable {
|
|
63
95
|
f(std::forward<Args>(capturedArgs)...);
|
|
96
|
+
size_t left = cntrl->tasksScheduled.fetch_sub(1, std::memory_order_acq_rel) - 1;
|
|
97
|
+
if (left == 0) {
|
|
98
|
+
cntrl->waitingForTasks.store(false, std::memory_order_release);
|
|
99
|
+
cntrl->waitingForTasks.notify_one();
|
|
100
|
+
}
|
|
64
101
|
};
|
|
65
102
|
loadBalancerSender.send(TaskEvent{audioapi::move_only_function<void()>(std::move(boundTask))});
|
|
66
103
|
}
|
|
67
104
|
|
|
105
|
+
/// @brief Waits for all scheduled tasks to complete
|
|
106
|
+
void wait() {
|
|
107
|
+
/// This logic might seem incorrect at first glance
|
|
108
|
+
/// Main principle for this is that there is only one thread scheduling tasks
|
|
109
|
+
/// If he is waiting for the tasks he CANNOT schedule new tasks so we can assume partial
|
|
110
|
+
/// synchronization here.
|
|
111
|
+
/// We first store true so if any task finishes at this moment he will flip it
|
|
112
|
+
/// Then we check if there are any tasks scheduled
|
|
113
|
+
/// If there are none we can return immediately
|
|
114
|
+
/// If there are some we wait until the last task flips the flag to false
|
|
115
|
+
controlBlock_->waitingForTasks.store(true, std::memory_order_release);
|
|
116
|
+
if (controlBlock_->tasksScheduled.load(std::memory_order_acquire) == 0) {
|
|
117
|
+
controlBlock_->waitingForTasks.store(false, std::memory_order_release);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
controlBlock_->waitingForTasks.wait(true, std::memory_order_acquire);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
68
124
|
private:
|
|
69
125
|
std::thread loadBalancerThread;
|
|
70
126
|
std::vector<std::thread> workers;
|
|
71
127
|
Sender loadBalancerSender;
|
|
128
|
+
std::unique_ptr<Cntrl> controlBlock_;
|
|
129
|
+
bool movedFrom_ = false;
|
|
72
130
|
|
|
73
131
|
void workerThreadFunc(Receiver &&receiver) {
|
|
74
132
|
Receiver localReceiver = std::move(receiver);
|
|
@@ -12,41 +12,44 @@ FetchContent_Declare(
|
|
|
12
12
|
googletest
|
|
13
13
|
URL https://github.com/google/googletest/archive/3983f67e32fb3e9294487b9d4f9586efa6e5d088.zip
|
|
14
14
|
)
|
|
15
|
+
|
|
15
16
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
16
17
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
17
18
|
FetchContent_MakeAvailable(googletest)
|
|
18
19
|
|
|
19
20
|
enable_testing()
|
|
20
21
|
|
|
22
|
+
set(REACT_NATIVE_AUDIO_API_DIR "${ROOT}/node_modules/react-native-audio-api")
|
|
23
|
+
|
|
21
24
|
file(GLOB_RECURSE RNAUDIOAPI_SRC
|
|
22
25
|
CONFIGURE_DEPENDS
|
|
23
|
-
"${
|
|
24
|
-
"${
|
|
26
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/*.cpp"
|
|
27
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp"
|
|
25
28
|
)
|
|
26
29
|
|
|
27
30
|
# exclude HostObjects from tests
|
|
28
31
|
list(FILTER RNAUDIOAPI_SRC EXCLUDE REGEX ".*/audioapi/HostObjects/.*\\.cpp$")
|
|
29
32
|
|
|
30
33
|
list(REMOVE_ITEM RNAUDIOAPI_SRC
|
|
31
|
-
"${
|
|
32
|
-
"${
|
|
33
|
-
"${
|
|
34
|
-
"${
|
|
35
|
-
"${
|
|
36
|
-
"${
|
|
37
|
-
"${
|
|
38
|
-
"${
|
|
34
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/AudioContext.cpp"
|
|
35
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/effects/WorkletNode.cpp"
|
|
36
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp"
|
|
37
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp"
|
|
38
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/sources/StreamerNode.cpp"
|
|
39
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/sources/StreamerNode.h"
|
|
40
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp"
|
|
41
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h"
|
|
39
42
|
)
|
|
40
43
|
|
|
41
44
|
file(GLOB_RECURSE RNAUDIOAPI_LIBS
|
|
42
45
|
CONFIGURE_DEPENDS
|
|
43
|
-
"${
|
|
44
|
-
"${
|
|
46
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/*.c"
|
|
47
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/*.h"
|
|
45
48
|
)
|
|
46
49
|
|
|
47
50
|
list(REMOVE_ITEM RNAUDIOAPI_LIBS
|
|
48
|
-
"${
|
|
49
|
-
"${
|
|
51
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.c"
|
|
52
|
+
"${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.c"
|
|
50
53
|
)
|
|
51
54
|
|
|
52
55
|
add_library(rnaudioapi STATIC ${RNAUDIOAPI_SRC})
|
|
@@ -57,6 +60,8 @@ target_include_directories(rnaudioapi PUBLIC
|
|
|
57
60
|
${JSI_DIR}
|
|
58
61
|
"${REACT_NATIVE_DIR}/ReactCommon"
|
|
59
62
|
"${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
|
|
63
|
+
${gtest_SOURCE_DIR}/include
|
|
64
|
+
${gmock_SOURCE_DIR}/include
|
|
60
65
|
)
|
|
61
66
|
|
|
62
67
|
target_include_directories(rnaudioapi_libs PUBLIC
|
|
@@ -8,7 +8,7 @@ using namespace audioapi;
|
|
|
8
8
|
|
|
9
9
|
class AudioParamTest : public ::testing::Test {
|
|
10
10
|
protected:
|
|
11
|
-
std::shared_ptr<
|
|
11
|
+
std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
|
|
12
12
|
std::unique_ptr<OfflineAudioContext> context;
|
|
13
13
|
static constexpr int sampleRate = 44100;
|
|
14
14
|
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
#include <audioapi/core/OfflineAudioContext.h>
|
|
2
|
+
#include <audioapi/core/destinations/AudioDestinationNode.h>
|
|
3
|
+
#include <audioapi/core/sources/AudioScheduledSourceNode.h>
|
|
4
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
5
|
+
#include <audioapi/utils/AudioBus.h>
|
|
6
|
+
#include <gtest/gtest.h>
|
|
7
|
+
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
8
|
+
|
|
9
|
+
using namespace audioapi;
|
|
10
|
+
static constexpr int SAMPLE_RATE = 44100;
|
|
11
|
+
static constexpr int RENDER_QUANTUM = 128;
|
|
12
|
+
static constexpr double RENDER_QUANTUM_TIME =
|
|
13
|
+
static_cast<double>(RENDER_QUANTUM) / SAMPLE_RATE;
|
|
14
|
+
|
|
15
|
+
class AudioScheduledSourceTest : public ::testing::Test {
|
|
16
|
+
protected:
|
|
17
|
+
std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
|
|
18
|
+
std::unique_ptr<OfflineAudioContext> context;
|
|
19
|
+
|
|
20
|
+
void SetUp() override {
|
|
21
|
+
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
22
|
+
context = std::make_unique<OfflineAudioContext>(
|
|
23
|
+
2, 5 * SAMPLE_RATE, SAMPLE_RATE, eventRegistry, RuntimeRegistry{});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
class TestableAudioScheduledSourceNode : public AudioScheduledSourceNode {
|
|
28
|
+
public:
|
|
29
|
+
explicit TestableAudioScheduledSourceNode(BaseAudioContext *context)
|
|
30
|
+
: AudioScheduledSourceNode(context) {
|
|
31
|
+
isInitialized_ = true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void updatePlaybackInfo(
|
|
35
|
+
const std::shared_ptr<AudioBus> &processingBus,
|
|
36
|
+
int framesToProcess,
|
|
37
|
+
size_t &startOffset,
|
|
38
|
+
size_t &nonSilentFramesToProcess) {
|
|
39
|
+
AudioScheduledSourceNode::updatePlaybackInfo(
|
|
40
|
+
processingBus, framesToProcess, startOffset, nonSilentFramesToProcess);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus> &, int)
|
|
44
|
+
override {
|
|
45
|
+
return nullptr;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
PlaybackState getPlaybackState() const {
|
|
49
|
+
return playbackState_;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void playFrames(int frames) {
|
|
53
|
+
size_t startOffset = 0;
|
|
54
|
+
size_t nonSilentFramesToProcess = 0;
|
|
55
|
+
auto processingBus =
|
|
56
|
+
std::make_shared<AudioBus>(128, 2, static_cast<float>(SAMPLE_RATE));
|
|
57
|
+
updatePlaybackInfo(
|
|
58
|
+
processingBus, frames, startOffset, nonSilentFramesToProcess);
|
|
59
|
+
context_->getDestination()->renderAudio(processingBus, frames);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
TEST_F(AudioScheduledSourceTest, IsUnscheduledStateSetCorrectly) {
|
|
64
|
+
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
65
|
+
EXPECT_EQ(
|
|
66
|
+
sourceNode.getPlaybackState(),
|
|
67
|
+
AudioScheduledSourceNode::PlaybackState::UNSCHEDULED);
|
|
68
|
+
|
|
69
|
+
sourceNode.start(RENDER_QUANTUM_TIME);
|
|
70
|
+
EXPECT_NE(
|
|
71
|
+
sourceNode.getPlaybackState(),
|
|
72
|
+
AudioScheduledSourceNode::PlaybackState::UNSCHEDULED);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
TEST_F(AudioScheduledSourceTest, IsScheduledStateSetCorrectly) {
|
|
76
|
+
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
77
|
+
sourceNode.start(RENDER_QUANTUM_TIME);
|
|
78
|
+
EXPECT_EQ(
|
|
79
|
+
sourceNode.getPlaybackState(),
|
|
80
|
+
AudioScheduledSourceNode::PlaybackState::SCHEDULED);
|
|
81
|
+
|
|
82
|
+
sourceNode.playFrames(RENDER_QUANTUM);
|
|
83
|
+
EXPECT_EQ(
|
|
84
|
+
sourceNode.getPlaybackState(),
|
|
85
|
+
AudioScheduledSourceNode::PlaybackState::SCHEDULED);
|
|
86
|
+
|
|
87
|
+
sourceNode.playFrames(1);
|
|
88
|
+
EXPECT_NE(
|
|
89
|
+
sourceNode.getPlaybackState(),
|
|
90
|
+
AudioScheduledSourceNode::PlaybackState::SCHEDULED);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
TEST_F(AudioScheduledSourceTest, IsPlayingStateSetCorrectly) {
|
|
94
|
+
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
95
|
+
sourceNode.start(0);
|
|
96
|
+
sourceNode.stop(RENDER_QUANTUM_TIME);
|
|
97
|
+
|
|
98
|
+
sourceNode.playFrames(RENDER_QUANTUM);
|
|
99
|
+
EXPECT_EQ(
|
|
100
|
+
sourceNode.getPlaybackState(),
|
|
101
|
+
AudioScheduledSourceNode::PlaybackState::PLAYING);
|
|
102
|
+
|
|
103
|
+
sourceNode.playFrames(1);
|
|
104
|
+
EXPECT_NE(
|
|
105
|
+
sourceNode.getPlaybackState(),
|
|
106
|
+
AudioScheduledSourceNode::PlaybackState::PLAYING);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
TEST_F(AudioScheduledSourceTest, IsStopScheduledStateSetCorrectly) {
|
|
110
|
+
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
111
|
+
sourceNode.start(0);
|
|
112
|
+
sourceNode.stop(RENDER_QUANTUM_TIME);
|
|
113
|
+
sourceNode.playFrames(1); // start playing
|
|
114
|
+
sourceNode.playFrames(RENDER_QUANTUM);
|
|
115
|
+
EXPECT_EQ(
|
|
116
|
+
sourceNode.getPlaybackState(),
|
|
117
|
+
AudioScheduledSourceNode::PlaybackState::STOP_SCHEDULED);
|
|
118
|
+
|
|
119
|
+
sourceNode.playFrames(1);
|
|
120
|
+
EXPECT_NE(
|
|
121
|
+
sourceNode.getPlaybackState(),
|
|
122
|
+
AudioScheduledSourceNode::PlaybackState::STOP_SCHEDULED);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
TEST_F(AudioScheduledSourceTest, IsFinishedStateSetCorrectly) {
|
|
126
|
+
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
127
|
+
sourceNode.start(0);
|
|
128
|
+
sourceNode.stop(RENDER_QUANTUM_TIME);
|
|
129
|
+
sourceNode.playFrames(1); // start playing
|
|
130
|
+
|
|
131
|
+
sourceNode.playFrames(RENDER_QUANTUM);
|
|
132
|
+
sourceNode.playFrames(1);
|
|
133
|
+
EXPECT_TRUE(sourceNode.isFinished());
|
|
134
|
+
}
|
|
@@ -10,7 +10,7 @@ using namespace audioapi;
|
|
|
10
10
|
|
|
11
11
|
class ConstantSourceTest : public ::testing::Test {
|
|
12
12
|
protected:
|
|
13
|
-
std::shared_ptr<
|
|
13
|
+
std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
|
|
14
14
|
std::unique_ptr<OfflineAudioContext> context;
|
|
15
15
|
static constexpr int sampleRate = 44100;
|
|
16
16
|
|
|
@@ -10,7 +10,7 @@ using namespace audioapi;
|
|
|
10
10
|
|
|
11
11
|
class GainTest : public ::testing::Test {
|
|
12
12
|
protected:
|
|
13
|
-
std::shared_ptr<
|
|
13
|
+
std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
|
|
14
14
|
std::unique_ptr<OfflineAudioContext> context;
|
|
15
15
|
static constexpr int sampleRate = 44100;
|
|
16
16
|
|
|
@@ -17,8 +17,8 @@ class MockAudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
|
|
|
17
17
|
MOCK_METHOD(void, unregisterHandler,
|
|
18
18
|
(const std::string &eventName, uint64_t listenerId), (override));
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
(const std::string &eventName, const EventMap &body)
|
|
22
|
-
|
|
23
|
-
(const std::string &eventName, uint64_t listenerId, const EventMap &body)
|
|
20
|
+
MOCK_METHOD2(invokeHandlerWithEventBody, void
|
|
21
|
+
(const std::string &eventName, const EventMap &body));
|
|
22
|
+
MOCK_METHOD3(invokeHandlerWithEventBody, void
|
|
23
|
+
(const std::string &eventName, uint64_t listenerId, const EventMap &body));
|
|
24
24
|
};
|
|
@@ -8,7 +8,7 @@ using namespace audioapi;
|
|
|
8
8
|
|
|
9
9
|
class OscillatorTest : public ::testing::Test {
|
|
10
10
|
protected:
|
|
11
|
-
std::shared_ptr<
|
|
11
|
+
std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
|
|
12
12
|
std::unique_ptr<OfflineAudioContext> context;
|
|
13
13
|
static constexpr int sampleRate = 44100;
|
|
14
14
|
|
|
@@ -10,7 +10,7 @@ using namespace audioapi;
|
|
|
10
10
|
|
|
11
11
|
class StereoPannerTest : public ::testing::Test {
|
|
12
12
|
protected:
|
|
13
|
-
std::shared_ptr<
|
|
13
|
+
std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
|
|
14
14
|
std::unique_ptr<OfflineAudioContext> context;
|
|
15
15
|
static constexpr int sampleRate = 44100;
|
|
16
16
|
|