react-native-audio-api 0.11.0-alpha.1 → 0.11.0-nightly-9f40b78-20251108

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 (362) hide show
  1. package/README.md +13 -11
  2. package/RNAudioAPI.podspec +20 -15
  3. package/android/build.gradle +33 -3
  4. package/android/src/main/cpp/audioapi/CMakeLists.txt +6 -3
  5. package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +5 -0
  6. package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +1 -0
  7. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +30 -142
  8. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +13 -40
  9. package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +4 -2
  10. package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
  11. package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +6 -0
  12. package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +31 -3
  13. package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +21 -9
  14. package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +27 -6
  15. package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +11 -0
  16. package/android/src/oldarch/NativeAudioAPIModuleSpec.java +4 -0
  17. package/common/cpp/audioapi/AudioAPIModuleInstaller.h +30 -2
  18. package/common/cpp/audioapi/HostObjects/AudioContextHostObject.cpp +12 -17
  19. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +18 -0
  20. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +1 -0
  21. package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +26 -30
  22. package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
  23. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +47 -0
  24. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +20 -0
  25. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +18 -97
  26. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +6 -18
  27. package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +1 -1
  28. package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +1 -1
  29. package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +1 -1
  30. package/common/cpp/audioapi/HostObjects/utils/AudioStretcherHostObject.cpp +15 -26
  31. package/common/cpp/audioapi/core/AudioNode.h +3 -2
  32. package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
  33. package/common/cpp/audioapi/core/BaseAudioContext.cpp +10 -0
  34. package/common/cpp/audioapi/core/BaseAudioContext.h +2 -0
  35. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +69 -32
  36. package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +37 -1
  37. package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +210 -0
  38. package/common/cpp/audioapi/core/effects/ConvolverNode.h +55 -0
  39. package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +82 -36
  40. package/common/cpp/audioapi/core/inputs/AudioRecorder.h +31 -52
  41. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +14 -17
  42. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +0 -1
  43. package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +7 -0
  44. package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +1 -0
  45. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +8 -14
  46. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +0 -1
  47. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +14 -19
  48. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +3 -3
  49. package/common/cpp/audioapi/core/sources/StreamerNode.cpp +64 -64
  50. package/common/cpp/audioapi/core/sources/StreamerNode.h +38 -10
  51. package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +5 -0
  52. package/common/cpp/audioapi/core/utils/Constants.h +2 -1
  53. package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +12 -8
  54. package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +3 -3
  55. package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +1 -1
  56. package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
  57. package/common/cpp/audioapi/dsp/Convolver.cpp +213 -0
  58. package/common/cpp/audioapi/dsp/Convolver.h +45 -0
  59. package/common/cpp/audioapi/dsp/FFT.cpp +0 -26
  60. package/common/cpp/audioapi/dsp/FFT.h +26 -2
  61. package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +1 -1
  62. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +4 -4
  63. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
  64. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
  65. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +3 -1
  66. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +2 -2
  67. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/defs.h +3 -0
  68. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/packet.h +1 -1
  69. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/smpte_436m.h +254 -0
  70. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/version.h +1 -1
  71. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +6 -6
  72. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version.h +2 -2
  73. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version_major.h +2 -0
  74. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avassert.h +5 -2
  75. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
  76. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/channel_layout.h +2 -2
  77. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/csp.h +1 -1
  78. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/dict.h +1 -1
  79. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ffversion.h +1 -1
  80. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/film_grain_params.h +1 -1
  81. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/frame.h +1 -1
  82. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hdr_dynamic_vivid_metadata.h +3 -3
  83. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext.h +1 -1
  84. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_opencl.h +1 -1
  85. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_qsv.h +0 -1
  86. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vulkan.h +1 -1
  87. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/iamf.h +2 -2
  88. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/lfg.h +2 -2
  89. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/log.h +2 -2
  90. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mathematics.h +1 -1
  91. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/opt.h +4 -4
  92. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rational.h +1 -1
  93. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rc4.h +1 -1
  94. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/refstruct.h +1 -1
  95. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/spherical.h +6 -0
  96. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tdrdi.h +1 -1
  97. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tx.h +1 -1
  98. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/version.h +3 -3
  99. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/video_hint.h +1 -1
  100. package/common/cpp/audioapi/external/ffmpeg_include/libswresample/swresample.h +1 -1
  101. package/common/cpp/audioapi/external/ffmpeg_include/libswresample/version.h +1 -1
  102. package/common/cpp/audioapi/jsi/JsiPromise.cpp +33 -56
  103. package/common/cpp/audioapi/jsi/JsiPromise.h +41 -11
  104. package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +2 -3
  105. package/common/cpp/audioapi/libs/ffmpeg/relinking.md +24 -0
  106. package/common/cpp/audioapi/utils/AlignedAllocator.hpp +50 -0
  107. package/common/cpp/audioapi/utils/AudioBus.cpp +28 -0
  108. package/common/cpp/audioapi/utils/AudioBus.h +3 -0
  109. package/common/cpp/audioapi/utils/ThreadPool.hpp +59 -1
  110. package/common/cpp/test/CMakeLists.txt +19 -14
  111. package/common/cpp/test/src/AudioParamTest.cpp +1 -1
  112. package/common/cpp/test/src/AudioScheduledSourceTest.cpp +134 -0
  113. package/common/cpp/test/src/ConstantSourceTest.cpp +1 -1
  114. package/common/cpp/test/src/GainTest.cpp +1 -1
  115. package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +4 -4
  116. package/common/cpp/test/src/OscillatorTest.cpp +1 -1
  117. package/common/cpp/test/src/StereoPannerTest.cpp +1 -1
  118. package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +389 -0
  119. package/common/cpp/test/src/biquad/BiquadFilterChromium.h +64 -0
  120. package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +284 -0
  121. package/common/cpp/test/src/biquad/BiquadFilterTest.h +40 -0
  122. package/ios/audioapi/ios/AudioAPIModule.h +2 -1
  123. package/ios/audioapi/ios/AudioAPIModule.mm +34 -9
  124. package/ios/audioapi/ios/core/IOSAudioRecorder.h +10 -28
  125. package/ios/audioapi/ios/core/IOSAudioRecorder.mm +30 -117
  126. package/ios/audioapi/ios/core/NativeAudioRecorder.h +9 -4
  127. package/ios/audioapi/ios/core/NativeAudioRecorder.m +71 -29
  128. package/ios/audioapi/ios/core/utils/AudioDecoder.mm +0 -1
  129. package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
  130. package/ios/audioapi/ios/system/AudioSessionManager.h +2 -0
  131. package/ios/audioapi/ios/system/AudioSessionManager.mm +24 -0
  132. package/ios/audioapi/ios/system/LockScreenManager.h +0 -1
  133. package/ios/audioapi/ios/system/LockScreenManager.mm +6 -19
  134. package/lib/commonjs/api.js +141 -76
  135. package/lib/commonjs/api.js.map +1 -1
  136. package/lib/commonjs/api.web.js +8 -0
  137. package/lib/commonjs/api.web.js.map +1 -1
  138. package/lib/commonjs/core/AudioContext.js +1 -1
  139. package/lib/commonjs/core/AudioContext.js.map +1 -1
  140. package/lib/commonjs/core/AudioRecorder.js +13 -171
  141. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  142. package/lib/commonjs/core/BaseAudioContext.js +28 -25
  143. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  144. package/lib/commonjs/core/ConvolverNode.js +37 -0
  145. package/lib/commonjs/core/ConvolverNode.js.map +1 -0
  146. package/lib/commonjs/core/OfflineAudioContext.js +1 -1
  147. package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
  148. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  149. package/lib/commonjs/system/AudioManager.js +3 -0
  150. package/lib/commonjs/system/AudioManager.js.map +1 -1
  151. package/lib/commonjs/types.js +0 -46
  152. package/lib/commonjs/types.js.map +1 -1
  153. package/lib/commonjs/utils/index.js +19 -21
  154. package/lib/commonjs/utils/index.js.map +1 -1
  155. package/lib/commonjs/web-core/AudioContext.js +12 -0
  156. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  157. package/lib/commonjs/web-core/ConvolverNode.js +40 -0
  158. package/lib/commonjs/web-core/ConvolverNode.js.map +1 -0
  159. package/lib/commonjs/web-core/ConvolverNodeOptions.js +6 -0
  160. package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +1 -0
  161. package/lib/commonjs/web-core/OfflineAudioContext.js +12 -0
  162. package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
  163. package/lib/module/api.js +16 -15
  164. package/lib/module/api.js.map +1 -1
  165. package/lib/module/api.web.js +1 -0
  166. package/lib/module/api.web.js.map +1 -1
  167. package/lib/module/core/AudioContext.js +2 -2
  168. package/lib/module/core/AudioContext.js.map +1 -1
  169. package/lib/module/core/AudioRecorder.js +13 -171
  170. package/lib/module/core/AudioRecorder.js.map +1 -1
  171. package/lib/module/core/BaseAudioContext.js +29 -26
  172. package/lib/module/core/BaseAudioContext.js.map +1 -1
  173. package/lib/module/core/ConvolverNode.js +31 -0
  174. package/lib/module/core/ConvolverNode.js.map +1 -0
  175. package/lib/module/core/OfflineAudioContext.js +2 -2
  176. package/lib/module/core/OfflineAudioContext.js.map +1 -1
  177. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  178. package/lib/module/system/AudioManager.js +3 -0
  179. package/lib/module/system/AudioManager.js.map +1 -1
  180. package/lib/module/types.js +1 -45
  181. package/lib/module/types.js.map +1 -1
  182. package/lib/module/utils/index.js +15 -2
  183. package/lib/module/utils/index.js.map +1 -1
  184. package/lib/module/web-core/AudioContext.js +12 -0
  185. package/lib/module/web-core/AudioContext.js.map +1 -1
  186. package/lib/module/web-core/ConvolverNode.js +34 -0
  187. package/lib/module/web-core/ConvolverNode.js.map +1 -0
  188. package/lib/module/web-core/ConvolverNodeOptions.js +4 -0
  189. package/lib/module/web-core/ConvolverNodeOptions.js.map +1 -0
  190. package/lib/module/web-core/OfflineAudioContext.js +12 -0
  191. package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
  192. package/lib/typescript/api.d.ts +19 -17
  193. package/lib/typescript/api.d.ts.map +1 -1
  194. package/lib/typescript/api.web.d.ts +1 -0
  195. package/lib/typescript/api.web.d.ts.map +1 -1
  196. package/lib/typescript/core/AudioContext.d.ts.map +1 -1
  197. package/lib/typescript/core/AudioRecorder.d.ts +7 -62
  198. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  199. package/lib/typescript/core/BaseAudioContext.d.ts +3 -1
  200. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  201. package/lib/typescript/core/ConvolverNode.d.ts +12 -0
  202. package/lib/typescript/core/ConvolverNode.d.ts.map +1 -0
  203. package/lib/typescript/events/types.d.ts +0 -16
  204. package/lib/typescript/events/types.d.ts.map +1 -1
  205. package/lib/typescript/interfaces.d.ts +9 -42
  206. package/lib/typescript/interfaces.d.ts.map +1 -1
  207. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -0
  208. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  209. package/lib/typescript/system/AudioManager.d.ts +1 -0
  210. package/lib/typescript/system/AudioManager.d.ts.map +1 -1
  211. package/lib/typescript/types.d.ts +8 -79
  212. package/lib/typescript/types.d.ts.map +1 -1
  213. package/lib/typescript/utils/index.d.ts +5 -2
  214. package/lib/typescript/utils/index.d.ts.map +1 -1
  215. package/lib/typescript/web-core/AudioContext.d.ts +3 -0
  216. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  217. package/lib/typescript/web-core/BaseAudioContext.d.ts +2 -0
  218. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  219. package/lib/typescript/web-core/ConvolverNode.d.ts +11 -0
  220. package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -0
  221. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +6 -0
  222. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +1 -0
  223. package/lib/typescript/web-core/OfflineAudioContext.d.ts +3 -0
  224. package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
  225. package/package.json +14 -5
  226. package/scripts/download-prebuilt-binaries.sh +61 -0
  227. package/scripts/rnaa_utils.rb +8 -0
  228. package/scripts/validate-worklets-version.js +28 -0
  229. package/src/api.ts +45 -18
  230. package/src/api.web.ts +1 -0
  231. package/src/core/AudioContext.ts +3 -2
  232. package/src/core/AudioRecorder.ts +24 -211
  233. package/src/core/BaseAudioContext.ts +67 -60
  234. package/src/core/ConvolverNode.ts +35 -0
  235. package/src/core/OfflineAudioContext.ts +2 -2
  236. package/src/events/types.ts +0 -18
  237. package/src/interfaces.ts +16 -52
  238. package/src/specs/NativeAudioAPIModule.ts +1 -0
  239. package/src/system/AudioManager.ts +4 -0
  240. package/src/types.ts +9 -90
  241. package/src/utils/index.ts +22 -2
  242. package/src/web-core/AudioContext.tsx +25 -0
  243. package/src/web-core/BaseAudioContext.tsx +2 -0
  244. package/src/web-core/ConvolverNode.tsx +43 -0
  245. package/src/web-core/ConvolverNodeOptions.tsx +6 -0
  246. package/src/web-core/OfflineAudioContext.tsx +25 -0
  247. package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +0 -37
  248. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +0 -187
  249. package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +0 -57
  250. package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +0 -34
  251. package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +0 -133
  252. package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +0 -3
  253. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +0 -154
  254. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +0 -41
  255. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +0 -429
  256. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +0 -113
  257. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +0 -47
  258. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +0 -28
  259. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +0 -269
  260. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +0 -47
  261. package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +0 -31
  262. package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +0 -18
  263. package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
  264. package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
  265. package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
  266. package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
  267. package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
  268. package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
  269. package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
  270. package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
  271. package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
  272. package/android/src/main/jniLibs/x86/libavformat.so +0 -0
  273. package/android/src/main/jniLibs/x86/libavutil.so +0 -0
  274. package/android/src/main/jniLibs/x86/libswresample.so +0 -0
  275. package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
  276. package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
  277. package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
  278. package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
  279. package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
  280. package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
  281. package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
  282. package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
  283. package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
  284. package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
  285. package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
  286. package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
  287. package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
  288. package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
  289. package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
  290. package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
  291. package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
  292. package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
  293. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
  294. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
  295. package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
  296. package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
  297. package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
  298. package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
  299. package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
  300. package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
  301. package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
  302. package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
  303. package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
  304. package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
  305. package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
  306. package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
  307. package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
  308. package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
  309. package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
  310. package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
  311. package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +0 -44
  312. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +0 -1
  313. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
  314. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +0 -1
  315. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
  316. package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +0 -44
  317. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +0 -1
  318. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
  319. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +0 -1
  320. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
  321. package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +0 -44
  322. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +0 -1
  323. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
  324. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +0 -1
  325. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
  326. package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +0 -44
  327. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +0 -1
  328. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
  329. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +0 -1
  330. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
  331. package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
  332. package/common/cpp/audioapi/external/x86/libogg.a +0 -0
  333. package/common/cpp/audioapi/external/x86/libopus.a +0 -0
  334. package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
  335. package/common/cpp/audioapi/external/x86/libssl.a +0 -0
  336. package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
  337. package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
  338. package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
  339. package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
  340. package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
  341. package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
  342. package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
  343. package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
  344. package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
  345. package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
  346. package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
  347. package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +0 -32
  348. package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +0 -111
  349. package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +0 -391
  350. package/ios/audioapi/ios/core/IOSAudioFileOptions.h +0 -36
  351. package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +0 -140
  352. package/ios/audioapi/ios/core/IOSAudioFileWriter.h +0 -51
  353. package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +0 -223
  354. package/ios/audioapi/ios/core/IOSRecorderCallback.h +0 -57
  355. package/ios/audioapi/ios/core/IOSRecorderCallback.mm +0 -189
  356. package/lib/commonjs/utils/bitEnums.js +0 -33
  357. package/lib/commonjs/utils/bitEnums.js.map +0 -1
  358. package/lib/module/utils/bitEnums.js +0 -27
  359. package/lib/module/utils/bitEnums.js.map +0 -1
  360. package/lib/typescript/utils/bitEnums.d.ts +0 -4
  361. package/lib/typescript/utils/bitEnums.d.ts.map +0 -1
  362. package/src/utils/bitEnums.ts +0 -51
@@ -14,6 +14,7 @@ AudioScheduledSourceNode::AudioScheduledSourceNode(BaseAudioContext *context)
14
14
  stopTime_(-1.0),
15
15
  playbackState_(PlaybackState::UNSCHEDULED) {
16
16
  numberOfInputs_ = 0;
17
+ audioEventHandlerRegistry_ = context_->audioEventHandlerRegistry_;
17
18
  }
18
19
 
19
20
  void AudioScheduledSourceNode::start(double when) {
@@ -45,19 +46,13 @@ bool AudioScheduledSourceNode::isStopScheduled() {
45
46
  return playbackState_ == PlaybackState::STOP_SCHEDULED;
46
47
  }
47
48
 
48
- void AudioScheduledSourceNode::clearOnEndedCallback() {
49
- if (onEndedCallbackId_ == 0 || context_ == nullptr ||
50
- context_->audioEventHandlerRegistry_ == nullptr) {
51
- return;
52
- }
53
-
54
- context_->audioEventHandlerRegistry_->unregisterHandler(
55
- "ended", onEndedCallbackId_);
56
- onEndedCallbackId_ = 0;
57
- }
58
-
59
49
  void AudioScheduledSourceNode::setOnEndedCallbackId(const uint64_t callbackId) {
60
- onEndedCallbackId_ = callbackId;
50
+ auto oldCallbackId =
51
+ onEndedCallbackId_.exchange(callbackId, std::memory_order_acq_rel);
52
+
53
+ if (oldCallbackId != 0) {
54
+ audioEventHandlerRegistry_->unregisterHandler("ended", oldCallbackId);
55
+ }
61
56
  }
62
57
 
63
58
  void AudioScheduledSourceNode::updatePlaybackInfo(
@@ -76,14 +71,13 @@ void AudioScheduledSourceNode::updatePlaybackInfo(
76
71
  auto sampleRate = context_->getSampleRate();
77
72
 
78
73
  size_t firstFrame = context_->getCurrentSampleFrame();
79
- size_t lastFrame = firstFrame + framesToProcess;
74
+ size_t lastFrame = firstFrame + framesToProcess - 1;
80
75
 
81
76
  size_t startFrame =
82
77
  std::max(dsp::timeToSampleFrame(startTime_, sampleRate), firstFrame);
83
78
  size_t stopFrame = stopTime_ == -1.0
84
79
  ? std::numeric_limits<size_t>::max()
85
80
  : dsp::timeToSampleFrame(stopTime_, sampleRate);
86
-
87
81
  if (isFinished()) {
88
82
  startOffset = 0;
89
83
  nonSilentFramesToProcess = 0;
@@ -105,7 +99,7 @@ void AudioScheduledSourceNode::updatePlaybackInfo(
105
99
  ? std::max(startFrame, firstFrame) - firstFrame
106
100
  : 0;
107
101
  nonSilentFramesToProcess =
108
- std::max(std::min(lastFrame, stopFrame), startFrame) - startFrame;
102
+ std::max(std::min(lastFrame, stopFrame) + 1, startFrame) - startFrame;
109
103
 
110
104
  assert(startOffset <= framesToProcess);
111
105
  assert(nonSilentFramesToProcess <= framesToProcess);
@@ -124,7 +118,7 @@ void AudioScheduledSourceNode::updatePlaybackInfo(
124
118
 
125
119
  // stop will happen in this render quantum
126
120
  // zero remaining frames after stop frame
127
- if (stopFrame < lastFrame && stopFrame >= firstFrame) {
121
+ if (stopFrame <= lastFrame && stopFrame >= firstFrame) {
128
122
  playbackState_ = PlaybackState::STOP_SCHEDULED;
129
123
  startOffset = 0;
130
124
  nonSilentFramesToProcess = stopFrame - firstFrame;
@@ -160,9 +154,10 @@ void AudioScheduledSourceNode::updatePlaybackInfo(
160
154
  void AudioScheduledSourceNode::disable() {
161
155
  AudioNode::disable();
162
156
 
163
- if (context_->audioEventHandlerRegistry_ != nullptr) {
164
- context_->audioEventHandlerRegistry_->invokeHandlerWithEventBody(
165
- "ended", onEndedCallbackId_, {});
157
+ auto onEndedCallbackId = onEndedCallbackId_.load(std::memory_order_acquire);
158
+ if (onEndedCallbackId != 0) {
159
+ audioEventHandlerRegistry_->invokeHandlerWithEventBody(
160
+ "ended", onEndedCallbackId, {});
166
161
  }
167
162
  }
168
163
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  namespace audioapi {
18
18
 
19
- class AudioEventHandlerRegistry;
19
+ class IAudioEventHandlerRegistry;
20
20
 
21
21
  class AudioScheduledSourceNode : public AudioNode {
22
22
  public:
@@ -28,7 +28,7 @@ class AudioScheduledSourceNode : public AudioNode {
28
28
  enum class PlaybackState { UNSCHEDULED, SCHEDULED, PLAYING, STOP_SCHEDULED, FINISHED };
29
29
  explicit AudioScheduledSourceNode(BaseAudioContext *context);
30
30
 
31
- void start(double when);
31
+ virtual void start(double when);
32
32
  virtual void stop(double when);
33
33
 
34
34
  bool isUnscheduled();
@@ -37,7 +37,6 @@ class AudioScheduledSourceNode : public AudioNode {
37
37
  bool isFinished();
38
38
  bool isStopScheduled();
39
39
 
40
- void clearOnEndedCallback();
41
40
  void setOnEndedCallbackId(uint64_t callbackId);
42
41
 
43
42
  void disable() override;
@@ -49,6 +48,7 @@ class AudioScheduledSourceNode : public AudioNode {
49
48
  PlaybackState playbackState_;
50
49
 
51
50
  std::atomic<uint64_t> onEndedCallbackId_ = 0;
51
+ std::shared_ptr<IAudioEventHandlerRegistry> audioEventHandlerRegistry_;
52
52
 
53
53
  void updatePlaybackInfo(
54
54
  const std::shared_ptr<AudioBus>& processingBus,
@@ -25,14 +25,12 @@ StreamerNode::StreamerNode(BaseAudioContext *context)
25
25
  codecpar_(nullptr),
26
26
  pkt_(nullptr),
27
27
  frame_(nullptr),
28
- pendingFrame_(nullptr),
29
- bufferedBus_(nullptr),
30
- bufferedBusIndex_(0),
31
- maxBufferSize_(0),
32
- audio_stream_index_(-1),
33
28
  swrCtx_(nullptr),
34
29
  resampledData_(nullptr),
35
- maxResampledSamples_(0) {}
30
+ bufferedBus_(nullptr),
31
+ audio_stream_index_(-1),
32
+ maxResampledSamples_(0),
33
+ processedSamples_(0) {}
36
34
 
37
35
  StreamerNode::~StreamerNode() {
38
36
  cleanup();
@@ -66,26 +64,22 @@ bool StreamerNode::initialize(const std::string &input_url) {
66
64
  return false;
67
65
  }
68
66
 
69
- maxBufferSize_ = BUFFER_LENGTH_SECONDS * codecCtx_->sample_rate;
70
- // If decoding is faster than playing, we buffer few seconds of audio
71
- bufferedBus_ = std::make_shared<AudioBus>(
72
- maxBufferSize_, codecpar_->ch_layout.nb_channels, codecCtx_->sample_rate);
73
-
74
67
  channelCount_ = codecpar_->ch_layout.nb_channels;
75
68
  audioBus_ = std::make_shared<AudioBus>(
76
69
  RENDER_QUANTUM_SIZE, channelCount_, context_->getSampleRate());
77
70
 
71
+ auto [sender, receiver] = channels::spsc::channel<
72
+ StreamingData,
73
+ channels::spsc::OverflowStrategy::WAIT_ON_FULL,
74
+ channels::spsc::WaitStrategy::ATOMIC_WAIT>(CHANNEL_CAPACITY);
75
+ sender_ = std::move(sender);
76
+ receiver_ = std::move(receiver);
77
+
78
78
  streamingThread_ = std::thread(&StreamerNode::streamAudio, this);
79
- streamFlag.store(true);
80
79
  isInitialized_ = true;
81
80
  return true;
82
81
  }
83
82
 
84
- void StreamerNode::stop(double when) {
85
- AudioScheduledSourceNode::stop(when);
86
- streamFlag.store(false);
87
- }
88
-
89
83
  bool StreamerNode::setupResampler() {
90
84
  // Allocate resampler context
91
85
  swrCtx_ = swr_alloc();
@@ -122,30 +116,27 @@ bool StreamerNode::setupResampler() {
122
116
  }
123
117
 
124
118
  void StreamerNode::streamAudio() {
125
- while (streamFlag.load()) {
126
- if (pendingFrame_ != nullptr) {
127
- if (!processFrameWithResampler(pendingFrame_)) {
119
+ while (!isNodeFinished_.load(std::memory_order_acquire)) {
120
+ if (av_read_frame(fmtCtx_, pkt_) < 0) {
121
+ return;
122
+ }
123
+ if (pkt_->stream_index == audio_stream_index_) {
124
+ if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
128
125
  return;
129
126
  }
130
- } else {
131
- if (av_read_frame(fmtCtx_, pkt_) < 0) {
127
+ if (avcodec_receive_frame(codecCtx_, frame_) != 0) {
132
128
  return;
133
129
  }
134
- if (pkt_->stream_index == audio_stream_index_) {
135
- if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
136
- return;
137
- }
138
- if (avcodec_receive_frame(codecCtx_, frame_) != 0) {
139
- return;
140
- }
141
- if (!processFrameWithResampler(frame_)) {
142
- return;
143
- }
130
+ if (!processFrameWithResampler(frame_)) {
131
+ return;
144
132
  }
145
- av_packet_unref(pkt_);
146
133
  }
147
- std::this_thread::sleep_for(std::chrono::milliseconds(10));
134
+ av_packet_unref(pkt_);
148
135
  }
136
+ StreamingData dummy;
137
+ while (receiver_.try_receive(dummy) ==
138
+ channels::spsc::ResponseStatus::SUCCESS)
139
+ ; // clear the receiver
149
140
  }
150
141
 
151
142
  std::shared_ptr<AudioBus> StreamerNode::processNode(
@@ -154,34 +145,44 @@ std::shared_ptr<AudioBus> StreamerNode::processNode(
154
145
  size_t startOffset = 0;
155
146
  size_t offsetLength = 0;
156
147
  updatePlaybackInfo(processingBus, framesToProcess, startOffset, offsetLength);
148
+ isNodeFinished_.store(isFinished(), std::memory_order_release);
157
149
 
158
150
  if (!isPlaying() && !isStopScheduled()) {
159
151
  processingBus->zero();
160
152
  return processingBus;
161
153
  }
162
154
 
163
- // If we have enough buffered data, copy to output bus
164
- if (bufferedBusIndex_ >= framesToProcess) {
165
- Locker locker(mutex_);
155
+ int bufferRemaining = bufferedBusSize_ - processedSamples_;
156
+ int alreadyProcessed = 0;
157
+ if (bufferRemaining < framesToProcess) {
158
+ if (bufferedBus_ != nullptr) {
159
+ for (int ch = 0; ch < processingBus->getNumberOfChannels(); ch++) {
160
+ memcpy(
161
+ processingBus->getChannel(ch)->getData(),
162
+ bufferedBus_->getChannel(ch)->getData() + processedSamples_,
163
+ bufferRemaining * sizeof(float));
164
+ }
165
+ framesToProcess -= bufferRemaining;
166
+ alreadyProcessed += bufferRemaining;
167
+ }
168
+ StreamingData data;
169
+ auto res = receiver_.try_receive(data);
170
+ if (res == channels::spsc::ResponseStatus::SUCCESS) {
171
+ bufferedBus_ = std::make_shared<AudioBus>(std::move(data.bus));
172
+ bufferedBusSize_ = data.size;
173
+ processedSamples_ = 0;
174
+ } else {
175
+ bufferedBus_ = nullptr;
176
+ }
177
+ }
178
+ if (bufferedBus_ != nullptr) {
166
179
  for (int ch = 0; ch < processingBus->getNumberOfChannels(); ch++) {
167
180
  memcpy(
168
- processingBus->getChannel(ch)->getData(),
169
- bufferedBus_->getChannel(ch)->getData(),
170
- offsetLength * sizeof(float));
171
-
172
- memmove(
173
- bufferedBus_->getChannel(ch)->getData(),
174
- bufferedBus_->getChannel(ch)->getData() + offsetLength,
175
- (maxBufferSize_ - offsetLength) * sizeof(float));
181
+ processingBus->getChannel(ch)->getData() + alreadyProcessed,
182
+ bufferedBus_->getChannel(ch)->getData() + processedSamples_,
183
+ framesToProcess * sizeof(float));
176
184
  }
177
- bufferedBusIndex_ -= offsetLength;
178
- } else {
179
- if (VERBOSE)
180
- printf(
181
- "Buffer underrun: have %zu, need %zu\n",
182
- bufferedBusIndex_,
183
- (size_t)framesToProcess);
184
- processingBus->zero();
185
+ processedSamples_ += framesToProcess;
185
186
  }
186
187
 
187
188
  return processingBus;
@@ -220,22 +221,21 @@ bool StreamerNode::processFrameWithResampler(AVFrame *frame) {
220
221
  return false;
221
222
  }
222
223
 
223
- // Check if converted data fits in buffer
224
- if (bufferedBusIndex_ + converted_samples > maxBufferSize_) {
225
- pendingFrame_ = frame;
224
+ // if we would like to finish dont copy anything
225
+ if (this->isFinished()) {
226
226
  return true;
227
- } else {
228
- pendingFrame_ = nullptr;
229
227
  }
230
-
231
- // Copy converted data to our buffer
232
- Locker locker(mutex_);
228
+ auto bus = AudioBus(
229
+ static_cast<size_t>(converted_samples),
230
+ codecCtx_->ch_layout.nb_channels,
231
+ context_->getSampleRate());
233
232
  for (int ch = 0; ch < codecCtx_->ch_layout.nb_channels; ch++) {
234
233
  auto *src = reinterpret_cast<float *>(resampledData_[ch]);
235
- float *dst = bufferedBus_->getChannel(ch)->getData() + bufferedBusIndex_;
234
+ float *dst = bus.getChannel(ch)->getData();
236
235
  memcpy(dst, src, converted_samples * sizeof(float));
237
236
  }
238
- bufferedBusIndex_ += converted_samples;
237
+ StreamingData data{std::move(bus), static_cast<size_t>(converted_samples)};
238
+ sender_.send(std::move(data));
239
239
  return true;
240
240
  }
241
241
 
@@ -280,7 +280,7 @@ bool StreamerNode::setupDecoder() {
280
280
  }
281
281
 
282
282
  void StreamerNode::cleanup() {
283
- streamFlag.store(false);
283
+ this->playbackState_ = PlaybackState::FINISHED;
284
284
  // cleanup cannot be called from the streaming thread so there is no need to
285
285
  // check if we are in the same thread
286
286
  streamingThread_.join();
@@ -11,6 +11,7 @@
11
11
  #pragma once
12
12
 
13
13
  #include <audioapi/core/sources/AudioScheduledSourceNode.h>
14
+ #include <audioapi/utils/AudioBus.h>
14
15
 
15
16
  #ifndef AUDIO_API_TEST_SUITE
16
17
  extern "C" {
@@ -27,8 +28,35 @@ extern "C" {
27
28
  #include <memory>
28
29
  #include <string>
29
30
  #include <atomic>
31
+ #include <utility>
32
+ #ifndef AUDIO_API_TEST_SUITE
33
+ #include <audioapi/utils/SpscChannel.hpp>
30
34
 
31
- static bool constexpr VERBOSE = false;
35
+ static constexpr audioapi::channels::spsc::OverflowStrategy STREAMER_NODE_SPSC_OVERFLOW_STRATEGY =
36
+ audioapi::channels::spsc::OverflowStrategy::WAIT_ON_FULL;
37
+ static constexpr audioapi::channels::spsc::WaitStrategy STREAMER_NODE_SPSC_WAIT_STRATEGY =
38
+ audioapi::channels::spsc::WaitStrategy::ATOMIC_WAIT;
39
+ #endif
40
+
41
+ static constexpr bool VERBOSE = false;
42
+ static constexpr int CHANNEL_CAPACITY = 32;
43
+
44
+ struct StreamingData{
45
+ audioapi::AudioBus bus;
46
+ size_t size;
47
+ StreamingData() = default;
48
+ StreamingData(audioapi::AudioBus b, size_t s) : bus(b), size(s) {}
49
+ StreamingData(const StreamingData& data) : bus(data.bus), size(data.size) {}
50
+ StreamingData(StreamingData&& data) noexcept : bus(std::move(data.bus)), size(data.size) {}
51
+ StreamingData& operator=(const StreamingData& data) {
52
+ if (this == &data) {
53
+ return *this;
54
+ }
55
+ bus = data.bus;
56
+ size = data.size;
57
+ return *this;
58
+ }
59
+ };
32
60
 
33
61
  namespace audioapi {
34
62
 
@@ -43,7 +71,6 @@ class StreamerNode : public AudioScheduledSourceNode {
43
71
  * @brief Initialize all necessary ffmpeg components for streaming audio
44
72
  */
45
73
  bool initialize(const std::string& inputUrl);
46
- void stop(double when) override;
47
74
 
48
75
  protected:
49
76
  std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>& processingBus, int framesToProcess) override;
@@ -56,19 +83,20 @@ class StreamerNode : public AudioScheduledSourceNode {
56
83
  AVCodecParameters* codecpar_;
57
84
  AVPacket* pkt_;
58
85
  AVFrame* frame_; // Frame that is currently being processed
59
- AVFrame* pendingFrame_; // Frame that is saved if bufferedBus is full
60
- std::shared_ptr<AudioBus> bufferedBus_; // audio bus for buffering hls frames
61
- size_t bufferedBusIndex_; // index in the buffered bus where we write the next frame
62
- size_t maxBufferSize_; // maximum size of the buffered bus
63
- int audio_stream_index_; // index of the audio stream channel in the input
64
86
  SwrContext* swrCtx_;
65
87
  uint8_t** resampledData_; // weird ffmpeg way of using raw byte pointers for resampled data
88
+
89
+ std::shared_ptr<AudioBus> bufferedBus_; // audio bus for buffering hls frames
90
+ size_t bufferedBusSize_; // size of currently buffered bus
91
+ int audio_stream_index_; // index of the audio stream channel in the input
66
92
  int maxResampledSamples_;
67
- std::mutex mutex_;
93
+ size_t processedSamples_;
94
+
68
95
  std::thread streamingThread_;
69
- std::atomic<bool> streamFlag; // Flag to control the streaming thread
70
- static constexpr float BUFFER_LENGTH_SECONDS = 5.0f; // Length of the buffer in seconds
96
+ std::atomic<bool> isNodeFinished_; // Flag to control the streaming thread
71
97
  static constexpr int INITIAL_MAX_RESAMPLED_SAMPLES = 8192; // Initial size for resampled data
98
+ channels::spsc::Sender<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> sender_;
99
+ channels::spsc::Receiver<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> receiver_;
72
100
 
73
101
  /**
74
102
  * @brief Setting up the resampler
@@ -1,5 +1,6 @@
1
1
  #include <audioapi/core/AudioNode.h>
2
2
  #include <audioapi/core/AudioParam.h>
3
+ #include <audioapi/core/effects/ConvolverNode.h>
3
4
  #include <audioapi/core/sources/AudioScheduledSourceNode.h>
4
5
  #include <audioapi/core/utils/AudioNodeManager.h>
5
6
  #include <audioapi/core/utils/Locker.h>
@@ -221,6 +222,10 @@ inline bool AudioNodeManager::nodeCanBeDestructed(
221
222
  if constexpr (std::is_base_of_v<AudioScheduledSourceNode, U>) {
222
223
  return node.use_count() == 1 &&
223
224
  (node->isUnscheduled() || node->isFinished());
225
+ } else if constexpr (std::is_base_of_v<
226
+ ConvolverNode,
227
+ U>) { // convolver overrides disabling behavior
228
+ return node.use_count() == 1 && !node->isEnabled();
224
229
  }
225
230
  return node.use_count() == 1;
226
231
  }
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
2
 
3
+ #include <numbers>
3
4
  #include <cmath>
4
5
  #include <limits>
5
6
 
@@ -19,7 +20,7 @@ static constexpr float MOST_POSITIVE_SINGLE_FLOAT = static_cast<float>(std::nume
19
20
  static constexpr float MOST_NEGATIVE_SINGLE_FLOAT = static_cast<float>(std::numeric_limits<float>::lowest());
20
21
  static float LOG2_MOST_POSITIVE_SINGLE_FLOAT = std::log2(MOST_POSITIVE_SINGLE_FLOAT);
21
22
  static float LOG10_MOST_POSITIVE_SINGLE_FLOAT = std::log10(MOST_POSITIVE_SINGLE_FLOAT);
22
- static constexpr float PI = static_cast<float>(M_PI);
23
+ static constexpr float PI = std::numbers::pi_v<float>;
23
24
 
24
25
  // buffer sizes
25
26
  static constexpr size_t PROMISE_VENDOR_THREAD_POOL_WORKER_COUNT = 4;
@@ -5,14 +5,8 @@
5
5
  #include <string>
6
6
  #include <memory>
7
7
 
8
- #ifdef __APPLE__
9
- /// We cannot make any conditional logic inside podspec but it should automatically compile those files
10
- /// they should be accessible if someone has react-native-worklets in node_modules
11
- #if __has_include(<worklets/WorkletRuntime/WorkletRuntime.h>)
12
- #define RN_AUDIO_API_ENABLE_WORKLETS 1
13
- #else
14
- #define RN_AUDIO_API_ENABLE_WORKLETS 0
15
- #endif
8
+ #if ANDROID
9
+ #include <fbjni/detail/Environment.h>
16
10
  #endif
17
11
 
18
12
  #ifndef RN_AUDIO_API_TEST
@@ -78,4 +72,14 @@ class SerializableWorklet {
78
72
  struct RuntimeRegistry {
79
73
  std::weak_ptr<worklets::WorkletRuntime> uiRuntime;
80
74
  std::shared_ptr<worklets::WorkletRuntime> audioRuntime;
75
+
76
+ #if ANDROID
77
+ ~RuntimeRegistry() {
78
+ facebook::jni::ThreadScope::WithClassLoader(
79
+ [this]() {
80
+ uiRuntime.reset();
81
+ audioRuntime.reset();
82
+ });
83
+ }
84
+ #endif
81
85
  };
@@ -4,7 +4,7 @@ namespace audioapi {
4
4
 
5
5
  WorkletsRunner::WorkletsRunner(
6
6
  std::weak_ptr<worklets::WorkletRuntime> weakRuntime,
7
- std::shared_ptr<worklets::SerializableWorklet> shareableWorklet,
7
+ const std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet,
8
8
  bool shouldLockRuntime)
9
9
  : weakRuntime_(std::move(weakRuntime)),
10
10
  shouldLockRuntime(shouldLockRuntime) {
@@ -33,8 +33,8 @@ WorkletsRunner::WorkletsRunner(
33
33
  WorkletsRunner::WorkletsRunner(WorkletsRunner &&other)
34
34
  : weakRuntime_(std::move(other.weakRuntime_)),
35
35
  unsafeRuntimePtr(other.unsafeRuntimePtr),
36
- shouldLockRuntime(other.shouldLockRuntime),
37
- workletInitialized(other.workletInitialized) {
36
+ workletInitialized(other.workletInitialized),
37
+ shouldLockRuntime(other.shouldLockRuntime) {
38
38
  if (workletInitialized) {
39
39
  std::memcpy(&unsafeWorklet, &other.unsafeWorklet, sizeof(unsafeWorklet));
40
40
  other.workletInitialized = false;
@@ -28,7 +28,7 @@ class WorkletsRunner {
28
28
  public:
29
29
  explicit WorkletsRunner(
30
30
  std::weak_ptr<worklets::WorkletRuntime> weakRuntime,
31
- std::shared_ptr<worklets::SerializableWorklet> shareableWorklet,
31
+ const std::shared_ptr<worklets::SerializableWorklet>& shareableWorklet,
32
32
  bool shouldLockRuntime = true);
33
33
  WorkletsRunner(WorkletsRunner&&);
34
34
  ~WorkletsRunner();
@@ -30,4 +30,4 @@ float linearToDecibels(float value) {
30
30
  float decibelsToLinear(float value) {
31
31
  return pow(10, value / 20);
32
32
  }
33
- } // namespace audioapi::dsp
33
+ } // namespace audioapi::dsp