react-native-audio-api 0.10.0-nightly-e16d7ff-20251030 → 0.11.0-alpha.1
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/RNAudioAPI.podspec +11 -16
- package/android/build.gradle +3 -33
- package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -6
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +0 -5
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +0 -1
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +142 -28
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +40 -13
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +2 -4
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +37 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +187 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +57 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -6
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +34 -0
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +133 -0
- package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +3 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +154 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +41 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +429 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +113 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +47 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +28 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +269 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +47 -0
- package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +31 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +3 -29
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +9 -21
- package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +6 -27
- package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +0 -11
- package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
- 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/AudioAPIModuleInstaller.h +2 -30
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +0 -18
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +0 -1
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +97 -18
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +18 -6
- package/common/cpp/audioapi/core/AudioNode.h +2 -3
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +0 -10
- package/common/cpp/audioapi/core/BaseAudioContext.h +0 -2
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +32 -69
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +1 -37
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +36 -82
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +52 -31
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +58 -59
- package/common/cpp/audioapi/core/sources/StreamerNode.h +8 -37
- package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +0 -5
- package/common/cpp/audioapi/core/utils/Constants.h +1 -2
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +10 -0
- package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
- package/common/cpp/audioapi/dsp/FFT.cpp +26 -0
- package/common/cpp/audioapi/dsp/FFT.h +2 -26
- 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/ffmpeg_include/libavcodec/avcodec.h +2 -2
- 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 +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
- 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 +44 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +1 -0
- 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 +1 -0
- 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 +44 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +1 -0
- 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 +1 -0
- 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 +44 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +1 -0
- 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 +1 -0
- 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 +44 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +1 -0
- 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 +1 -0
- 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/FFmpegDecoding.cpp +3 -2
- package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +32 -0
- package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +111 -0
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +391 -0
- package/common/cpp/audioapi/utils/AudioBus.cpp +0 -28
- package/common/cpp/audioapi/utils/AudioBus.h +0 -3
- package/common/cpp/audioapi/utils/ThreadPool.hpp +1 -59
- package/common/cpp/test/CMakeLists.txt +14 -19
- package/ios/audioapi/ios/AudioAPIModule.h +1 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +0 -2
- package/ios/audioapi/ios/core/IOSAudioFileOptions.h +36 -0
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +140 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +51 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +223 -0
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +28 -10
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +117 -30
- package/ios/audioapi/ios/core/IOSRecorderCallback.h +57 -0
- package/ios/audioapi/ios/core/IOSRecorderCallback.mm +189 -0
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +4 -9
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +29 -71
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -0
- package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
- package/ios/audioapi/ios/system/AudioSessionManager.mm +0 -9
- package/ios/audioapi/ios/system/LockScreenManager.h +1 -0
- package/ios/audioapi/ios/system/LockScreenManager.mm +19 -6
- package/lib/commonjs/api.js +76 -141
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +0 -8
- 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 +171 -13
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +25 -28
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/types.js +46 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/bitEnums.js +33 -0
- package/lib/commonjs/utils/bitEnums.js.map +1 -0
- package/lib/commonjs/utils/index.js +21 -19
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +0 -12
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/OfflineAudioContext.js +0 -12
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/api.js +15 -16
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +0 -1
- 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 +171 -13
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +26 -29
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/OfflineAudioContext.js +2 -2
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/types.js +45 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/bitEnums.js +27 -0
- package/lib/module/utils/bitEnums.js.map +1 -0
- package/lib/module/utils/index.js +2 -15
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +0 -12
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/module/web-core/OfflineAudioContext.js +0 -12
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +17 -19
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +0 -1
- 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 +62 -7
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +1 -3
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +16 -0
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +42 -9
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +79 -8
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/bitEnums.d.ts +4 -0
- package/lib/typescript/utils/bitEnums.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +2 -5
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +0 -3
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/BaseAudioContext.d.ts +0 -2
- package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +0 -3
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/package.json +4 -7
- package/src/api.ts +18 -45
- package/src/api.web.ts +0 -1
- package/src/core/AudioContext.ts +2 -3
- package/src/core/AudioRecorder.ts +211 -24
- package/src/core/BaseAudioContext.ts +60 -67
- package/src/core/OfflineAudioContext.ts +2 -2
- package/src/events/types.ts +18 -0
- package/src/interfaces.ts +52 -16
- package/src/types.ts +90 -9
- package/src/utils/bitEnums.ts +51 -0
- package/src/utils/index.ts +2 -22
- package/src/web-core/AudioContext.tsx +0 -25
- package/src/web-core/BaseAudioContext.tsx +0 -2
- package/src/web-core/OfflineAudioContext.tsx +0 -25
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +0 -47
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +0 -20
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +0 -210
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +0 -55
- package/common/cpp/audioapi/dsp/Convolver.cpp +0 -213
- package/common/cpp/audioapi/dsp/Convolver.h +0 -45
- package/common/cpp/audioapi/libs/ffmpeg/relinking.md +0 -24
- package/common/cpp/audioapi/utils/AlignedAllocator.hpp +0 -50
- package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +0 -389
- package/common/cpp/test/src/biquad/BiquadFilterChromium.h +0 -64
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +0 -284
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +0 -40
- package/lib/commonjs/core/ConvolverNode.js +0 -37
- package/lib/commonjs/core/ConvolverNode.js.map +0 -1
- package/lib/commonjs/web-core/ConvolverNode.js +0 -40
- package/lib/commonjs/web-core/ConvolverNode.js.map +0 -1
- package/lib/commonjs/web-core/ConvolverNodeOptions.js +0 -6
- package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +0 -1
- package/lib/module/core/ConvolverNode.js +0 -31
- package/lib/module/core/ConvolverNode.js.map +0 -1
- package/lib/module/web-core/ConvolverNode.js +0 -34
- package/lib/module/web-core/ConvolverNode.js.map +0 -1
- package/lib/module/web-core/ConvolverNodeOptions.js +0 -4
- package/lib/module/web-core/ConvolverNodeOptions.js.map +0 -1
- package/lib/typescript/core/ConvolverNode.d.ts +0 -12
- package/lib/typescript/core/ConvolverNode.d.ts.map +0 -1
- package/lib/typescript/web-core/ConvolverNode.d.ts +0 -11
- package/lib/typescript/web-core/ConvolverNode.d.ts.map +0 -1
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +0 -6
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +0 -1
- package/scripts/download-prebuilt-binaries.sh +0 -52
- package/scripts/rnaa_utils.rb +0 -8
- package/scripts/validate-worklets-version.js +0 -28
- package/src/core/ConvolverNode.ts +0 -35
- package/src/web-core/ConvolverNode.tsx +0 -43
- package/src/web-core/ConvolverNodeOptions.tsx +0 -6
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#ifndef __OBJC__ // when compiled as C++
|
|
4
|
+
typedef struct objc_object AVAudioFormat;
|
|
5
|
+
typedef struct objc_object AudioBufferList;
|
|
6
|
+
typedef struct objc_object AVAudioConverter;
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
namespace audioapi {
|
|
13
|
+
|
|
14
|
+
class AudioBus;
|
|
15
|
+
class CircularAudioArray;
|
|
16
|
+
class AudioEventHandlerRegistry;
|
|
17
|
+
|
|
18
|
+
class IOSRecorderCallback {
|
|
19
|
+
public:
|
|
20
|
+
IOSRecorderCallback(
|
|
21
|
+
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
|
|
22
|
+
float sampleRate,
|
|
23
|
+
size_t bufferLength,
|
|
24
|
+
size_t channelCount,
|
|
25
|
+
uint64_t callbackId);
|
|
26
|
+
~IOSRecorderCallback();
|
|
27
|
+
|
|
28
|
+
void prepare(AVAudioFormat *bufferFormat, size_t maxInputBufferLength);
|
|
29
|
+
void cleanup();
|
|
30
|
+
|
|
31
|
+
void receiveAudioData(const AudioBufferList *audioBufferList, int numFrames);
|
|
32
|
+
void emitAudioData();
|
|
33
|
+
|
|
34
|
+
void invokeCallback(const std::shared_ptr<AudioBus> &bus, int numFrames);
|
|
35
|
+
void sendRemainingData();
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
float sampleRate_;
|
|
39
|
+
size_t bufferLength_;
|
|
40
|
+
size_t channelCount_;
|
|
41
|
+
uint64_t callbackId_;
|
|
42
|
+
size_t ringBufferSize_;
|
|
43
|
+
size_t converterInputBufferSize_;
|
|
44
|
+
size_t converterOutputBufferSize_;
|
|
45
|
+
|
|
46
|
+
std::shared_ptr<AudioEventHandlerRegistry> audioEventHandlerRegistry_;
|
|
47
|
+
std::vector<std::shared_ptr<CircularAudioArray>> circularBus_;
|
|
48
|
+
|
|
49
|
+
AVAudioFormat *bufferFormat_;
|
|
50
|
+
AVAudioFormat *callbackFormat_;
|
|
51
|
+
AVAudioConverter *converter_;
|
|
52
|
+
|
|
53
|
+
AVAudioPCMBuffer *converterInputBuffer_;
|
|
54
|
+
AVAudioPCMBuffer *converterOutputBuffer_;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#import <AVFoundation/AVFoundation.h>
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
|
|
4
|
+
#include <audioapi/HostObjects/sources/AudioBufferHostObject.h>
|
|
5
|
+
#include <audioapi/core/utils/Constants.h>
|
|
6
|
+
#include <audioapi/dsp/VectorMath.h>
|
|
7
|
+
#include <audioapi/events/AudioEventHandlerRegistry.h>
|
|
8
|
+
#include <audioapi/ios/core/IOSRecorderCallback.h>
|
|
9
|
+
#include <audioapi/utils/AudioArray.h>
|
|
10
|
+
#include <audioapi/utils/AudioBus.h>
|
|
11
|
+
#include <audioapi/utils/CircularAudioArray.h>
|
|
12
|
+
#include <algorithm>
|
|
13
|
+
|
|
14
|
+
namespace audioapi {
|
|
15
|
+
|
|
16
|
+
IOSRecorderCallback::IOSRecorderCallback(
|
|
17
|
+
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
|
|
18
|
+
float sampleRate,
|
|
19
|
+
size_t bufferLength,
|
|
20
|
+
size_t channelCount,
|
|
21
|
+
uint64_t callbackId)
|
|
22
|
+
: audioEventHandlerRegistry_(audioEventHandlerRegistry),
|
|
23
|
+
sampleRate_(sampleRate),
|
|
24
|
+
bufferLength_(bufferLength),
|
|
25
|
+
channelCount_(channelCount),
|
|
26
|
+
callbackId_(callbackId)
|
|
27
|
+
{
|
|
28
|
+
ringBufferSize_ = std::max((int)bufferLength_ * 2, 8192);
|
|
29
|
+
circularBus_.resize(channelCount_);
|
|
30
|
+
|
|
31
|
+
for (size_t i = 0; i < channelCount_; ++i) {
|
|
32
|
+
auto busAudioArray = std::make_shared<CircularAudioArray>(ringBufferSize_);
|
|
33
|
+
circularBus_[i] = busAudioArray;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
IOSRecorderCallback::~IOSRecorderCallback()
|
|
38
|
+
{
|
|
39
|
+
@autoreleasepool {
|
|
40
|
+
converter_ = nil;
|
|
41
|
+
bufferFormat_ = nil;
|
|
42
|
+
callbackFormat_ = nil;
|
|
43
|
+
converterInputBuffer_ = nil;
|
|
44
|
+
converterOutputBuffer_ = nil;
|
|
45
|
+
|
|
46
|
+
for (size_t i = 0; i < channelCount_; ++i) {
|
|
47
|
+
circularBus_[i].reset();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void IOSRecorderCallback::prepare(AVAudioFormat *bufferFormat, size_t maxInputBufferLength)
|
|
53
|
+
{
|
|
54
|
+
@autoreleasepool {
|
|
55
|
+
bufferFormat_ = bufferFormat;
|
|
56
|
+
converterInputBufferSize_ = maxInputBufferLength;
|
|
57
|
+
|
|
58
|
+
converterOutputBufferSize_ =
|
|
59
|
+
std::max((double)maxInputBufferLength, sampleRate_ / bufferFormat.sampleRate * maxInputBufferLength);
|
|
60
|
+
|
|
61
|
+
callbackFormat_ = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32
|
|
62
|
+
sampleRate:sampleRate_
|
|
63
|
+
channels:channelCount_
|
|
64
|
+
interleaved:NO];
|
|
65
|
+
|
|
66
|
+
converter_ = [[AVAudioConverter alloc] initFromFormat:bufferFormat toFormat:callbackFormat_];
|
|
67
|
+
converter_.sampleRateConverterAlgorithm = AVSampleRateConverterAlgorithm_Normal;
|
|
68
|
+
converter_.sampleRateConverterQuality = AVAudioQualityMax;
|
|
69
|
+
converter_.primeMethod = AVAudioConverterPrimeMethod_None;
|
|
70
|
+
|
|
71
|
+
converterInputBuffer_ = [[AVAudioPCMBuffer alloc] initWithPCMFormat:bufferFormat_
|
|
72
|
+
frameCapacity:(AVAudioFrameCount)converterInputBufferSize_];
|
|
73
|
+
converterOutputBuffer_ = [[AVAudioPCMBuffer alloc] initWithPCMFormat:callbackFormat_
|
|
74
|
+
frameCapacity:(AVAudioFrameCount)converterOutputBufferSize_];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
void IOSRecorderCallback::cleanup()
|
|
79
|
+
{
|
|
80
|
+
@autoreleasepool {
|
|
81
|
+
sendRemainingData();
|
|
82
|
+
|
|
83
|
+
converter_ = nil;
|
|
84
|
+
bufferFormat_ = nil;
|
|
85
|
+
callbackFormat_ = nil;
|
|
86
|
+
converterInputBuffer_ = nil;
|
|
87
|
+
converterOutputBuffer_ = nil;
|
|
88
|
+
|
|
89
|
+
for (size_t i = 0; i < channelCount_; ++i) {
|
|
90
|
+
circularBus_[i].reset();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
void IOSRecorderCallback::receiveAudioData(const AudioBufferList *inputBuffer, int numFrames)
|
|
96
|
+
{
|
|
97
|
+
@autoreleasepool {
|
|
98
|
+
NSError *error = nil;
|
|
99
|
+
|
|
100
|
+
if (bufferFormat_.sampleRate == sampleRate_ && bufferFormat_.channelCount == channelCount_ &&
|
|
101
|
+
!bufferFormat_.isInterleaved) {
|
|
102
|
+
// Directly write to circular buffer
|
|
103
|
+
for (size_t i = 0; i < channelCount_; ++i) {
|
|
104
|
+
auto *inputChannel = static_cast<float *>(inputBuffer->mBuffers[i].mData);
|
|
105
|
+
circularBus_[i]->push_back(inputChannel, numFrames);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
emitAudioData();
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
size_t outputFrameCount = ceil(numFrames * (sampleRate_ / bufferFormat_.sampleRate));
|
|
113
|
+
|
|
114
|
+
for (size_t i = 0; i < bufferFormat_.channelCount; ++i) {
|
|
115
|
+
memcpy(
|
|
116
|
+
converterInputBuffer_.mutableAudioBufferList->mBuffers[i].mData,
|
|
117
|
+
inputBuffer->mBuffers[i].mData,
|
|
118
|
+
inputBuffer->mBuffers[i].mDataByteSize);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
converterInputBuffer_.frameLength = numFrames;
|
|
122
|
+
|
|
123
|
+
AVAudioConverterInputBlock inputBlock =
|
|
124
|
+
^AVAudioBuffer *_Nullable(AVAudioPacketCount inNumberOfPackets, AVAudioConverterInputStatus *outStatus)
|
|
125
|
+
{
|
|
126
|
+
// this line is probably an delusion, but for my sanity lets keep it
|
|
127
|
+
inNumberOfPackets = numFrames;
|
|
128
|
+
*outStatus = AVAudioConverterInputStatus_HaveData;
|
|
129
|
+
return converterInputBuffer_;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
[converter_ convertToBuffer:converterOutputBuffer_ error:&error withInputFromBlock:inputBlock];
|
|
133
|
+
|
|
134
|
+
if (error != nil) {
|
|
135
|
+
NSLog(@"Error during audio conversion: %@", [error debugDescription]);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (size_t i = 0; i < channelCount_; ++i) {
|
|
140
|
+
auto *inputChannel = static_cast<float *>(converterOutputBuffer_.audioBufferList->mBuffers[i].mData);
|
|
141
|
+
circularBus_[i]->push_back(inputChannel, outputFrameCount);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
emitAudioData();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
void IOSRecorderCallback::emitAudioData()
|
|
149
|
+
{
|
|
150
|
+
while (circularBus_[0]->getNumberOfAvailableFrames() >= bufferLength_) {
|
|
151
|
+
auto bus = std::make_shared<AudioBus>(bufferLength_, channelCount_, sampleRate_);
|
|
152
|
+
|
|
153
|
+
for (size_t i = 0; i < channelCount_; ++i) {
|
|
154
|
+
auto *outputChannel = bus->getChannel(i)->getData();
|
|
155
|
+
circularBus_[i]->pop_front(outputChannel, bufferLength_);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
invokeCallback(bus, bufferLength_);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
void IOSRecorderCallback::invokeCallback(const std::shared_ptr<AudioBus> &bus, int numFrames)
|
|
163
|
+
{
|
|
164
|
+
auto audioBuffer = std::make_shared<AudioBuffer>(bus);
|
|
165
|
+
auto audioBufferHostObject = std::make_shared<AudioBufferHostObject>(audioBuffer);
|
|
166
|
+
|
|
167
|
+
std::unordered_map<std::string, EventValue> eventPayload = {};
|
|
168
|
+
eventPayload.insert({"buffer", audioBufferHostObject});
|
|
169
|
+
eventPayload.insert({"numFrames", numFrames});
|
|
170
|
+
|
|
171
|
+
if (audioEventHandlerRegistry_) {
|
|
172
|
+
audioEventHandlerRegistry_->invokeHandlerWithEventBody("audioReady", callbackId_, eventPayload);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
void IOSRecorderCallback::sendRemainingData()
|
|
177
|
+
{
|
|
178
|
+
auto numberOfFrames = circularBus_[0]->getNumberOfAvailableFrames();
|
|
179
|
+
auto bus = std::make_shared<AudioBus>(circularBus_[0]->getNumberOfAvailableFrames(), channelCount_, sampleRate_);
|
|
180
|
+
|
|
181
|
+
for (size_t i = 0; i < channelCount_; ++i) {
|
|
182
|
+
auto *outputChannel = bus->getChannel(i)->getData();
|
|
183
|
+
circularBus_[i]->pop_front(outputChannel, numberOfFrames);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
invokeCallback(bus, numberOfFrames);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
} // namespace audioapi
|
|
@@ -7,20 +7,15 @@ typedef void (^AudioReceiverBlock)(const AudioBufferList *inputBuffer, int numFr
|
|
|
7
7
|
|
|
8
8
|
@interface NativeAudioRecorder : NSObject
|
|
9
9
|
|
|
10
|
-
@property (nonatomic, assign) int bufferLength;
|
|
11
|
-
@property (nonatomic, assign) float sampleRate;
|
|
12
|
-
|
|
13
10
|
@property (nonatomic, strong) AVAudioSinkNode *sinkNode;
|
|
14
11
|
@property (nonatomic, copy) AVAudioSinkNodeReceiverBlock receiverSinkBlock;
|
|
15
12
|
@property (nonatomic, copy) AudioReceiverBlock receiverBlock;
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
- (instancetype)initWithReceiverBlock:(AudioReceiverBlock)receiverBlock;
|
|
15
|
+
|
|
16
|
+
- (AVAudioFormat *)getInputFormat;
|
|
20
17
|
|
|
21
|
-
- (
|
|
22
|
-
bufferLength:(int)bufferLength
|
|
23
|
-
sampleRate:(float)sampleRate;
|
|
18
|
+
- (int)getBufferSize;
|
|
24
19
|
|
|
25
20
|
- (void)start;
|
|
26
21
|
|
|
@@ -4,41 +4,36 @@
|
|
|
4
4
|
|
|
5
5
|
@implementation NativeAudioRecorder
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
bufferLength:(int)bufferLength
|
|
9
|
-
sampleRate:(float)sampleRate
|
|
7
|
+
static inline uint32_t nextPowerOfTwo(uint32_t x)
|
|
10
8
|
{
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
self.receiverBlock = [receiverBlock copy];
|
|
16
|
-
|
|
17
|
-
float devicePrefferedSampleRate = [[AVAudioSession sharedInstance] sampleRate];
|
|
9
|
+
if (x == 0) {
|
|
10
|
+
return 1;
|
|
11
|
+
}
|
|
18
12
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
x--;
|
|
14
|
+
x |= x >> 1;
|
|
15
|
+
x |= x >> 2;
|
|
16
|
+
x |= x >> 4;
|
|
17
|
+
x |= x >> 8;
|
|
18
|
+
x |= x >> 16;
|
|
19
|
+
x++;
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return x;
|
|
22
|
+
}
|
|
25
23
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
self.outputFormat = [[AVAudioFormat alloc] initWithCommonFormat:AVAudioPCMFormatFloat32
|
|
31
|
-
sampleRate:sampleRate
|
|
32
|
-
channels:1
|
|
33
|
-
interleaved:NO];
|
|
34
|
-
self.audioConverter = [[AVAudioConverter alloc] initFromFormat:self.inputFormat toFormat:self.outputFormat];
|
|
24
|
+
- (instancetype)initWithReceiverBlock:(AudioReceiverBlock)receiverBlock
|
|
25
|
+
{
|
|
26
|
+
if (self = [super init]) {
|
|
27
|
+
self.receiverBlock = [receiverBlock copy];
|
|
35
28
|
|
|
36
29
|
__weak typeof(self) weakSelf = self;
|
|
37
30
|
self.receiverSinkBlock = ^OSStatus(
|
|
38
31
|
const AudioTimeStamp *_Nonnull timestamp,
|
|
39
32
|
AVAudioFrameCount frameCount,
|
|
40
33
|
const AudioBufferList *_Nonnull inputData) {
|
|
41
|
-
|
|
34
|
+
weakSelf.receiverBlock(inputData, frameCount);
|
|
35
|
+
|
|
36
|
+
return kAudioServicesNoError;
|
|
42
37
|
};
|
|
43
38
|
|
|
44
39
|
self.sinkNode = [[AVAudioSinkNode alloc] initWithReceiverBlock:self.receiverSinkBlock];
|
|
@@ -47,55 +42,18 @@
|
|
|
47
42
|
return self;
|
|
48
43
|
}
|
|
49
44
|
|
|
50
|
-
- (
|
|
51
|
-
withFrameCount:(AVAudioFrameCount)frameCount
|
|
52
|
-
atTimestamp:(const AudioTimeStamp *)timestamp
|
|
45
|
+
- (AVAudioFormat *)getInputFormat
|
|
53
46
|
{
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (inputSampleRate != outputSampleRate) {
|
|
58
|
-
AVAudioPCMBuffer *inputBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:self.inputFormat
|
|
59
|
-
frameCapacity:frameCount];
|
|
60
|
-
memcpy(
|
|
61
|
-
inputBuffer.mutableAudioBufferList->mBuffers[0].mData,
|
|
62
|
-
inputData->mBuffers[0].mData,
|
|
63
|
-
inputData->mBuffers[0].mDataByteSize);
|
|
64
|
-
inputBuffer.frameLength = frameCount;
|
|
65
|
-
|
|
66
|
-
int outputFrameCount = frameCount * outputSampleRate / inputSampleRate;
|
|
67
|
-
|
|
68
|
-
AVAudioPCMBuffer *outputBuffer = [[AVAudioPCMBuffer alloc] initWithPCMFormat:self.audioConverter.outputFormat
|
|
69
|
-
frameCapacity:outputFrameCount];
|
|
70
|
-
|
|
71
|
-
NSError *error = nil;
|
|
72
|
-
AVAudioConverterInputBlock inputBlock =
|
|
73
|
-
^AVAudioBuffer *_Nullable(AVAudioPacketCount inNumberOfPackets, AVAudioConverterInputStatus *outStatus)
|
|
74
|
-
{
|
|
75
|
-
*outStatus = AVAudioConverterInputStatus_HaveData;
|
|
76
|
-
return inputBuffer;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/// IMPORTANT: AVAudioConverter leaks memory without autorelease pool
|
|
80
|
-
/// more details here: https://github.com/poneciak57/AVAudioConverter-memory-leak-repro-electric-boogaloo
|
|
81
|
-
/// we can try to remove it in the future or refactor to reuse buffers to minimize allocations
|
|
82
|
-
@autoreleasepool {
|
|
83
|
-
[self.audioConverter convertToBuffer:outputBuffer error:&error withInputFromBlock:inputBlock];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (error) {
|
|
87
|
-
NSLog(@"Error during audio conversion: %@", error.localizedDescription);
|
|
88
|
-
return kAudioServicesBadSpecifierSizeError;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
self.receiverBlock(outputBuffer.audioBufferList, outputBuffer.frameLength);
|
|
92
|
-
|
|
93
|
-
return kAudioServicesNoError;
|
|
94
|
-
}
|
|
47
|
+
return [AudioEngine.sharedInstance.audioEngine.inputNode inputFormatForBus:0];
|
|
48
|
+
}
|
|
95
49
|
|
|
96
|
-
|
|
50
|
+
- (int)getBufferSize
|
|
51
|
+
{
|
|
52
|
+
// NOTE: this method should be called only after the session is activated
|
|
53
|
+
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
|
|
54
|
+
float bufferDuration = audioSession.IOBufferDuration > 0 ? audioSession.IOBufferDuration : 0.02;
|
|
97
55
|
|
|
98
|
-
return
|
|
56
|
+
return nextPowerOfTwo(ceil(bufferDuration * audioSession.sampleRate));
|
|
99
57
|
}
|
|
100
58
|
|
|
101
59
|
- (void)start
|
|
@@ -118,9 +118,9 @@ static AudioEngine *_sharedInstance = nil;
|
|
|
118
118
|
- (void)stopEngine
|
|
119
119
|
{
|
|
120
120
|
NSLog(@"[AudioEngine] stopEngine");
|
|
121
|
-
if (![self.audioEngine isRunning]) {
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
121
|
+
// if (![self.audioEngine isRunning]) {
|
|
122
|
+
// return;
|
|
123
|
+
// }
|
|
124
124
|
|
|
125
125
|
self.isSupposedToBeRunning = false;
|
|
126
126
|
[self.audioEngine stop];
|
|
@@ -213,15 +213,6 @@
|
|
|
213
213
|
|
|
214
214
|
- (void)requestRecordingPermissions:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject
|
|
215
215
|
{
|
|
216
|
-
id value = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSMicrophoneUsageDescription"];
|
|
217
|
-
// if there is no entry NSMicrophoneUsageDescription calling requestRecordPermission will quit an app
|
|
218
|
-
if (value == nil) {
|
|
219
|
-
reject(
|
|
220
|
-
nil,
|
|
221
|
-
@"There is no NSMicrophoneUsageDescription entry in info.plist file. App cannot access microphone without it.",
|
|
222
|
-
nil);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
216
|
if (@available(iOS 17, *)) {
|
|
226
217
|
[AVAudioSession.sharedInstance requestRecordPermission:^(BOOL granted) {
|
|
227
218
|
if (granted) {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
@property (nonatomic, weak) MPNowPlayingInfoCenter *playingInfoCenter;
|
|
14
14
|
@property (nonatomic, copy) NSString *artworkUrl;
|
|
15
|
+
@property (nonatomic, assign) bool isReceivingRemoteCommands;
|
|
15
16
|
|
|
16
17
|
- (instancetype)initWithAudioAPIModule:(AudioAPIModule *)audioAPIModule;
|
|
17
18
|
- (void)cleanup;
|
|
@@ -19,28 +19,40 @@
|
|
|
19
19
|
if (self = [super init]) {
|
|
20
20
|
self.audioAPIModule = audioAPIModule;
|
|
21
21
|
self.playingInfoCenter = [MPNowPlayingInfoCenter defaultCenter];
|
|
22
|
+
self.isReceivingRemoteCommands = false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return self;
|
|
26
|
+
}
|
|
22
27
|
|
|
28
|
+
- (void)toggleRemoteCommands:(bool)enable
|
|
29
|
+
{
|
|
30
|
+
if (enable && !self.isReceivingRemoteCommands) {
|
|
31
|
+
self.isReceivingRemoteCommands = true;
|
|
23
32
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
24
33
|
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
|
|
25
34
|
});
|
|
35
|
+
return;
|
|
36
|
+
} else if (!enable && self.isReceivingRemoteCommands) {
|
|
37
|
+
self.isReceivingRemoteCommands = false;
|
|
38
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
39
|
+
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
|
|
40
|
+
});
|
|
41
|
+
return;
|
|
26
42
|
}
|
|
27
|
-
|
|
28
|
-
return self;
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
- (void)cleanup
|
|
32
46
|
{
|
|
33
47
|
NSLog(@"[LockScreenManager] cleanup");
|
|
48
|
+
[self toggleRemoteCommands:false];
|
|
34
49
|
[self resetLockScreenInfo];
|
|
35
|
-
|
|
36
|
-
dispatch_async(dispatch_get_main_queue(), ^{
|
|
37
|
-
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
|
|
38
|
-
});
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
- (void)setLockScreenInfo:(NSDictionary *)info
|
|
42
53
|
{
|
|
43
54
|
self.playingInfoCenter = [MPNowPlayingInfoCenter defaultCenter];
|
|
55
|
+
[self toggleRemoteCommands:true];
|
|
44
56
|
|
|
45
57
|
// now playing info(lock screen info)
|
|
46
58
|
NSMutableDictionary *lockScreenInfoDict;
|
|
@@ -79,6 +91,7 @@
|
|
|
79
91
|
|
|
80
92
|
- (void)resetLockScreenInfo
|
|
81
93
|
{
|
|
94
|
+
[self toggleRemoteCommands:false];
|
|
82
95
|
self.playingInfoCenter = [MPNowPlayingInfoCenter defaultCenter];
|
|
83
96
|
self.playingInfoCenter.nowPlayingInfo = nil;
|
|
84
97
|
self.artworkUrl = nil;
|