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.
Files changed (288) hide show
  1. package/RNAudioAPI.podspec +11 -16
  2. package/android/build.gradle +3 -33
  3. package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -6
  4. package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +0 -5
  5. package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +0 -1
  6. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +142 -28
  7. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +40 -13
  8. package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +2 -4
  9. package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
  10. package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +37 -0
  11. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +187 -0
  12. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +57 -0
  13. package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -6
  14. package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +34 -0
  15. package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +133 -0
  16. package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +3 -0
  17. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +154 -0
  18. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +41 -0
  19. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +429 -0
  20. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +113 -0
  21. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +47 -0
  22. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +28 -0
  23. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +269 -0
  24. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +47 -0
  25. package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +31 -0
  26. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +3 -29
  27. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +9 -21
  28. package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +6 -27
  29. package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +0 -11
  30. package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
  31. package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
  32. package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
  33. package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
  34. package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
  35. package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
  36. package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
  37. package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
  38. package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
  39. package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
  40. package/android/src/main/jniLibs/x86/libavformat.so +0 -0
  41. package/android/src/main/jniLibs/x86/libavutil.so +0 -0
  42. package/android/src/main/jniLibs/x86/libswresample.so +0 -0
  43. package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
  44. package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
  45. package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
  46. package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
  47. package/common/cpp/audioapi/AudioAPIModuleInstaller.h +2 -30
  48. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +0 -18
  49. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +0 -1
  50. package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
  51. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +97 -18
  52. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +18 -6
  53. package/common/cpp/audioapi/core/AudioNode.h +2 -3
  54. package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
  55. package/common/cpp/audioapi/core/BaseAudioContext.cpp +0 -10
  56. package/common/cpp/audioapi/core/BaseAudioContext.h +0 -2
  57. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +32 -69
  58. package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +1 -37
  59. package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +36 -82
  60. package/common/cpp/audioapi/core/inputs/AudioRecorder.h +52 -31
  61. package/common/cpp/audioapi/core/sources/StreamerNode.cpp +58 -59
  62. package/common/cpp/audioapi/core/sources/StreamerNode.h +8 -37
  63. package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +0 -5
  64. package/common/cpp/audioapi/core/utils/Constants.h +1 -2
  65. package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +10 -0
  66. package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
  67. package/common/cpp/audioapi/dsp/FFT.cpp +26 -0
  68. package/common/cpp/audioapi/dsp/FFT.h +2 -26
  69. package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
  70. package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
  71. package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
  72. package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
  73. package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
  74. package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
  75. package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
  76. package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
  77. package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
  78. package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
  79. package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
  80. package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
  81. package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
  82. package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
  83. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
  84. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
  85. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +2 -2
  86. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
  87. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
  88. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +1 -1
  89. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +1 -1
  90. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +2 -2
  91. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
  92. package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
  93. package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
  94. package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
  95. package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
  96. package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
  97. package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
  98. package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
  99. package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
  100. package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
  101. package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
  102. package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
  103. package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
  104. package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
  105. package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
  106. package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
  107. package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
  108. package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +44 -0
  109. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +1 -0
  110. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
  111. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +1 -0
  112. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
  113. package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +44 -0
  114. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +1 -0
  115. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
  116. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +1 -0
  117. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
  118. package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +44 -0
  119. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +1 -0
  120. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
  121. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +1 -0
  122. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
  123. package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +44 -0
  124. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +1 -0
  125. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
  126. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +1 -0
  127. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
  128. package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
  129. package/common/cpp/audioapi/external/x86/libogg.a +0 -0
  130. package/common/cpp/audioapi/external/x86/libopus.a +0 -0
  131. package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
  132. package/common/cpp/audioapi/external/x86/libssl.a +0 -0
  133. package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
  134. package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
  135. package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
  136. package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
  137. package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
  138. package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
  139. package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
  140. package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
  141. package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
  142. package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
  143. package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
  144. package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +3 -2
  145. package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +32 -0
  146. package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +111 -0
  147. package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +391 -0
  148. package/common/cpp/audioapi/utils/AudioBus.cpp +0 -28
  149. package/common/cpp/audioapi/utils/AudioBus.h +0 -3
  150. package/common/cpp/audioapi/utils/ThreadPool.hpp +1 -59
  151. package/common/cpp/test/CMakeLists.txt +14 -19
  152. package/ios/audioapi/ios/AudioAPIModule.h +1 -2
  153. package/ios/audioapi/ios/AudioAPIModule.mm +0 -2
  154. package/ios/audioapi/ios/core/IOSAudioFileOptions.h +36 -0
  155. package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +140 -0
  156. package/ios/audioapi/ios/core/IOSAudioFileWriter.h +51 -0
  157. package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +223 -0
  158. package/ios/audioapi/ios/core/IOSAudioRecorder.h +28 -10
  159. package/ios/audioapi/ios/core/IOSAudioRecorder.mm +117 -30
  160. package/ios/audioapi/ios/core/IOSRecorderCallback.h +57 -0
  161. package/ios/audioapi/ios/core/IOSRecorderCallback.mm +189 -0
  162. package/ios/audioapi/ios/core/NativeAudioRecorder.h +4 -9
  163. package/ios/audioapi/ios/core/NativeAudioRecorder.m +29 -71
  164. package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -0
  165. package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
  166. package/ios/audioapi/ios/system/AudioSessionManager.mm +0 -9
  167. package/ios/audioapi/ios/system/LockScreenManager.h +1 -0
  168. package/ios/audioapi/ios/system/LockScreenManager.mm +19 -6
  169. package/lib/commonjs/api.js +76 -141
  170. package/lib/commonjs/api.js.map +1 -1
  171. package/lib/commonjs/api.web.js +0 -8
  172. package/lib/commonjs/api.web.js.map +1 -1
  173. package/lib/commonjs/core/AudioContext.js +1 -1
  174. package/lib/commonjs/core/AudioContext.js.map +1 -1
  175. package/lib/commonjs/core/AudioRecorder.js +171 -13
  176. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  177. package/lib/commonjs/core/BaseAudioContext.js +25 -28
  178. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  179. package/lib/commonjs/core/OfflineAudioContext.js +1 -1
  180. package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
  181. package/lib/commonjs/types.js +46 -0
  182. package/lib/commonjs/types.js.map +1 -1
  183. package/lib/commonjs/utils/bitEnums.js +33 -0
  184. package/lib/commonjs/utils/bitEnums.js.map +1 -0
  185. package/lib/commonjs/utils/index.js +21 -19
  186. package/lib/commonjs/utils/index.js.map +1 -1
  187. package/lib/commonjs/web-core/AudioContext.js +0 -12
  188. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  189. package/lib/commonjs/web-core/OfflineAudioContext.js +0 -12
  190. package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
  191. package/lib/module/api.js +15 -16
  192. package/lib/module/api.js.map +1 -1
  193. package/lib/module/api.web.js +0 -1
  194. package/lib/module/api.web.js.map +1 -1
  195. package/lib/module/core/AudioContext.js +2 -2
  196. package/lib/module/core/AudioContext.js.map +1 -1
  197. package/lib/module/core/AudioRecorder.js +171 -13
  198. package/lib/module/core/AudioRecorder.js.map +1 -1
  199. package/lib/module/core/BaseAudioContext.js +26 -29
  200. package/lib/module/core/BaseAudioContext.js.map +1 -1
  201. package/lib/module/core/OfflineAudioContext.js +2 -2
  202. package/lib/module/core/OfflineAudioContext.js.map +1 -1
  203. package/lib/module/types.js +45 -1
  204. package/lib/module/types.js.map +1 -1
  205. package/lib/module/utils/bitEnums.js +27 -0
  206. package/lib/module/utils/bitEnums.js.map +1 -0
  207. package/lib/module/utils/index.js +2 -15
  208. package/lib/module/utils/index.js.map +1 -1
  209. package/lib/module/web-core/AudioContext.js +0 -12
  210. package/lib/module/web-core/AudioContext.js.map +1 -1
  211. package/lib/module/web-core/OfflineAudioContext.js +0 -12
  212. package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
  213. package/lib/typescript/api.d.ts +17 -19
  214. package/lib/typescript/api.d.ts.map +1 -1
  215. package/lib/typescript/api.web.d.ts +0 -1
  216. package/lib/typescript/api.web.d.ts.map +1 -1
  217. package/lib/typescript/core/AudioContext.d.ts.map +1 -1
  218. package/lib/typescript/core/AudioRecorder.d.ts +62 -7
  219. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  220. package/lib/typescript/core/BaseAudioContext.d.ts +1 -3
  221. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  222. package/lib/typescript/events/types.d.ts +16 -0
  223. package/lib/typescript/events/types.d.ts.map +1 -1
  224. package/lib/typescript/interfaces.d.ts +42 -9
  225. package/lib/typescript/interfaces.d.ts.map +1 -1
  226. package/lib/typescript/types.d.ts +79 -8
  227. package/lib/typescript/types.d.ts.map +1 -1
  228. package/lib/typescript/utils/bitEnums.d.ts +4 -0
  229. package/lib/typescript/utils/bitEnums.d.ts.map +1 -0
  230. package/lib/typescript/utils/index.d.ts +2 -5
  231. package/lib/typescript/utils/index.d.ts.map +1 -1
  232. package/lib/typescript/web-core/AudioContext.d.ts +0 -3
  233. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  234. package/lib/typescript/web-core/BaseAudioContext.d.ts +0 -2
  235. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  236. package/lib/typescript/web-core/OfflineAudioContext.d.ts +0 -3
  237. package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
  238. package/package.json +4 -7
  239. package/src/api.ts +18 -45
  240. package/src/api.web.ts +0 -1
  241. package/src/core/AudioContext.ts +2 -3
  242. package/src/core/AudioRecorder.ts +211 -24
  243. package/src/core/BaseAudioContext.ts +60 -67
  244. package/src/core/OfflineAudioContext.ts +2 -2
  245. package/src/events/types.ts +18 -0
  246. package/src/interfaces.ts +52 -16
  247. package/src/types.ts +90 -9
  248. package/src/utils/bitEnums.ts +51 -0
  249. package/src/utils/index.ts +2 -22
  250. package/src/web-core/AudioContext.tsx +0 -25
  251. package/src/web-core/BaseAudioContext.tsx +0 -2
  252. package/src/web-core/OfflineAudioContext.tsx +0 -25
  253. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +0 -47
  254. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +0 -20
  255. package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +0 -210
  256. package/common/cpp/audioapi/core/effects/ConvolverNode.h +0 -55
  257. package/common/cpp/audioapi/dsp/Convolver.cpp +0 -213
  258. package/common/cpp/audioapi/dsp/Convolver.h +0 -45
  259. package/common/cpp/audioapi/libs/ffmpeg/relinking.md +0 -24
  260. package/common/cpp/audioapi/utils/AlignedAllocator.hpp +0 -50
  261. package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +0 -389
  262. package/common/cpp/test/src/biquad/BiquadFilterChromium.h +0 -64
  263. package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +0 -284
  264. package/common/cpp/test/src/biquad/BiquadFilterTest.h +0 -40
  265. package/lib/commonjs/core/ConvolverNode.js +0 -37
  266. package/lib/commonjs/core/ConvolverNode.js.map +0 -1
  267. package/lib/commonjs/web-core/ConvolverNode.js +0 -40
  268. package/lib/commonjs/web-core/ConvolverNode.js.map +0 -1
  269. package/lib/commonjs/web-core/ConvolverNodeOptions.js +0 -6
  270. package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +0 -1
  271. package/lib/module/core/ConvolverNode.js +0 -31
  272. package/lib/module/core/ConvolverNode.js.map +0 -1
  273. package/lib/module/web-core/ConvolverNode.js +0 -34
  274. package/lib/module/web-core/ConvolverNode.js.map +0 -1
  275. package/lib/module/web-core/ConvolverNodeOptions.js +0 -4
  276. package/lib/module/web-core/ConvolverNodeOptions.js.map +0 -1
  277. package/lib/typescript/core/ConvolverNode.d.ts +0 -12
  278. package/lib/typescript/core/ConvolverNode.d.ts.map +0 -1
  279. package/lib/typescript/web-core/ConvolverNode.d.ts +0 -11
  280. package/lib/typescript/web-core/ConvolverNode.d.ts.map +0 -1
  281. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +0 -6
  282. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +0 -1
  283. package/scripts/download-prebuilt-binaries.sh +0 -52
  284. package/scripts/rnaa_utils.rb +0 -8
  285. package/scripts/validate-worklets-version.js +0 -28
  286. package/src/core/ConvolverNode.ts +0 -35
  287. package/src/web-core/ConvolverNode.tsx +0 -43
  288. package/src/web-core/ConvolverNodeOptions.tsx +0 -6
@@ -1,5 +1,4 @@
1
1
  require "json"
2
- require_relative './scripts/rnaa_utils'
3
2
 
4
3
  package_json = JSON.parse(File.read(File.join(__dir__, "package.json")))
5
4
 
@@ -9,8 +8,6 @@ folly_flags = "-DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-
9
8
  fabric_flags = $new_arch_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''
10
9
  version_flag = "-DAUDIOAPI_VERSION=#{package_json['version']}"
11
10
 
12
- worklets_preprocessor_flag = check_if_worklets_enabled() ? '-DRN_AUDIO_API_ENABLE_WORKLETS=1' : ''
13
-
14
11
  Pod::Spec.new do |s|
15
12
  s.name = "RNAudioAPI"
16
13
  s.version = package_json["version"]
@@ -32,23 +29,15 @@ Pod::Spec.new do |s|
32
29
  sss.header_dir = "audioapi"
33
30
  sss.header_mappings_dir = "ios/audioapi"
34
31
  end
35
-
36
- ss.subspec "audioapi_dsp" do |sss|
37
- sss.source_files = "common/cpp/audioapi/dsp/**/*.{cpp}"
38
- sss.header_dir = "audioapi/dsp"
39
- sss.header_mappings_dir = "common/cpp/audioapi/dsp"
40
- sss.compiler_flags = "-O3"
41
- end
42
32
  end
43
33
 
44
34
  s.ios.frameworks = 'CoreFoundation', 'CoreAudio', 'AudioToolbox', 'Accelerate', 'MediaPlayer', 'AVFoundation'
45
35
 
46
36
  s.compiler_flags = "#{folly_flags}"
47
37
 
48
- s.prepare_command = <<-CMD
49
- chmod +x scripts/download-prebuilt-binaries.sh
50
- scripts/download-prebuilt-binaries.sh ios
51
- CMD
38
+ # s.prepare_command = <<-CMD TODO: re-add when we have prebuilt libs put somewhere public
39
+ # ruby -r './scripts/download-audioapi-libs.rb'
40
+ # CMD
52
41
 
53
42
  # Assumes Pods dir is nested under ios project dir
54
43
  ios_dir = File.join(Pod::Config.instance.project_pods_root, '..')
@@ -57,6 +46,8 @@ Pod::Spec.new do |s|
57
46
  external_dir_relative = "common/cpp/audioapi/external"
58
47
  lib_dir = "$(PROJECT_DIR)/#{rn_audio_dir_relative}/#{external_dir_relative}/$(PLATFORM_NAME)"
59
48
 
49
+ external_dir = File.join(__dir__, "common/cpp/audioapi/external")
50
+
60
51
  s.ios.vendored_frameworks = [
61
52
  'common/cpp/audioapi/external/libavcodec.xcframework',
62
53
  'common/cpp/audioapi/external/libavformat.xcframework',
@@ -77,8 +68,8 @@ s.pod_target_xcconfig = {
77
68
  $(PODS_TARGET_SRCROOT)/#{external_dir_relative}/include/vorbis
78
69
  $(PODS_TARGET_SRCROOT)/#{external_dir_relative}/ffmpeg_include
79
70
  ].join(" "),
80
- 'OTHER_CFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag} #{worklets_preprocessor_flag}",
81
- 'OTHER_CPLUSPLUSFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag} #{worklets_preprocessor_flag}",
71
+ 'OTHER_CFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}",
72
+ 'OTHER_CPLUSPLUSFLAGS' => "$(inherited) #{folly_flags} #{fabric_flags} #{version_flag}"
82
73
  }
83
74
 
84
75
  s.user_target_xcconfig = {
@@ -97,6 +88,10 @@ s.user_target_xcconfig = {
97
88
  $(inherited)
98
89
  $(PODS_ROOT)/Headers/Public/RNAudioAPI
99
90
  $(PODS_TARGET_SRCROOT)/common/cpp
91
+ #{external_dir}/include
92
+ #{external_dir}/include/opus
93
+ #{external_dir}/include/vorbis
94
+ #{external_dir}/ffmpeg_include
100
95
  ].join(' ')
101
96
  }
102
97
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
@@ -74,30 +74,6 @@ def resolveReactNativeWorkletsDirectory() {
74
74
  return null;
75
75
  }
76
76
 
77
- def validateWorkletsVersion() {
78
- def validationScript = file("${projectDir}/../scripts/validate-worklets-version.js")
79
- if (!validationScript.exists()) {
80
- logger.error("[AudioAPI] Worklets validation script not found at ${validationScript.absolutePath}")
81
- return false
82
- }
83
-
84
- try {
85
- def process = ["node", validationScript.absolutePath].execute()
86
- process.waitForProcessOutput(System.out, System.err)
87
- def exitCode = process.exitValue()
88
-
89
- if (exitCode == 0) {
90
- return true
91
- } else {
92
- logger.warn("[AudioAPI] Worklets version validation failed")
93
- return false
94
- }
95
- } catch (Exception e) {
96
- logger.error("[AudioAPI] Failed to validate worklets version: ${e.message}")
97
- return false
98
- }
99
- }
100
-
101
77
  def toPlatformFileString(String path) {
102
78
  if (Os.isFamily(Os.FAMILY_WINDOWS)) {
103
79
  path = path.replace(File.separatorChar, '/' as char)
@@ -116,7 +92,7 @@ static def supportsNamespace() {
116
92
 
117
93
  def reactNativeRootDir = resolveReactNativeDirectory()
118
94
  def reactNativeWorkletsRootDir = resolveReactNativeWorkletsDirectory()
119
- def isWorkletsAvailable = reactNativeWorkletsRootDir != null && validateWorkletsVersion()
95
+ def isWorkletsAvailable = reactNativeWorkletsRootDir != null
120
96
 
121
97
  def reactProperties = new Properties()
122
98
  file("$reactNativeRootDir/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
@@ -147,7 +123,7 @@ android {
147
123
  defaultConfig {
148
124
  minSdkVersion getExtOrIntegerDefault("minSdkVersion")
149
125
  targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
150
-
126
+
151
127
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
152
128
  buildConfigField "boolean", "RN_AUDIO_API_ENABLE_WORKLETS", "${isWorkletsAvailable}"
153
129
 
@@ -301,16 +277,10 @@ def assertMinimalReactNativeVersion = task assertMinimalReactNativeVersionTask {
301
277
  }
302
278
  }
303
279
 
304
- task downloadPrebuiltBinaries(type: Exec) {
305
- commandLine 'chmod', '+x', '../scripts/download-prebuilt-binaries.sh'
306
- commandLine 'bash', '../scripts/download-prebuilt-binaries.sh'
307
- args 'android'
308
- }
309
-
310
280
  // Make preBuild depend on the download task
311
281
  tasks.preBuild {
312
282
  dependsOn assertMinimalReactNativeVersion
313
- dependsOn downloadPrebuiltBinaries
283
+ // dependsOn downloadStaticPrebuiltLibraries TODO: re-add when we have prebuilt libs put somewhere public
314
284
  }
315
285
 
316
286
  task cleanCmakeCache() {
@@ -3,12 +3,6 @@ cmake_minimum_required(VERSION 3.12.0)
3
3
  file(GLOB_RECURSE ANDROID_CPP_SOURCES CONFIGURE_DEPENDS "${ANDROID_CPP_DIR}/audioapi/*.cpp")
4
4
  file(GLOB_RECURSE COMMON_CPP_SOURCES CONFIGURE_DEPENDS "${COMMON_CPP_DIR}/audioapi/*.cpp" "${COMMON_CPP_DIR}/audioapi/*.c")
5
5
 
6
- set_source_files_properties(
7
- ${COMMON_CPP_SOURCES}/dsp/*.cpp
8
- PROPERTIES
9
- COMPILE_FLAGS "-O3"
10
- )
11
-
12
6
  set(INCLUDE_DIR ${COMMON_CPP_DIR}/audioapi/external/include)
13
7
  set(FFMPEG_INCLUDE_DIR ${COMMON_CPP_DIR}/audioapi/external/ffmpeg_include)
14
8
  set(EXTERNAL_DIR ${COMMON_CPP_DIR}/audioapi/external)
@@ -51,7 +51,6 @@ void AudioAPIModule::registerNatives() {
51
51
  makeNativeMethod(
52
52
  "invokeHandlerWithEventNameAndEventBody",
53
53
  AudioAPIModule::invokeHandlerWithEventNameAndEventBody),
54
- makeNativeMethod("closeAllContexts", AudioAPIModule::closeAllContexts),
55
54
  });
56
55
  }
57
56
 
@@ -102,8 +101,4 @@ void AudioAPIModule::invokeHandlerWithEventNameAndEventBody(
102
101
  eventName->toStdString(), body);
103
102
  }
104
103
  }
105
-
106
- void AudioAPIModule::closeAllContexts() {
107
- AudioAPIModuleInstaller::closeAllContexts();
108
- }
109
104
  } // namespace audioapi
@@ -34,7 +34,6 @@ class AudioAPIModule : public jni::HybridClass<AudioAPIModule> {
34
34
 
35
35
  void injectJSIBindings();
36
36
  void invokeHandlerWithEventNameAndEventBody(jni::alias_ref<jni::JString> eventName, jni::alias_ref<jni::JMap<jstring, jobject>> eventBody);
37
- void closeAllContexts();
38
37
 
39
38
  private:
40
39
  friend HybridBase;
@@ -1,4 +1,9 @@
1
+ #include <android/log.h>
1
2
  #include <audioapi/android/core/AndroidAudioRecorder.h>
3
+ #include <audioapi/android/core/utils/AndroidFileWriterBackend.h>
4
+ #include <audioapi/android/core/utils/AndroidRecorderCallback.h>
5
+ #include <audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h>
6
+ #include <audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h>
2
7
  #include <audioapi/core/sources/RecorderAdapterNode.h>
3
8
  #include <audioapi/core/utils/Constants.h>
4
9
  #include <audioapi/events/AudioEventHandlerRegistry.h>
@@ -10,22 +15,22 @@
10
15
  namespace audioapi {
11
16
 
12
17
  AndroidAudioRecorder::AndroidAudioRecorder(
13
- float sampleRate,
14
- int bufferLength,
15
18
  const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry)
16
- : AudioRecorder(sampleRate, bufferLength, audioEventHandlerRegistry) {
19
+ : AudioRecorder(audioEventHandlerRegistry) {
17
20
  AudioStreamBuilder builder;
21
+
18
22
  builder.setSharingMode(SharingMode::Exclusive)
19
23
  ->setDirection(Direction::Input)
20
24
  ->setFormat(AudioFormat::Float)
21
25
  ->setFormatConversionAllowed(true)
22
26
  ->setPerformanceMode(PerformanceMode::None)
23
- ->setChannelCount(1)
24
27
  ->setSampleRateConversionQuality(SampleRateConversionQuality::Medium)
25
28
  ->setDataCallback(this)
26
- ->setSampleRate(static_cast<int>(sampleRate))
27
29
  ->openStream(mStream_);
28
30
 
31
+ streamSampleRate_ = mStream_->getSampleRate();
32
+ streamChannelCount_ = mStream_->getChannelCount();
33
+ streamMaxBufferSizeInFrames_ = mStream_->getBufferSizeInFrames();
29
34
  nativeAudioRecorder_ = jni::make_global(NativeAudioRecorder::create());
30
35
  }
31
36
 
@@ -39,53 +44,162 @@ AndroidAudioRecorder::~AndroidAudioRecorder() {
39
44
  }
40
45
  }
41
46
 
42
- void AndroidAudioRecorder::start() {
43
- if (isRunning_.load()) {
44
- return;
47
+ std::string AndroidAudioRecorder::start() {
48
+ if (isRecording()) {
49
+ return filePath_;
45
50
  }
46
51
 
47
- if (mStream_) {
48
- nativeAudioRecorder_->start();
49
- mStream_->requestStart();
52
+ if (!mStream_ || !nativeAudioRecorder_) {
53
+ __android_log_print(
54
+ ANDROID_LOG_ERROR,
55
+ "AndroidAudioRecorder",
56
+ "Audio stream is not initialized.\n");
57
+ return filePath_;
58
+ }
59
+
60
+ if (usesFileOutput()) {
61
+ filePath_ = fileWriter_->openFile(
62
+ streamSampleRate_, streamChannelCount_, streamMaxBufferSizeInFrames_);
63
+ }
64
+
65
+ if (usesCallback()) {
66
+ // TODO: create circular buffer and converter?
67
+ callback_->prepare(
68
+ streamSampleRate_, streamChannelCount_, streamMaxBufferSizeInFrames_);
69
+ }
70
+
71
+ if (isConnected()) {
72
+ // TODO: set adapter node properties?
73
+ }
74
+
75
+ nativeAudioRecorder_->start();
76
+ mStream_->requestStart();
77
+ state_.store(RecorderState::Recording);
78
+
79
+ return filePath_;
80
+ }
81
+
82
+ std::tuple<std::string, double, double> AndroidAudioRecorder::stop() {
83
+ std::string filePath = filePath_;
84
+ double outputFileSize = 0.0;
85
+ double outputDuration = 0.0;
86
+
87
+ if (!isRecording()) {
88
+ return {filePath_, 0.0, 0.0};
89
+ }
90
+
91
+ if (!mStream_ || !nativeAudioRecorder_) {
92
+ __android_log_print(
93
+ ANDROID_LOG_ERROR,
94
+ "AndroidAudioRecorder",
95
+ "Audio stream is not initialized.\n");
96
+ return {filePath_, 0.0, 0.0};
97
+ }
98
+
99
+ nativeAudioRecorder_->stop();
100
+ mStream_->requestStop();
101
+ state_.store(RecorderState::Idle);
102
+
103
+ if (usesFileOutput()) {
104
+ auto [size, duration] = fileWriter_->closeFile();
105
+ outputFileSize = size;
106
+ outputDuration = duration;
107
+ }
108
+
109
+ if (usesCallback()) {
110
+ callback_->cleanup();
50
111
  }
51
112
 
52
- isRunning_.store(true);
113
+ filePath_ = "";
114
+ return {filePath, outputFileSize, outputDuration};
53
115
  }
54
116
 
55
- void AndroidAudioRecorder::stop() {
56
- if (!isRunning_.load()) {
117
+ void AndroidAudioRecorder::enableFileOutput(
118
+ float sampleRate,
119
+ size_t channelCount,
120
+ size_t bitRate,
121
+ size_t iosFlags,
122
+ size_t androidFlags) {
123
+ uint8_t format = static_cast<uint8_t>(androidFlags & 0xF);
124
+
125
+ if (format == 1) {
126
+ fileWriter_ = std::make_shared<MiniAudioFileWriter>(
127
+ sampleRate, channelCount, bitRate, androidFlags);
128
+ } else {
129
+ fileWriter_ = std::make_shared<FFmpegAudioFileWriter>(
130
+ sampleRate, channelCount, bitRate, androidFlags);
131
+ }
132
+
133
+ fileOutputEnabled_.store(true);
134
+ }
135
+
136
+ void AndroidAudioRecorder::disableFileOutput() {
137
+ fileOutputEnabled_.store(false);
138
+ fileWriter_ = nullptr;
139
+ }
140
+
141
+ void AndroidAudioRecorder::pause() {
142
+ if (!isRecording()) {
57
143
  return;
58
144
  }
59
145
 
60
- isRunning_.store(false);
146
+ mStream_->pause(0);
147
+ state_.store(RecorderState::Paused);
148
+ }
61
149
 
62
- if (mStream_) {
63
- nativeAudioRecorder_->stop();
64
- mStream_->requestStop();
150
+ void AndroidAudioRecorder::resume() {
151
+ if (!isPaused()) {
152
+ return;
65
153
  }
66
154
 
67
- sendRemainingData();
155
+ mStream_->start(0);
156
+ state_.store(RecorderState::Recording);
157
+ }
158
+
159
+ void AndroidAudioRecorder::setOnAudioReadyCallback(
160
+ float sampleRate,
161
+ size_t bufferLength,
162
+ size_t channelCount,
163
+ uint64_t callbackId) {
164
+ callback_ = std::make_shared<AndroidRecorderCallback>(
165
+ audioEventHandlerRegistry_,
166
+ sampleRate,
167
+ bufferLength,
168
+ channelCount,
169
+ callbackId);
170
+ callbackOutputEnabled_.store(true);
171
+ }
172
+
173
+ void AndroidAudioRecorder::clearOnAudioReadyCallback() {
174
+ callbackOutputEnabled_.store(false);
175
+ callback_ = nullptr;
68
176
  }
69
177
 
70
178
  DataCallbackResult AndroidAudioRecorder::onAudioReady(
71
179
  oboe::AudioStream *oboeStream,
72
180
  void *audioData,
73
181
  int32_t numFrames) {
74
- if (isRunning_.load()) {
75
- auto *inputChannel = static_cast<float *>(audioData);
76
- writeToBuffers(inputChannel, numFrames);
182
+ if (isPaused()) {
183
+ return DataCallbackResult::Continue;
77
184
  }
78
185
 
79
- while (circularBuffer_->getNumberOfAvailableFrames() >= bufferLength_) {
80
- auto bus = std::make_shared<AudioBus>(bufferLength_, 1, sampleRate_);
81
- auto *outputChannel = bus->getChannel(0)->getData();
82
-
83
- circularBuffer_->pop_front(outputChannel, bufferLength_);
186
+ if (usesFileOutput()) {
187
+ fileWriter_->writeAudioData(audioData, numFrames);
188
+ }
84
189
 
85
- invokeOnAudioReadyCallback(bus, bufferLength_);
190
+ if (usesCallback()) {
191
+ callback_->receiveAudioData(audioData, numFrames);
86
192
  }
87
193
 
88
194
  return DataCallbackResult::Continue;
89
195
  }
90
196
 
197
+ double AndroidAudioRecorder::getCurrentDuration() const {
198
+ if (usesFileOutput()) {
199
+ return fileWriter_->getCurrentDuration();
200
+ }
201
+
202
+ return 0.0;
203
+ }
204
+
91
205
  } // namespace audioapi
@@ -5,6 +5,8 @@
5
5
  #include <oboe/Oboe.h>
6
6
  #include <functional>
7
7
  #include <memory>
8
+ #include <string>
9
+ #include <tuple>
8
10
 
9
11
  #include <audioapi/android/core/NativeAudioRecorder.hpp>
10
12
 
@@ -13,28 +15,53 @@ namespace audioapi {
13
15
  using namespace oboe;
14
16
 
15
17
  class AudioBus;
18
+ class CircularAudioArray;
19
+ class AndroidRecorderCallback;
20
+ class AndroidFileWriterBackend;
21
+ class AudioEventHandlerRegistry;
16
22
 
17
23
  class AndroidAudioRecorder : public AudioStreamDataCallback, public AudioRecorder {
18
24
  public:
19
- AndroidAudioRecorder(float sampleRate,
20
- int bufferLength,
21
- const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry
22
- );
25
+ explicit AndroidAudioRecorder(const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry);
26
+ ~AndroidAudioRecorder() override;
23
27
 
24
- ~AndroidAudioRecorder() override;
28
+ std::string start() override;
29
+ std::tuple<std::string, double, double> stop() override;
25
30
 
26
- void start() override;
27
- void stop() override;
31
+ void enableFileOutput(
32
+ float sampleRate,
33
+ size_t channelCount,
34
+ size_t bitRate,
35
+ size_t iosFlags,
36
+ size_t androidFlags) override;
37
+ void disableFileOutput() override;
28
38
 
29
- DataCallbackResult onAudioReady(
30
- AudioStream *oboeStream,
31
- void *audioData,
32
- int32_t numFrames) override;
39
+ void pause() override;
40
+ void resume() override;
41
+
42
+ void setOnAudioReadyCallback(float sampleRate, size_t bufferLength, size_t channelCount, uint64_t callbackId)
43
+ override;
44
+ void clearOnAudioReadyCallback() override;
45
+
46
+ double getCurrentDuration() const override;
47
+
48
+ DataCallbackResult onAudioReady(
49
+ AudioStream *oboeStream,
50
+ void *audioData,
51
+ int32_t numFrames) override;
33
52
 
34
53
  private:
35
- std::shared_ptr<AudioStream> mStream_;
54
+ std::string filePath_;
55
+ std::shared_ptr<AudioStream> mStream_;
56
+
57
+ std::shared_ptr<AndroidFileWriterBackend> fileWriter_;
58
+ std::shared_ptr<AndroidRecorderCallback> callback_;
59
+
60
+ int32_t streamSampleRate_;
61
+ int32_t streamChannelCount_;
62
+ int32_t streamMaxBufferSizeInFrames_;
36
63
 
37
- facebook::jni::global_ref<NativeAudioRecorder> nativeAudioRecorder_;
64
+ facebook::jni::global_ref<NativeAudioRecorder> nativeAudioRecorder_;
38
65
  };
39
66
 
40
67
  } // namespace audioapi
@@ -4,7 +4,6 @@
4
4
  #include <audioapi/core/utils/Constants.h>
5
5
  #include <audioapi/utils/AudioArray.h>
6
6
  #include <audioapi/utils/AudioBus.h>
7
- #include <jni.h>
8
7
 
9
8
  namespace audioapi {
10
9
 
@@ -50,8 +49,7 @@ bool AudioPlayer::openAudioStream() {
50
49
 
51
50
  bool AudioPlayer::start() {
52
51
  if (mStream_) {
53
- jni::ThreadScope::WithClassLoader(
54
- [this]() { nativeAudioPlayer_->start(); });
52
+ nativeAudioPlayer_->start();
55
53
  auto result = mStream_->requestStart();
56
54
  return result == oboe::Result::OK;
57
55
  }
@@ -61,7 +59,7 @@ bool AudioPlayer::start() {
61
59
 
62
60
  void AudioPlayer::stop() {
63
61
  if (mStream_) {
64
- jni::ThreadScope::WithClassLoader([this]() { nativeAudioPlayer_->stop(); });
62
+ nativeAudioPlayer_->stop();
65
63
  mStream_->requestStop();
66
64
  }
67
65
  }
@@ -22,15 +22,15 @@ class NativeAudioRecorder : public jni::JavaClass<NativeAudioRecorder> {
22
22
  return newInstance();
23
23
  }
24
24
 
25
- void start() {
26
- static const auto method = javaClassStatic()->getMethod<void()>("start");
27
- method(self());
28
- }
29
-
30
- void stop() {
31
- static const auto method = javaClassStatic()->getMethod<void()>("stop");
32
- method(self());
33
- }
25
+ void start() {
26
+ static const auto method = javaClassStatic()->getMethod<void()>("start");
27
+ method(self());
28
+ }
29
+
30
+ void stop() {
31
+ static const auto method = javaClassStatic()->getMethod<void()>("stop");
32
+ method(self());
33
+ }
34
34
  };
35
35
 
36
36
  } // namespace audioapi
@@ -0,0 +1,37 @@
1
+ #pragma once
2
+
3
+ #include <tuple>
4
+ #include <string>
5
+ #include <memory>
6
+
7
+ namespace audioapi {
8
+
9
+ class AndroidFileWriterBackend {
10
+ public:
11
+ AndroidFileWriterBackend(
12
+ float sampleRate,
13
+ size_t channelCount,
14
+ size_t bitRate,
15
+ size_t androidFlags) {}
16
+
17
+ virtual ~AndroidFileWriterBackend() = default;
18
+
19
+ virtual std::string openFile(int32_t streamSampleRate, int32_t streamChannelCount, int32_t streamMaxBufferSize) = 0;
20
+ virtual std::tuple<double, double> closeFile() = 0;
21
+
22
+ virtual bool writeAudioData(void *data, int numFrames) = 0;
23
+
24
+ std::string getFilePath() const { return filePath_; }
25
+
26
+ double getCurrentDuration() const { return static_cast<double>(framesWritten_.load()) / streamSampleRate_; }
27
+
28
+ protected:
29
+ std::string filePath_{""};
30
+ std::atomic<size_t> framesWritten_{0};
31
+
32
+ int32_t streamSampleRate_{0};
33
+ int32_t streamChannelCount_{0};
34
+ int32_t streamMaxBufferSize_{0};
35
+ };
36
+
37
+ } // namespace audioapi