react-native-audio-api 0.11.0-alpha.0 → 0.11.0-nightly-bfab178-20251107

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (350) 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 -94
  8. package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +14 -28
  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/BaseAudioContextHostObject.cpp +18 -0
  19. package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +1 -0
  20. package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
  21. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +47 -0
  22. package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +20 -0
  23. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +18 -80
  24. package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +6 -15
  25. package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +1 -1
  26. package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +1 -1
  27. package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +1 -1
  28. package/common/cpp/audioapi/core/AudioNode.h +3 -2
  29. package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
  30. package/common/cpp/audioapi/core/BaseAudioContext.cpp +10 -0
  31. package/common/cpp/audioapi/core/BaseAudioContext.h +2 -0
  32. package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +69 -32
  33. package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +37 -1
  34. package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +210 -0
  35. package/common/cpp/audioapi/core/effects/ConvolverNode.h +55 -0
  36. package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +49 -102
  37. package/common/cpp/audioapi/core/inputs/AudioRecorder.h +28 -46
  38. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +14 -17
  39. package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +0 -1
  40. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +8 -14
  41. package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +0 -1
  42. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +14 -18
  43. package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +2 -2
  44. package/common/cpp/audioapi/core/sources/StreamerNode.cpp +64 -64
  45. package/common/cpp/audioapi/core/sources/StreamerNode.h +38 -10
  46. package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +5 -0
  47. package/common/cpp/audioapi/core/utils/Constants.h +2 -1
  48. package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +12 -8
  49. package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +3 -3
  50. package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +1 -1
  51. package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
  52. package/common/cpp/audioapi/dsp/Convolver.cpp +213 -0
  53. package/common/cpp/audioapi/dsp/Convolver.h +45 -0
  54. package/common/cpp/audioapi/dsp/FFT.cpp +0 -26
  55. package/common/cpp/audioapi/dsp/FFT.h +26 -2
  56. package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +1 -1
  57. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +4 -4
  58. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
  59. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
  60. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +3 -1
  61. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +2 -2
  62. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/defs.h +3 -0
  63. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/packet.h +1 -1
  64. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/smpte_436m.h +254 -0
  65. package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/version.h +1 -1
  66. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +6 -6
  67. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version.h +2 -2
  68. package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version_major.h +2 -0
  69. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avassert.h +5 -2
  70. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
  71. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/channel_layout.h +2 -2
  72. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/csp.h +1 -1
  73. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/dict.h +1 -1
  74. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ffversion.h +1 -1
  75. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/film_grain_params.h +1 -1
  76. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/frame.h +1 -1
  77. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hdr_dynamic_vivid_metadata.h +3 -3
  78. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext.h +1 -1
  79. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_opencl.h +1 -1
  80. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_qsv.h +0 -1
  81. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vulkan.h +1 -1
  82. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/iamf.h +2 -2
  83. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/lfg.h +2 -2
  84. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/log.h +2 -2
  85. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mathematics.h +1 -1
  86. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/opt.h +4 -4
  87. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rational.h +1 -1
  88. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rc4.h +1 -1
  89. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/refstruct.h +1 -1
  90. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/spherical.h +6 -0
  91. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tdrdi.h +1 -1
  92. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tx.h +1 -1
  93. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/version.h +3 -3
  94. package/common/cpp/audioapi/external/ffmpeg_include/libavutil/video_hint.h +1 -1
  95. package/common/cpp/audioapi/external/ffmpeg_include/libswresample/swresample.h +1 -1
  96. package/common/cpp/audioapi/external/ffmpeg_include/libswresample/version.h +1 -1
  97. package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +2 -3
  98. package/common/cpp/audioapi/libs/ffmpeg/relinking.md +24 -0
  99. package/common/cpp/audioapi/utils/AlignedAllocator.hpp +50 -0
  100. package/common/cpp/audioapi/utils/AudioBus.cpp +28 -0
  101. package/common/cpp/audioapi/utils/AudioBus.h +3 -0
  102. package/common/cpp/audioapi/utils/ThreadPool.hpp +59 -1
  103. package/common/cpp/test/CMakeLists.txt +19 -14
  104. package/common/cpp/test/src/AudioParamTest.cpp +1 -1
  105. package/common/cpp/test/src/AudioScheduledSourceTest.cpp +134 -0
  106. package/common/cpp/test/src/ConstantSourceTest.cpp +1 -1
  107. package/common/cpp/test/src/GainTest.cpp +1 -1
  108. package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +4 -4
  109. package/common/cpp/test/src/OscillatorTest.cpp +1 -1
  110. package/common/cpp/test/src/StereoPannerTest.cpp +1 -1
  111. package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +389 -0
  112. package/common/cpp/test/src/biquad/BiquadFilterChromium.h +64 -0
  113. package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +284 -0
  114. package/common/cpp/test/src/biquad/BiquadFilterTest.h +40 -0
  115. package/ios/audioapi/ios/AudioAPIModule.h +2 -1
  116. package/ios/audioapi/ios/AudioAPIModule.mm +13 -0
  117. package/ios/audioapi/ios/core/IOSAudioRecorder.h +9 -18
  118. package/ios/audioapi/ios/core/IOSAudioRecorder.mm +28 -70
  119. package/ios/audioapi/ios/core/NativeAudioRecorder.h +6 -2
  120. package/ios/audioapi/ios/core/NativeAudioRecorder.m +73 -5
  121. package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
  122. package/ios/audioapi/ios/system/AudioSessionManager.h +2 -0
  123. package/ios/audioapi/ios/system/AudioSessionManager.mm +24 -0
  124. package/ios/audioapi/ios/system/LockScreenManager.h +0 -1
  125. package/ios/audioapi/ios/system/LockScreenManager.mm +6 -19
  126. package/lib/commonjs/api.js +141 -76
  127. package/lib/commonjs/api.js.map +1 -1
  128. package/lib/commonjs/api.web.js +8 -0
  129. package/lib/commonjs/api.web.js.map +1 -1
  130. package/lib/commonjs/core/AudioContext.js +1 -1
  131. package/lib/commonjs/core/AudioContext.js.map +1 -1
  132. package/lib/commonjs/core/AudioRecorder.js +12 -157
  133. package/lib/commonjs/core/AudioRecorder.js.map +1 -1
  134. package/lib/commonjs/core/BaseAudioContext.js +28 -25
  135. package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
  136. package/lib/commonjs/core/ConvolverNode.js +37 -0
  137. package/lib/commonjs/core/ConvolverNode.js.map +1 -0
  138. package/lib/commonjs/core/OfflineAudioContext.js +1 -1
  139. package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
  140. package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
  141. package/lib/commonjs/system/AudioManager.js +3 -0
  142. package/lib/commonjs/system/AudioManager.js.map +1 -1
  143. package/lib/commonjs/types.js +0 -46
  144. package/lib/commonjs/types.js.map +1 -1
  145. package/lib/commonjs/utils/index.js +19 -21
  146. package/lib/commonjs/utils/index.js.map +1 -1
  147. package/lib/commonjs/web-core/AudioContext.js +12 -0
  148. package/lib/commonjs/web-core/AudioContext.js.map +1 -1
  149. package/lib/commonjs/web-core/ConvolverNode.js +40 -0
  150. package/lib/commonjs/web-core/ConvolverNode.js.map +1 -0
  151. package/lib/commonjs/web-core/ConvolverNodeOptions.js +6 -0
  152. package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +1 -0
  153. package/lib/commonjs/web-core/OfflineAudioContext.js +12 -0
  154. package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
  155. package/lib/module/api.js +16 -15
  156. package/lib/module/api.js.map +1 -1
  157. package/lib/module/api.web.js +1 -0
  158. package/lib/module/api.web.js.map +1 -1
  159. package/lib/module/core/AudioContext.js +2 -2
  160. package/lib/module/core/AudioContext.js.map +1 -1
  161. package/lib/module/core/AudioRecorder.js +12 -157
  162. package/lib/module/core/AudioRecorder.js.map +1 -1
  163. package/lib/module/core/BaseAudioContext.js +29 -26
  164. package/lib/module/core/BaseAudioContext.js.map +1 -1
  165. package/lib/module/core/ConvolverNode.js +31 -0
  166. package/lib/module/core/ConvolverNode.js.map +1 -0
  167. package/lib/module/core/OfflineAudioContext.js +2 -2
  168. package/lib/module/core/OfflineAudioContext.js.map +1 -1
  169. package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
  170. package/lib/module/system/AudioManager.js +3 -0
  171. package/lib/module/system/AudioManager.js.map +1 -1
  172. package/lib/module/types.js +1 -45
  173. package/lib/module/types.js.map +1 -1
  174. package/lib/module/utils/index.js +15 -2
  175. package/lib/module/utils/index.js.map +1 -1
  176. package/lib/module/web-core/AudioContext.js +12 -0
  177. package/lib/module/web-core/AudioContext.js.map +1 -1
  178. package/lib/module/web-core/ConvolverNode.js +34 -0
  179. package/lib/module/web-core/ConvolverNode.js.map +1 -0
  180. package/lib/module/web-core/ConvolverNodeOptions.js +4 -0
  181. package/lib/module/web-core/ConvolverNodeOptions.js.map +1 -0
  182. package/lib/module/web-core/OfflineAudioContext.js +12 -0
  183. package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
  184. package/lib/typescript/api.d.ts +19 -17
  185. package/lib/typescript/api.d.ts.map +1 -1
  186. package/lib/typescript/api.web.d.ts +1 -0
  187. package/lib/typescript/api.web.d.ts.map +1 -1
  188. package/lib/typescript/core/AudioContext.d.ts.map +1 -1
  189. package/lib/typescript/core/AudioRecorder.d.ts +6 -58
  190. package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
  191. package/lib/typescript/core/BaseAudioContext.d.ts +3 -1
  192. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  193. package/lib/typescript/core/ConvolverNode.d.ts +12 -0
  194. package/lib/typescript/core/ConvolverNode.d.ts.map +1 -0
  195. package/lib/typescript/events/types.d.ts +0 -16
  196. package/lib/typescript/events/types.d.ts.map +1 -1
  197. package/lib/typescript/interfaces.d.ts +8 -39
  198. package/lib/typescript/interfaces.d.ts.map +1 -1
  199. package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -0
  200. package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
  201. package/lib/typescript/system/AudioManager.d.ts +1 -0
  202. package/lib/typescript/system/AudioManager.d.ts.map +1 -1
  203. package/lib/typescript/types.d.ts +8 -74
  204. package/lib/typescript/types.d.ts.map +1 -1
  205. package/lib/typescript/utils/index.d.ts +5 -2
  206. package/lib/typescript/utils/index.d.ts.map +1 -1
  207. package/lib/typescript/web-core/AudioContext.d.ts +3 -0
  208. package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
  209. package/lib/typescript/web-core/BaseAudioContext.d.ts +2 -0
  210. package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
  211. package/lib/typescript/web-core/ConvolverNode.d.ts +11 -0
  212. package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -0
  213. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +6 -0
  214. package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +1 -0
  215. package/lib/typescript/web-core/OfflineAudioContext.d.ts +3 -0
  216. package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
  217. package/package.json +14 -5
  218. package/scripts/download-prebuilt-binaries.sh +61 -0
  219. package/scripts/rnaa_utils.rb +8 -0
  220. package/scripts/validate-worklets-version.js +28 -0
  221. package/src/api.ts +45 -18
  222. package/src/api.web.ts +1 -0
  223. package/src/core/AudioContext.ts +3 -2
  224. package/src/core/AudioRecorder.ts +20 -190
  225. package/src/core/BaseAudioContext.ts +67 -60
  226. package/src/core/ConvolverNode.ts +35 -0
  227. package/src/core/OfflineAudioContext.ts +2 -2
  228. package/src/events/types.ts +0 -18
  229. package/src/interfaces.ts +15 -47
  230. package/src/specs/NativeAudioAPIModule.ts +1 -0
  231. package/src/system/AudioManager.ts +4 -0
  232. package/src/types.ts +9 -84
  233. package/src/utils/index.ts +22 -2
  234. package/src/web-core/AudioContext.tsx +25 -0
  235. package/src/web-core/BaseAudioContext.tsx +2 -0
  236. package/src/web-core/ConvolverNode.tsx +43 -0
  237. package/src/web-core/ConvolverNodeOptions.tsx +6 -0
  238. package/src/web-core/OfflineAudioContext.tsx +25 -0
  239. package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +0 -33
  240. package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +0 -34
  241. package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +0 -133
  242. package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +0 -3
  243. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +0 -154
  244. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +0 -41
  245. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +0 -431
  246. package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +0 -112
  247. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +0 -47
  248. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +0 -28
  249. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +0 -237
  250. package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +0 -46
  251. package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +0 -31
  252. package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +0 -18
  253. package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
  254. package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
  255. package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
  256. package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
  257. package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
  258. package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
  259. package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
  260. package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
  261. package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
  262. package/android/src/main/jniLibs/x86/libavformat.so +0 -0
  263. package/android/src/main/jniLibs/x86/libavutil.so +0 -0
  264. package/android/src/main/jniLibs/x86/libswresample.so +0 -0
  265. package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
  266. package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
  267. package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
  268. package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
  269. package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
  270. package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
  271. package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
  272. package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
  273. package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
  274. package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
  275. package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
  276. package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
  277. package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
  278. package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
  279. package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
  280. package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
  281. package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
  282. package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
  283. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
  284. package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
  285. package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
  286. package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
  287. package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
  288. package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
  289. package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
  290. package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
  291. package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
  292. package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
  293. package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
  294. package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
  295. package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
  296. package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
  297. package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
  298. package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
  299. package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
  300. package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
  301. package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +0 -44
  302. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +0 -1
  303. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
  304. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +0 -1
  305. package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
  306. package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +0 -44
  307. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +0 -1
  308. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
  309. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +0 -1
  310. package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
  311. package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +0 -44
  312. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +0 -1
  313. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
  314. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +0 -1
  315. package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
  316. package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +0 -44
  317. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +0 -1
  318. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
  319. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +0 -1
  320. package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
  321. package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
  322. package/common/cpp/audioapi/external/x86/libogg.a +0 -0
  323. package/common/cpp/audioapi/external/x86/libopus.a +0 -0
  324. package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
  325. package/common/cpp/audioapi/external/x86/libssl.a +0 -0
  326. package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
  327. package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
  328. package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
  329. package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
  330. package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
  331. package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
  332. package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
  333. package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
  334. package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
  335. package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
  336. package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
  337. package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +0 -32
  338. package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +0 -111
  339. package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +0 -391
  340. package/ios/audioapi/ios/core/IOSAudioFileOptions.h +0 -35
  341. package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +0 -135
  342. package/ios/audioapi/ios/core/IOSAudioFileWriter.h +0 -38
  343. package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +0 -187
  344. package/lib/commonjs/utils/bitEnums.js +0 -33
  345. package/lib/commonjs/utils/bitEnums.js.map +0 -1
  346. package/lib/module/utils/bitEnums.js +0 -27
  347. package/lib/module/utils/bitEnums.js.map +0 -1
  348. package/lib/typescript/utils/bitEnums.d.ts +0 -4
  349. package/lib/typescript/utils/bitEnums.d.ts.map +0 -1
  350. package/src/utils/bitEnums.ts +0 -51
@@ -75,7 +75,7 @@ typedef struct AVOpenCLDeviceContext {
75
75
  /**
76
76
  * The default command queue for this device, which will be used by all
77
77
  * frames contexts which do not have their own command queue. If not
78
- * intialised by the user, a default queue will be created on the
78
+ * initialised by the user, a default queue will be created on the
79
79
  * primary device.
80
80
  */
81
81
  cl_command_queue command_queue;
@@ -84,4 +84,3 @@ typedef struct AVQSVFramesContext {
84
84
  } AVQSVFramesContext;
85
85
 
86
86
  #endif /* AVUTIL_HWCONTEXT_QSV_H */
87
-
@@ -115,7 +115,7 @@ typedef struct AVVulkanDeviceContext {
115
115
  #if FF_API_VULKAN_FIXED_QUEUES
116
116
  /**
117
117
  * Queue family index for graphics operations, and the number of queues
118
- * enabled for it. If unavaiable, will be set to -1. Not required.
118
+ * enabled for it. If unavailable, will be set to -1. Not required.
119
119
  * av_hwdevice_create() will attempt to find a dedicated queue for each
120
120
  * queue family, or pick the one with the least unrelated flags set.
121
121
  * Queue indices here may overlap if a queue has to share capabilities.
@@ -213,11 +213,11 @@ typedef struct AVIAMFParamDefinition {
213
213
  enum AVIAMFParamDefinitionType type;
214
214
 
215
215
  /**
216
- * Identifier for the paremeter substream.
216
+ * Identifier for the parameter substream.
217
217
  */
218
218
  unsigned int parameter_id;
219
219
  /**
220
- * Sample rate for the paremeter substream. It must not be 0.
220
+ * Sample rate for the parameter substream. It must not be 0.
221
221
  */
222
222
  unsigned int parameter_rate;
223
223
 
@@ -28,7 +28,7 @@
28
28
  * Context structure for the Lagged Fibonacci PRNG.
29
29
  * The exact layout, types and content of this struct may change and should
30
30
  * not be accessed directly. Only its `sizeof()` is guaranteed to stay the same
31
- * to allow easy instanciation.
31
+ * to allow easy instantiation.
32
32
  */
33
33
  typedef struct AVLFG {
34
34
  unsigned int state[64];
@@ -73,7 +73,7 @@ static inline unsigned int av_mlfg_get(AVLFG *c){
73
73
  * Get the next two numbers generated by a Box-Muller Gaussian
74
74
  * generator using the random numbers issued by lfg.
75
75
  *
76
- * @param lfg pointer to the contex structure
76
+ * @param lfg pointer to the context structure
77
77
  * @param out array where the two generated numbers are placed
78
78
  */
79
79
  void av_bmg_get(AVLFG *lfg, double out[2]);
@@ -277,9 +277,9 @@ void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
277
277
  * @param avcl A pointer to an arbitrary struct of which the first field is a
278
278
  * pointer to an AVClass struct or NULL if general log.
279
279
  * @param initial_level importance level of the message expressed using a @ref
280
- * lavu_log_constants "Logging Constant" for the first occurance.
280
+ * lavu_log_constants "Logging Constant" for the first occurrence.
281
281
  * @param subsequent_level importance level of the message expressed using a @ref
282
- * lavu_log_constants "Logging Constant" after the first occurance.
282
+ * lavu_log_constants "Logging Constant" after the first occurrence.
283
283
  * @param fmt The format string (printf-compatible) that specifies how
284
284
  * subsequent arguments are converted to output.
285
285
  * @param state a variable to keep trak of if a message has already been printed
@@ -278,7 +278,7 @@ int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int
278
278
  /**
279
279
  * Add a value to a timestamp.
280
280
  *
281
- * This function guarantees that when the same value is repeatly added that
281
+ * This function guarantees that when the same value is repeatedly added that
282
282
  * no accumulation of rounding errors occurs.
283
283
  *
284
284
  * @param[in] ts Input timestamp
@@ -542,7 +542,7 @@ typedef struct AVOptionRanges {
542
542
  */
543
543
  int nb_ranges;
544
544
  /**
545
- * Number of componentes.
545
+ * Number of components.
546
546
  */
547
547
  int nb_components;
548
548
  } AVOptionRanges;
@@ -1137,7 +1137,7 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name)
1137
1137
  * @param[in] obj AVClass object to serialize
1138
1138
  * @param[in] opt_flags serialize options with all the specified flags set (AV_OPT_FLAG)
1139
1139
  * @param[in] flags combination of AV_OPT_SERIALIZE_* flags
1140
- * @param[out] buffer Pointer to buffer that will be allocated with string containg serialized options.
1140
+ * @param[out] buffer Pointer to buffer that will be allocated with string containing serialized options.
1141
1141
  * Buffer must be freed by the caller when is no longer needed.
1142
1142
  * @param[in] key_val_sep character used to separate key from value
1143
1143
  * @param[in] pairs_sep character used to separate two pairs from each other
@@ -1167,7 +1167,7 @@ void av_opt_freep_ranges(AVOptionRanges **ranges);
1167
1167
  *
1168
1168
  * The result must be freed with av_opt_freep_ranges.
1169
1169
  *
1170
- * @return number of compontents returned on success, a negative errro code otherwise
1170
+ * @return number of components returned on success, a negative error code otherwise
1171
1171
  */
1172
1172
  int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
1173
1173
 
@@ -1183,7 +1183,7 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags
1183
1183
  *
1184
1184
  * The result must be freed with av_opt_free_ranges.
1185
1185
  *
1186
- * @return number of compontents returned on success, a negative errro code otherwise
1186
+ * @return number of components returned on success, a negative error code otherwise
1187
1187
  */
1188
1188
  int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
1189
1189
 
@@ -22,7 +22,7 @@
22
22
  /**
23
23
  * @file
24
24
  * @ingroup lavu_math_rational
25
- * Utilties for rational number calculation.
25
+ * Utilities for rational number calculation.
26
26
  * @author Michael Niedermayer <michaelni@gmx.at>
27
27
  */
28
28
 
@@ -43,7 +43,7 @@ AVRC4 *av_rc4_alloc(void);
43
43
  * @brief Initializes an AVRC4 context.
44
44
  *
45
45
  * @param d pointer to the AVRC4 context
46
- * @param key buffer containig the key
46
+ * @param key buffer containing the key
47
47
  * @param key_bits must be a multiple of 8
48
48
  * @param decrypt 0 for encryption, 1 for decryption, currently has no effect
49
49
  * @return zero on success, negative value otherwise
@@ -161,7 +161,7 @@ int av_refstruct_exclusive(const void *obj);
161
161
  *
162
162
  * Frequently allocating and freeing large or complicated objects may be slow
163
163
  * and wasteful. This API is meant to solve this in cases when the caller
164
- * needs a set of interchangable objects.
164
+ * needs a set of interchangeable objects.
165
165
  *
166
166
  * At the beginning, the user must call allocate the pool via
167
167
  * av_refstruct_pool_alloc() or its analogue av_refstruct_pool_alloc_ext().
@@ -82,6 +82,12 @@ enum AVSphericalProjection {
82
82
  * See: https://developer.apple.com/documentation/coremedia/cmprojectiontype/fisheye
83
83
  */
84
84
  AV_SPHERICAL_FISHEYE,
85
+
86
+ /**
87
+ * Parametric Immersive projection (Apple).
88
+ * See: https://developer.apple.com/documentation/coremedia/cmprojectiontype/parametricimmersive
89
+ */
90
+ AV_SPHERICAL_PARAMETRIC_IMMERSIVE,
85
91
  };
86
92
 
87
93
  /**
@@ -119,7 +119,7 @@ typedef struct AV3DReferenceDisplay {
119
119
  uint8_t mantissa_ref_display_width;
120
120
 
121
121
  /**
122
- * Tthe exponent part of the reference viewing distance of the n-th reference display.
122
+ * The exponent part of the reference viewing distance of the n-th reference display.
123
123
  */
124
124
  uint8_t exponent_ref_viewing_distance;
125
125
 
@@ -50,7 +50,7 @@ enum AVTXType {
50
50
 
51
51
  /**
52
52
  * Standard MDCT with a sample data type of float, double or int32_t,
53
- * respecively. For the float and int32 variants, the scale type is
53
+ * respectively. For the float and int32 variants, the scale type is
54
54
  * 'float', while for the double variant, it's 'double'.
55
55
  * If scale is NULL, 1.0 will be used as a default.
56
56
  *
@@ -35,7 +35,7 @@
35
35
  * Useful to check and match library version in order to maintain
36
36
  * backward compatibility.
37
37
  *
38
- * The FFmpeg libraries follow a versioning sheme very similar to
38
+ * The FFmpeg libraries follow a versioning scheme very similar to
39
39
  * Semantic Versioning (http://semver.org/)
40
40
  * The difference is that the component called PATCH is called MICRO in FFmpeg
41
41
  * and its value is reset to 100 instead of 0 to keep it above or equal to 100.
@@ -72,14 +72,14 @@
72
72
  /**
73
73
  * @defgroup lavu_ver Version and Build diagnostics
74
74
  *
75
- * Macros and function useful to check at compiletime and at runtime
75
+ * Macros and function useful to check at compile time and at runtime
76
76
  * which version of libavutil is in use.
77
77
  *
78
78
  * @{
79
79
  */
80
80
 
81
81
  #define LIBAVUTIL_VERSION_MAJOR 60
82
- #define LIBAVUTIL_VERSION_MINOR 6
82
+ #define LIBAVUTIL_VERSION_MINOR 8
83
83
  #define LIBAVUTIL_VERSION_MICRO 100
84
84
 
85
85
  #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -80,7 +80,7 @@ av_video_hint_get_rect(const AVVideoHint *hints, size_t idx) {
80
80
  * The side data contains a list of rectangles for the portions of the frame
81
81
  * which changed from the last encoded one (and the remainder are assumed to be
82
82
  * changed), or, alternately (depending on the type parameter) the unchanged
83
- * ones (and the remanining ones are those which changed).
83
+ * ones (and the remaining ones are those which changed).
84
84
  * Macroblocks will thus be hinted either to be P_SKIP-ped or go through the
85
85
  * regular encoding procedure.
86
86
  *
@@ -337,7 +337,7 @@ int64_t swr_next_pts(struct SwrContext *s, int64_t pts);
337
337
  * @}
338
338
  *
339
339
  * @name Low-level option setting functions
340
- * These functons provide a means to set low-level options that is not possible
340
+ * These functions provide a means to set low-level options that is not possible
341
341
  * with the AVOption API.
342
342
  * @{
343
343
  */
@@ -30,7 +30,7 @@
30
30
 
31
31
  #include "version_major.h"
32
32
 
33
- #define LIBSWRESAMPLE_VERSION_MINOR 0
33
+ #define LIBSWRESAMPLE_VERSION_MINOR 1
34
34
  #define LIBSWRESAMPLE_VERSION_MICRO 100
35
35
 
36
36
  #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \
@@ -277,8 +277,7 @@ decodeWithMemoryBlock(const void *data, size_t size, int sample_rate) {
277
277
  MemoryIOContext io_ctx{static_cast<const uint8_t *>(data), size, 0};
278
278
 
279
279
  constexpr size_t buffer_size = 4096;
280
- auto io_buffer = std::unique_ptr<uint8_t, decltype(&av_free)>(
281
- static_cast<uint8_t *>(av_malloc(buffer_size)), &av_free);
280
+ uint8_t *io_buffer = static_cast<uint8_t *>(av_malloc(buffer_size));
282
281
  if (io_buffer == nullptr) {
283
282
  return nullptr;
284
283
  }
@@ -286,7 +285,7 @@ decodeWithMemoryBlock(const void *data, size_t size, int sample_rate) {
286
285
  auto avio_ctx =
287
286
  std::unique_ptr<AVIOContext, std::function<void(AVIOContext *)>>(
288
287
  avio_alloc_context(
289
- io_buffer.get(),
288
+ io_buffer,
290
289
  buffer_size,
291
290
  0,
292
291
  &io_ctx,
@@ -0,0 +1,24 @@
1
+ ## If you would like to relink ffmpeg to your implementation there are two options:
2
+
3
+ ### Option A)
4
+
5
+ you can modify script in scripts/download-prebuilt-binaries.sh
6
+
7
+ - ios dynamic frameworks are in `ffmpeg_ios.zip` directory
8
+ - android shared libraries are in `jniLibs.zip`
9
+
10
+ just replace way of downloading them that links to your binaries
11
+
12
+ ### Option B)
13
+
14
+ directly modify libraries in source code
15
+
16
+ - ios dynamic frameworks are placed in `common/cpp/audioapi/external`
17
+ - android shared libraries are placed in `android/src/main/jniLibs`
18
+
19
+ ---
20
+ `USED_LIBRARIES`:
21
+ - libavcodec
22
+ - libavformat
23
+ - libavutil
24
+ - libswresample
@@ -0,0 +1,50 @@
1
+ #pragma once
2
+ #include <cstddef>
3
+ #include <new>
4
+
5
+ template<typename T, std::size_t Align = 16>
6
+ class AlignedAllocator {
7
+ public:
8
+ using value_type = T;
9
+ using size_type = std::size_t;
10
+ using difference_type = std::ptrdiff_t;
11
+
12
+ AlignedAllocator() noexcept = default;
13
+ template<class U> AlignedAllocator(const AlignedAllocator<U, Align>&) noexcept {}
14
+
15
+ T* allocate(std::size_t n) {
16
+ // We want to maximize performance on hot paths, so we hint unlikely branches
17
+ if (n == 0) [[ unlikely ]] {
18
+ return nullptr;
19
+ }
20
+ std::size_t bytes = n * sizeof(T);
21
+ // C++17 aligned new
22
+ void* p = ::operator new(bytes, std::align_val_t(Align));
23
+
24
+ // We have more serious problems if this happens than speed concerns
25
+ // so we can opt the branch prediction
26
+ if (!p) [[ unlikely ]] {
27
+ throw std::bad_alloc();
28
+ }
29
+ return static_cast<T*>(p);
30
+ }
31
+
32
+ void deallocate(T* p, std::size_t) noexcept {
33
+ ::operator delete(p, std::align_val_t(Align));
34
+ }
35
+
36
+ // Rebind allocator to type U (required by std::vector)
37
+ template<class U>
38
+ struct rebind { using other = AlignedAllocator<U, Align>; };
39
+
40
+ // Comparison operators (required by std::vector)
41
+ template<typename U, std::size_t UAlign>
42
+ bool operator==(const AlignedAllocator<U, UAlign>&) const noexcept {
43
+ return Align == UAlign;
44
+ }
45
+
46
+ template<typename U, std::size_t UAlign>
47
+ bool operator!=(const AlignedAllocator<U, UAlign>&) const noexcept {
48
+ return Align != UAlign;
49
+ }
50
+ };
@@ -34,6 +34,34 @@ AudioBus::AudioBus(const AudioBus &other) {
34
34
  }
35
35
  }
36
36
 
37
+ AudioBus::AudioBus(AudioBus &&other) noexcept
38
+ : channels_(std::move(other.channels_)),
39
+ numberOfChannels_(other.numberOfChannels_),
40
+ sampleRate_(other.sampleRate_),
41
+ size_(other.size_) {
42
+ other.numberOfChannels_ = 0;
43
+ other.sampleRate_ = 0.0f;
44
+ other.size_ = 0;
45
+ }
46
+
47
+ AudioBus &AudioBus::operator=(const AudioBus &other) {
48
+ if (this == &other) {
49
+ return *this;
50
+ }
51
+
52
+ numberOfChannels_ = other.numberOfChannels_;
53
+ sampleRate_ = other.sampleRate_;
54
+ size_ = other.size_;
55
+
56
+ createChannels();
57
+
58
+ for (int i = 0; i < numberOfChannels_; i += 1) {
59
+ channels_[i] = std::make_shared<AudioArray>(*other.channels_[i]);
60
+ }
61
+
62
+ return *this;
63
+ }
64
+
37
65
  AudioBus::~AudioBus() {
38
66
  channels_.clear();
39
67
  }
@@ -24,8 +24,11 @@ class AudioBus {
24
24
  ChannelSurroundRight = 5,
25
25
  };
26
26
 
27
+ explicit AudioBus() = default;
27
28
  explicit AudioBus(size_t size, int numberOfChannels, float sampleRate);
28
29
  AudioBus(const AudioBus &other);
30
+ AudioBus(AudioBus &&other) noexcept;
31
+ AudioBus& operator=(const AudioBus& other);
29
32
 
30
33
  ~AudioBus();
31
34
 
@@ -20,6 +20,11 @@ class ThreadPool {
20
20
  struct TaskEvent { audioapi::move_only_function<void()> task; };
21
21
  using Event = std::variant<TaskEvent, StopEvent>;
22
22
 
23
+ struct Cntrl {
24
+ std::atomic<bool> waitingForTasks{false};
25
+ std::atomic<size_t> tasksScheduled{0};
26
+ };
27
+
23
28
  using Sender = channels::spsc::Sender<Event, channels::spsc::OverflowStrategy::WAIT_ON_FULL, channels::spsc::WaitStrategy::ATOMIC_WAIT>;
24
29
  using Receiver = channels::spsc::Receiver<Event, channels::spsc::OverflowStrategy::WAIT_ON_FULL, channels::spsc::WaitStrategy::ATOMIC_WAIT>;
25
30
  public:
@@ -38,8 +43,30 @@ public:
38
43
  workerSenders.emplace_back(std::move(workerSender));
39
44
  }
40
45
  loadBalancerThread = std::thread(&ThreadPool::loadBalancerThreadFunc, this, std::move(receiver), std::move(workerSenders));
46
+ controlBlock_ = std::make_unique<Cntrl>();
47
+ }
48
+ ThreadPool(const ThreadPool&) = delete;
49
+ ThreadPool& operator=(const ThreadPool&) = delete;
50
+ ThreadPool(ThreadPool&& other):
51
+ loadBalancerThread(std::move(other.loadBalancerThread)),
52
+ workers(std::move(other.workers)),
53
+ loadBalancerSender(std::move(other.loadBalancerSender)),
54
+ controlBlock_(std::move(other.controlBlock_)) {}
55
+ ThreadPool& operator=(ThreadPool&& other) {
56
+ if (this != &other) {
57
+ loadBalancerThread = std::move(other.loadBalancerThread);
58
+ workers = std::move(other.workers);
59
+ loadBalancerSender = std::move(other.loadBalancerSender);
60
+ controlBlock_ = std::move(other.controlBlock_);
61
+ other.movedFrom_ = true;
62
+ }
63
+ return *this;
41
64
  }
65
+
42
66
  ~ThreadPool() {
67
+ if (movedFrom_) {
68
+ return;
69
+ }
43
70
  loadBalancerSender.send(StopEvent{});
44
71
  loadBalancerThread.join();
45
72
  for (auto& worker : workers) {
@@ -59,16 +86,47 @@ public:
59
86
  /// @note IMPORTANT: This function is not thread-safe and should be called from a single thread only.
60
87
  template<typename Func, typename ... Args, typename = std::enable_if_t<std::is_invocable_r_v<void, Func, Args...>>>
61
88
  void schedule(Func &&task, Args &&... args) noexcept {
62
- auto boundTask = [f = std::forward<Func>(task), ...capturedArgs = std::forward<Args>(args)]() mutable {
89
+ controlBlock_->tasksScheduled.fetch_add(1, std::memory_order_release);
90
+
91
+ /// We know that lifetime of each worker thus spsc thus lambda is strongly bounded by ThreadPool lifetime
92
+ /// so we can safely capture control block pointer unsafely here
93
+ Cntrl *cntrl = controlBlock_.get();
94
+ auto boundTask = [cntrl, f= std::forward<Func>(task), ...capturedArgs = std::forward<Args>(args)]() mutable {
63
95
  f(std::forward<Args>(capturedArgs)...);
96
+ size_t left = cntrl->tasksScheduled.fetch_sub(1, std::memory_order_acq_rel) - 1;
97
+ if (left == 0) {
98
+ cntrl->waitingForTasks.store(false, std::memory_order_release);
99
+ cntrl->waitingForTasks.notify_one();
100
+ }
64
101
  };
65
102
  loadBalancerSender.send(TaskEvent{audioapi::move_only_function<void()>(std::move(boundTask))});
66
103
  }
67
104
 
105
+ /// @brief Waits for all scheduled tasks to complete
106
+ void wait() {
107
+ /// This logic might seem incorrect at first glance
108
+ /// Main principle for this is that there is only one thread scheduling tasks
109
+ /// If he is waiting for the tasks he CANNOT schedule new tasks so we can assume partial
110
+ /// synchronization here.
111
+ /// We first store true so if any task finishes at this moment he will flip it
112
+ /// Then we check if there are any tasks scheduled
113
+ /// If there are none we can return immediately
114
+ /// If there are some we wait until the last task flips the flag to false
115
+ controlBlock_->waitingForTasks.store(true, std::memory_order_release);
116
+ if (controlBlock_->tasksScheduled.load(std::memory_order_acquire) == 0) {
117
+ controlBlock_->waitingForTasks.store(false, std::memory_order_release);
118
+ return;
119
+ }
120
+ controlBlock_->waitingForTasks.wait(true, std::memory_order_acquire);
121
+ return;
122
+ }
123
+
68
124
  private:
69
125
  std::thread loadBalancerThread;
70
126
  std::vector<std::thread> workers;
71
127
  Sender loadBalancerSender;
128
+ std::unique_ptr<Cntrl> controlBlock_;
129
+ bool movedFrom_ = false;
72
130
 
73
131
  void workerThreadFunc(Receiver &&receiver) {
74
132
  Receiver localReceiver = std::move(receiver);
@@ -12,41 +12,44 @@ FetchContent_Declare(
12
12
  googletest
13
13
  URL https://github.com/google/googletest/archive/3983f67e32fb3e9294487b9d4f9586efa6e5d088.zip
14
14
  )
15
+
15
16
  # For Windows: Prevent overriding the parent project's compiler/linker settings
16
17
  set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
17
18
  FetchContent_MakeAvailable(googletest)
18
19
 
19
20
  enable_testing()
20
21
 
22
+ set(REACT_NATIVE_AUDIO_API_DIR "${ROOT}/node_modules/react-native-audio-api")
23
+
21
24
  file(GLOB_RECURSE RNAUDIOAPI_SRC
22
25
  CONFIGURE_DEPENDS
23
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/*.cpp"
24
- "${ROOT}/node_modules/react-native-audio-api/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp"
26
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/*.cpp"
27
+ "${REACT_NATIVE_AUDIO_API_DIR}/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp"
25
28
  )
26
29
 
27
30
  # exclude HostObjects from tests
28
31
  list(FILTER RNAUDIOAPI_SRC EXCLUDE REGEX ".*/audioapi/HostObjects/.*\\.cpp$")
29
32
 
30
33
  list(REMOVE_ITEM RNAUDIOAPI_SRC
31
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/AudioContext.cpp"
32
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletNode.cpp"
33
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp"
34
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp"
35
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/sources/StreamerNode.cpp"
36
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/core/sources/StreamerNode.h"
37
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp"
38
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h"
34
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/AudioContext.cpp"
35
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/effects/WorkletNode.cpp"
36
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp"
37
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp"
38
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/sources/StreamerNode.cpp"
39
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/core/sources/StreamerNode.h"
40
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp"
41
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h"
39
42
  )
40
43
 
41
44
  file(GLOB_RECURSE RNAUDIOAPI_LIBS
42
45
  CONFIGURE_DEPENDS
43
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/*.c"
44
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/*.h"
46
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/*.c"
47
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/*.h"
45
48
  )
46
49
 
47
50
  list(REMOVE_ITEM RNAUDIOAPI_LIBS
48
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.c"
49
- "${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.c"
51
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.c"
52
+ "${REACT_NATIVE_AUDIO_API_DIR}/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.c"
50
53
  )
51
54
 
52
55
  add_library(rnaudioapi STATIC ${RNAUDIOAPI_SRC})
@@ -57,6 +60,8 @@ target_include_directories(rnaudioapi PUBLIC
57
60
  ${JSI_DIR}
58
61
  "${REACT_NATIVE_DIR}/ReactCommon"
59
62
  "${REACT_NATIVE_DIR}/ReactCommon/callinvoker"
63
+ ${gtest_SOURCE_DIR}/include
64
+ ${gmock_SOURCE_DIR}/include
60
65
  )
61
66
 
62
67
  target_include_directories(rnaudioapi_libs PUBLIC
@@ -8,7 +8,7 @@ using namespace audioapi;
8
8
 
9
9
  class AudioParamTest : public ::testing::Test {
10
10
  protected:
11
- std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
11
+ std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
12
12
  std::unique_ptr<OfflineAudioContext> context;
13
13
  static constexpr int sampleRate = 44100;
14
14