react-native-audio-api 0.12.0-nightly-6a44b58-20260126 → 0.12.0-nightly-1a3c43b-20260128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNAudioAPI.podspec +8 -0
- package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -13
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +3 -2
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +1 -1
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +12 -1
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +5 -1
- package/android/src/main/java/com/swmansion/audioapi/system/AudioEvent.kt +28 -0
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +4 -4
- package/android/src/main/java/com/swmansion/audioapi/system/VolumeChangeListener.kt +1 -1
- package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotification.kt +27 -18
- package/android/src/main/java/com/swmansion/audioapi/system/notification/PlaybackNotificationReceiver.kt +13 -8
- package/android/src/main/java/com/swmansion/audioapi/system/notification/RecordingNotificationReceiver.kt +3 -2
- package/android/src/oldarch/NativeAudioAPIModuleSpec.java +2 -2
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +9 -12
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.cpp +4 -2
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.h +5 -1
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +38 -38
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +4 -2
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +8 -4
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.h +7 -1
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.cpp +6 -4
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.h +6 -2
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +8 -5
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.h +5 -3
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +5 -3
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/DelayNodeHostObject.cpp +4 -3
- package/common/cpp/audioapi/HostObjects/effects/DelayNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.cpp +6 -2
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/IIRFilterNodeHostObject.cpp +6 -2
- package/common/cpp/audioapi/HostObjects/effects/IIRFilterNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.cpp +5 -2
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/effects/WaveShaperNodeHostObject.cpp +9 -4
- package/common/cpp/audioapi/HostObjects/effects/WaveShaperNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.cpp +3 -2
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +2 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.cpp +9 -6
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.h +4 -2
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +5 -2
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.cpp +5 -2
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.cpp +7 -3
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +6 -2
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +5 -2
- package/common/cpp/audioapi/HostObjects/utils/JsEnumParser.cpp +63 -0
- package/common/cpp/audioapi/HostObjects/utils/JsEnumParser.h +5 -0
- package/common/cpp/audioapi/core/AudioContext.cpp +2 -4
- package/common/cpp/audioapi/core/AudioNode.cpp +4 -4
- package/common/cpp/audioapi/core/AudioNode.h +6 -6
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +7 -22
- package/common/cpp/audioapi/core/BaseAudioContext.h +20 -22
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +3 -6
- package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +5 -2
- package/common/cpp/audioapi/core/analysis/AnalyserNode.h +4 -2
- package/common/cpp/audioapi/core/destinations/AudioDestinationNode.cpp +1 -1
- package/common/cpp/audioapi/core/destinations/AudioDestinationNode.h +1 -1
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +6 -6
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +2 -2
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +1 -1
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +2 -2
- package/common/cpp/audioapi/core/effects/DelayNode.cpp +1 -1
- package/common/cpp/audioapi/core/effects/DelayNode.h +2 -2
- package/common/cpp/audioapi/core/effects/GainNode.cpp +1 -1
- package/common/cpp/audioapi/core/effects/GainNode.h +2 -2
- package/common/cpp/audioapi/core/effects/IIRFilterNode.cpp +5 -3
- package/common/cpp/audioapi/core/effects/IIRFilterNode.h +2 -2
- package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +5 -2
- package/common/cpp/audioapi/core/effects/StereoPannerNode.h +2 -2
- package/common/cpp/audioapi/core/effects/WaveShaperNode.cpp +4 -2
- package/common/cpp/audioapi/core/effects/WaveShaperNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBuffer.h +1 -1
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +10 -4
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +13 -13
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +6 -5
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +2 -2
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +10 -2
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +11 -6
- package/common/cpp/audioapi/core/sources/OscillatorNode.h +2 -2
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +17 -4
- package/common/cpp/audioapi/core/sources/StreamerNode.h +4 -2
- package/common/cpp/audioapi/core/utils/AudioFileWriter.cpp +2 -3
- package/common/cpp/audioapi/core/utils/AudioRecorderCallback.cpp +3 -4
- package/common/cpp/audioapi/events/AudioEvent.h +30 -0
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.cpp +9 -20
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +7 -34
- package/common/cpp/audioapi/events/IAudioEventHandlerRegistry.h +5 -4
- package/common/cpp/audioapi/jsi/JsiUtils.cpp +21 -0
- package/common/cpp/audioapi/jsi/JsiUtils.h +17 -0
- package/{android/src/main/cpp/audioapi/android/core → common/cpp/audioapi}/utils/MiniaudioImplementation.cpp +1 -2
- package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +5 -10
- package/ios/audioapi/ios/AudioAPIModule.h +3 -1
- package/ios/audioapi/ios/AudioAPIModule.mm +7 -6
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -3
- package/ios/audioapi/ios/system/AudioSessionManager.h +3 -1
- package/ios/audioapi/ios/system/AudioSessionManager.mm +8 -1
- package/ios/audioapi/ios/system/SystemNotificationManager.mm +17 -8
- package/ios/audioapi/ios/system/notification/PlaybackNotification.mm +36 -33
- package/lib/commonjs/core/AudioDecoder.js +2 -2
- package/lib/commonjs/core/AudioDecoder.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +1 -1
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.web.js.map +1 -1
- package/lib/commonjs/system/AudioManager.js +1 -1
- package/lib/commonjs/system/AudioManager.js.map +1 -1
- package/lib/module/core/AudioDecoder.js +2 -2
- package/lib/module/core/AudioDecoder.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +1 -1
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.web.js.map +1 -1
- package/lib/module/system/AudioManager.js +1 -1
- package/lib/module/system/AudioManager.js.map +1 -1
- package/lib/typescript/core/AudioDecoder.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +1 -17
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.web.d.ts.map +1 -1
- package/lib/typescript/system/AudioManager.d.ts.map +1 -1
- package/lib/typescript/system/notification/types.d.ts +4 -3
- package/lib/typescript/system/notification/types.d.ts.map +1 -1
- package/lib/typescript/system/types.d.ts +8 -0
- package/lib/typescript/system/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/core/AudioDecoder.ts +2 -2
- package/src/core/AudioRecorder.ts +1 -1
- package/src/events/types.ts +1 -18
- package/src/specs/NativeAudioAPIModule.ts +3 -2
- package/src/specs/NativeAudioAPIModule.web.ts +2 -1
- package/src/system/AudioManager.ts +2 -1
- package/src/system/notification/types.ts +6 -4
- package/src/system/types.ts +8 -0
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
namespace audioapi {
|
|
10
10
|
|
|
11
11
|
class AudioBus;
|
|
12
|
-
|
|
12
|
+
struct DelayOptions;
|
|
13
13
|
|
|
14
14
|
class DelayNode : public AudioNode {
|
|
15
15
|
public:
|
|
16
|
-
explicit DelayNode(std::shared_ptr<BaseAudioContext> context, const DelayOptions &options);
|
|
16
|
+
explicit DelayNode(const std::shared_ptr<BaseAudioContext> &context, const DelayOptions &options);
|
|
17
17
|
|
|
18
18
|
[[nodiscard]] std::shared_ptr<AudioParam> getDelayTimeParam() const;
|
|
19
19
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
namespace audioapi {
|
|
10
10
|
|
|
11
|
-
GainNode::GainNode(std::shared_ptr<BaseAudioContext> context, const GainOptions &options)
|
|
11
|
+
GainNode::GainNode(const std::shared_ptr<BaseAudioContext> &context, const GainOptions &options)
|
|
12
12
|
: AudioNode(context, options),
|
|
13
13
|
gainParam_(
|
|
14
14
|
std::make_shared<AudioParam>(
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
namespace audioapi {
|
|
9
9
|
|
|
10
10
|
class AudioBus;
|
|
11
|
-
|
|
11
|
+
struct GainOptions;
|
|
12
12
|
|
|
13
13
|
class GainNode : public AudioNode {
|
|
14
14
|
public:
|
|
15
|
-
explicit GainNode(std::shared_ptr<BaseAudioContext> context, const GainOptions &options);
|
|
15
|
+
explicit GainNode(const std::shared_ptr<BaseAudioContext> &context, const GainOptions &options);
|
|
16
16
|
|
|
17
17
|
[[nodiscard]] std::shared_ptr<AudioParam> getGainParam() const;
|
|
18
18
|
|
|
@@ -36,10 +36,12 @@
|
|
|
36
36
|
|
|
37
37
|
namespace audioapi {
|
|
38
38
|
|
|
39
|
-
IIRFilterNode::IIRFilterNode(
|
|
39
|
+
IIRFilterNode::IIRFilterNode(
|
|
40
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
41
|
+
const IIRFilterOptions &options)
|
|
40
42
|
: AudioNode(context, options),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
feedforward_(std::move(options.feedforward)),
|
|
44
|
+
feedback_(std::move(options.feedback)) {
|
|
43
45
|
|
|
44
46
|
int maxChannels = MAX_CHANNEL_COUNT;
|
|
45
47
|
xBuffers_.resize(maxChannels);
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
|
|
34
34
|
namespace audioapi {
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
struct IIRFilterOptions;
|
|
37
37
|
|
|
38
38
|
class IIRFilterNode : public AudioNode {
|
|
39
39
|
|
|
40
40
|
public:
|
|
41
41
|
explicit IIRFilterNode(
|
|
42
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
42
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
43
43
|
const IIRFilterOptions &options);
|
|
44
44
|
|
|
45
45
|
void getFrequencyResponse(
|
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
namespace audioapi {
|
|
12
12
|
|
|
13
|
-
StereoPannerNode::StereoPannerNode(
|
|
14
|
-
|
|
13
|
+
StereoPannerNode::StereoPannerNode(
|
|
14
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
15
|
+
const StereoPannerOptions &options)
|
|
16
|
+
: AudioNode(context, options),
|
|
17
|
+
panParam_(std::make_shared<AudioParam>(options.pan, -1.0f, 1.0f, context)) {
|
|
15
18
|
isInitialized_ = true;
|
|
16
19
|
}
|
|
17
20
|
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
namespace audioapi {
|
|
11
11
|
|
|
12
12
|
class AudioBus;
|
|
13
|
-
|
|
13
|
+
struct StereoPannerOptions;
|
|
14
14
|
|
|
15
15
|
class StereoPannerNode : public AudioNode {
|
|
16
16
|
public:
|
|
17
17
|
explicit StereoPannerNode(
|
|
18
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
18
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
19
19
|
const StereoPannerOptions &options);
|
|
20
20
|
|
|
21
21
|
[[nodiscard]] std::shared_ptr<AudioParam> getPanParam() const;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
#include <audioapi/HostObjects/utils/NodeOptions.h>
|
|
1
2
|
#include <audioapi/core/BaseAudioContext.h>
|
|
2
3
|
#include <audioapi/core/effects/WaveShaperNode.h>
|
|
3
4
|
#include <audioapi/dsp/VectorMath.h>
|
|
4
5
|
#include <audioapi/utils/AudioArray.h>
|
|
5
6
|
#include <audioapi/utils/AudioBus.h>
|
|
6
|
-
#include <audioapi/HostObjects/utils/NodeOptions.h>
|
|
7
7
|
|
|
8
8
|
#include <algorithm>
|
|
9
9
|
#include <memory>
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
namespace audioapi {
|
|
13
13
|
|
|
14
|
-
WaveShaperNode::WaveShaperNode(
|
|
14
|
+
WaveShaperNode::WaveShaperNode(
|
|
15
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
16
|
+
const WaveShaperOptions &options)
|
|
15
17
|
: AudioNode(context, options), oversample_(options.oversample) {
|
|
16
18
|
|
|
17
19
|
waveShapers_.reserve(6);
|
|
@@ -16,12 +16,12 @@ namespace audioapi {
|
|
|
16
16
|
|
|
17
17
|
class AudioBus;
|
|
18
18
|
class AudioArray;
|
|
19
|
-
|
|
19
|
+
struct WaveShaperOptions;
|
|
20
20
|
|
|
21
21
|
class WaveShaperNode : public AudioNode {
|
|
22
22
|
public:
|
|
23
23
|
explicit WaveShaperNode(
|
|
24
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
24
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
25
25
|
const WaveShaperOptions &options);
|
|
26
26
|
|
|
27
27
|
[[nodiscard]] OverSampleType getOversample() const;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
namespace audioapi {
|
|
14
14
|
AudioBufferBaseSourceNode::AudioBufferBaseSourceNode(
|
|
15
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
15
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
16
16
|
const BaseAudioBufferSourceOptions &options)
|
|
17
17
|
: AudioScheduledSourceNode(context),
|
|
18
18
|
pitchCorrection_(options.pitchCorrection),
|
|
@@ -42,7 +42,7 @@ void AudioBufferBaseSourceNode::setOnPositionChangedCallbackId(uint64_t callback
|
|
|
42
42
|
auto oldCallbackId = onPositionChangedCallbackId_.exchange(callbackId, std::memory_order_acq_rel);
|
|
43
43
|
|
|
44
44
|
if (oldCallbackId != 0) {
|
|
45
|
-
audioEventHandlerRegistry_->unregisterHandler(
|
|
45
|
+
audioEventHandlerRegistry_->unregisterHandler(AudioEvent::POSITION_CHANGED, oldCallbackId);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -90,7 +90,7 @@ void AudioBufferBaseSourceNode::sendOnPositionChangedEvent() {
|
|
|
90
90
|
std::unordered_map<std::string, EventValue> body = {{"value", getCurrentPosition()}};
|
|
91
91
|
|
|
92
92
|
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
93
|
-
|
|
93
|
+
AudioEvent::POSITION_CHANGED, onPositionChangedCallbackId, body);
|
|
94
94
|
|
|
95
95
|
onPositionChangedTime_ = 0;
|
|
96
96
|
}
|
|
@@ -157,7 +157,13 @@ void AudioBufferBaseSourceNode::processWithoutPitchCorrection(
|
|
|
157
157
|
}
|
|
158
158
|
auto computedPlaybackRate =
|
|
159
159
|
getComputedPlaybackRateValue(framesToProcess, context->getCurrentTime());
|
|
160
|
-
updatePlaybackInfo(
|
|
160
|
+
updatePlaybackInfo(
|
|
161
|
+
processingBus,
|
|
162
|
+
framesToProcess,
|
|
163
|
+
startOffset,
|
|
164
|
+
offsetLength,
|
|
165
|
+
context->getSampleRate(),
|
|
166
|
+
context->getCurrentSampleFrame());
|
|
161
167
|
|
|
162
168
|
if (computedPlaybackRate == 0.0f || (!isPlaying() && !isStopScheduled())) {
|
|
163
169
|
processingBus->zero();
|
|
@@ -11,12 +11,12 @@ namespace audioapi {
|
|
|
11
11
|
|
|
12
12
|
class AudioBus;
|
|
13
13
|
class AudioParam;
|
|
14
|
-
|
|
14
|
+
struct BaseAudioBufferSourceOptions;
|
|
15
15
|
|
|
16
16
|
class AudioBufferBaseSourceNode : public AudioScheduledSourceNode {
|
|
17
17
|
public:
|
|
18
18
|
explicit AudioBufferBaseSourceNode(
|
|
19
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
19
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
20
20
|
const BaseAudioBufferSourceOptions &options);
|
|
21
21
|
|
|
22
22
|
[[nodiscard]] std::shared_ptr<AudioParam> getDetuneParam() const;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
namespace audioapi {
|
|
20
20
|
|
|
21
21
|
AudioBufferQueueSourceNode::AudioBufferQueueSourceNode(
|
|
22
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
22
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
23
23
|
const BaseAudioBufferSourceOptions &options)
|
|
24
24
|
: AudioBufferBaseSourceNode(context, options) {
|
|
25
25
|
buffers_ = {};
|
|
@@ -130,11 +130,11 @@ void AudioBufferQueueSourceNode::disable() {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
void AudioBufferQueueSourceNode::setOnBufferEndedCallbackId(uint64_t callbackId) {
|
|
133
|
-
|
|
133
|
+
auto oldCallbackId = onBufferEndedCallbackId_.exchange(callbackId, std::memory_order_acq_rel);
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
if (oldCallbackId != 0) {
|
|
136
|
+
audioEventHandlerRegistry_->unregisterHandler(AudioEvent::BUFFER_ENDED, oldCallbackId);
|
|
137
|
+
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
std::shared_ptr<AudioBus> AudioBufferQueueSourceNode::processNode(
|
|
@@ -171,15 +171,15 @@ double AudioBufferQueueSourceNode::getCurrentPosition() const {
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
void AudioBufferQueueSourceNode::sendOnBufferEndedEvent(size_t bufferId, bool isLastBufferInQueue) {
|
|
174
|
-
|
|
174
|
+
auto onBufferEndedCallbackId = onBufferEndedCallbackId_.load(std::memory_order_acquire);
|
|
175
175
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
if (onBufferEndedCallbackId != 0) {
|
|
177
|
+
std::unordered_map<std::string, EventValue> body = {
|
|
178
|
+
{"bufferId", std::to_string(bufferId)}, {"isLastBufferInQueue", isLastBufferInQueue}};
|
|
179
179
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
181
|
+
AudioEvent::BUFFER_ENDED, onBufferEndedCallbackId, body);
|
|
182
|
+
}
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
@@ -221,7 +221,7 @@ void AudioBufferQueueSourceNode::processWithoutInterpolation(
|
|
|
221
221
|
buffers_.pop();
|
|
222
222
|
|
|
223
223
|
if (!(buffers_.empty() && addExtraTailFrames_)) {
|
|
224
|
-
|
|
224
|
+
sendOnBufferEndedEvent(bufferId, buffers_.empty());
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
if (buffers_.empty()) {
|
|
@@ -14,12 +14,12 @@ namespace audioapi {
|
|
|
14
14
|
|
|
15
15
|
class AudioBus;
|
|
16
16
|
class AudioParam;
|
|
17
|
-
|
|
17
|
+
struct BaseAudioBufferSourceOptions;
|
|
18
18
|
|
|
19
19
|
class AudioBufferQueueSourceNode : public AudioBufferBaseSourceNode {
|
|
20
20
|
public:
|
|
21
21
|
explicit AudioBufferQueueSourceNode(
|
|
22
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
22
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
23
23
|
const BaseAudioBufferSourceOptions &options);
|
|
24
24
|
~AudioBufferQueueSourceNode() override;
|
|
25
25
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
namespace audioapi {
|
|
15
15
|
|
|
16
16
|
AudioBufferSourceNode::AudioBufferSourceNode(
|
|
17
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
17
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
18
18
|
const AudioBufferSourceOptions &options)
|
|
19
19
|
: AudioBufferBaseSourceNode(context, options),
|
|
20
20
|
loop_(options.loop),
|
|
@@ -105,8 +105,8 @@ void AudioBufferSourceNode::setBuffer(const std::shared_ptr<AudioBuffer> &buffer
|
|
|
105
105
|
}
|
|
106
106
|
audioBus_ =
|
|
107
107
|
std::make_shared<AudioBus>(RENDER_QUANTUM_SIZE, channelCount_, context->getSampleRate());
|
|
108
|
-
playbackRateBus_ =
|
|
109
|
-
RENDER_QUANTUM_SIZE * 3, channelCount_, context->getSampleRate());
|
|
108
|
+
playbackRateBus_ =
|
|
109
|
+
std::make_shared<AudioBus>(RENDER_QUANTUM_SIZE * 3, channelCount_, context->getSampleRate());
|
|
110
110
|
|
|
111
111
|
loopEnd_ = buffer_->getDuration();
|
|
112
112
|
}
|
|
@@ -141,7 +141,7 @@ void AudioBufferSourceNode::setOnLoopEndedCallbackId(uint64_t callbackId) {
|
|
|
141
141
|
auto oldCallbackId = onLoopEndedCallbackId_.exchange(callbackId, std::memory_order_acq_rel);
|
|
142
142
|
|
|
143
143
|
if (oldCallbackId != 0) {
|
|
144
|
-
audioEventHandlerRegistry_->unregisterHandler(
|
|
144
|
+
audioEventHandlerRegistry_->unregisterHandler(AudioEvent::LOOP_ENDED, oldCallbackId);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -176,7 +176,8 @@ double AudioBufferSourceNode::getCurrentPosition() const {
|
|
|
176
176
|
void AudioBufferSourceNode::sendOnLoopEndedEvent() {
|
|
177
177
|
auto onLoopEndedCallbackId = onLoopEndedCallbackId_.load(std::memory_order_acquire);
|
|
178
178
|
if (onLoopEndedCallbackId != 0) {
|
|
179
|
-
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
179
|
+
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
180
|
+
AudioEvent::LOOP_ENDED, onLoopEndedCallbackId, {});
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
|
|
@@ -13,12 +13,12 @@ namespace audioapi {
|
|
|
13
13
|
|
|
14
14
|
class AudioBus;
|
|
15
15
|
class AudioParam;
|
|
16
|
-
|
|
16
|
+
struct AudioBufferSourceOptions;
|
|
17
17
|
|
|
18
18
|
class AudioBufferSourceNode : public AudioBufferBaseSourceNode {
|
|
19
19
|
public:
|
|
20
20
|
explicit AudioBufferSourceNode(
|
|
21
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
21
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
22
22
|
const AudioBufferSourceOptions &options);
|
|
23
23
|
~AudioBufferSourceNode() override;
|
|
24
24
|
|
|
@@ -66,7 +66,7 @@ void AudioScheduledSourceNode::setOnEndedCallbackId(const uint64_t callbackId) {
|
|
|
66
66
|
auto oldCallbackId = onEndedCallbackId_.exchange(callbackId, std::memory_order_acq_rel);
|
|
67
67
|
|
|
68
68
|
if (oldCallbackId != 0) {
|
|
69
|
-
audioEventHandlerRegistry_->unregisterHandler(
|
|
69
|
+
audioEventHandlerRegistry_->unregisterHandler(AudioEvent::ENDED, oldCallbackId);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -167,7 +167,7 @@ void AudioScheduledSourceNode::disable() {
|
|
|
167
167
|
|
|
168
168
|
auto onEndedCallbackId = onEndedCallbackId_.load(std::memory_order_acquire);
|
|
169
169
|
if (onEndedCallbackId != 0) {
|
|
170
|
-
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
170
|
+
audioEventHandlerRegistry_->invokeHandlerWithEventBody(AudioEvent::ENDED, onEndedCallbackId, {});
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
#include <memory>
|
|
8
8
|
|
|
9
9
|
namespace audioapi {
|
|
10
|
-
ConstantSourceNode::ConstantSourceNode(
|
|
10
|
+
ConstantSourceNode::ConstantSourceNode(
|
|
11
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
12
|
+
const ConstantSourceOptions &options)
|
|
11
13
|
: AudioScheduledSourceNode(context) {
|
|
12
14
|
offsetParam_ = std::make_shared<AudioParam>(
|
|
13
15
|
options.offset, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
|
|
@@ -30,7 +32,13 @@ std::shared_ptr<AudioBus> ConstantSourceNode::processNode(
|
|
|
30
32
|
return processingBus;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
updatePlaybackInfo(
|
|
35
|
+
updatePlaybackInfo(
|
|
36
|
+
processingBus,
|
|
37
|
+
framesToProcess,
|
|
38
|
+
startOffset,
|
|
39
|
+
offsetLength,
|
|
40
|
+
context->getSampleRate(),
|
|
41
|
+
context->getCurrentSampleFrame());
|
|
34
42
|
|
|
35
43
|
if (!isPlaying() && !isStopScheduled()) {
|
|
36
44
|
processingBus->zero();
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
namespace audioapi {
|
|
11
11
|
|
|
12
12
|
class AudioBus;
|
|
13
|
-
|
|
13
|
+
struct ConstantSourceOptions;
|
|
14
14
|
|
|
15
15
|
class ConstantSourceNode : public AudioScheduledSourceNode {
|
|
16
16
|
public:
|
|
17
17
|
explicit ConstantSourceNode(
|
|
18
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
18
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
19
19
|
const ConstantSourceOptions &options);
|
|
20
20
|
|
|
21
21
|
[[nodiscard]] std::shared_ptr<AudioParam> getOffsetParam() const;
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
|
|
10
10
|
namespace audioapi {
|
|
11
11
|
|
|
12
|
-
OscillatorNode::OscillatorNode(
|
|
12
|
+
OscillatorNode::OscillatorNode(
|
|
13
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
14
|
+
const OscillatorOptions &options)
|
|
13
15
|
: AudioScheduledSourceNode(context) {
|
|
14
16
|
frequencyParam_ = std::make_shared<AudioParam>(
|
|
15
|
-
options.frequency,
|
|
16
|
-
-context->getNyquistFrequency(),
|
|
17
|
-
context->getNyquistFrequency(),
|
|
18
|
-
context);
|
|
17
|
+
options.frequency, -context->getNyquistFrequency(), context->getNyquistFrequency(), context);
|
|
19
18
|
detuneParam_ = std::make_shared<AudioParam>(
|
|
20
19
|
options.detune,
|
|
21
20
|
-1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
|
|
@@ -69,7 +68,13 @@ std::shared_ptr<AudioBus> OscillatorNode::processNode(
|
|
|
69
68
|
return processingBus;
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
updatePlaybackInfo(
|
|
71
|
+
updatePlaybackInfo(
|
|
72
|
+
processingBus,
|
|
73
|
+
framesToProcess,
|
|
74
|
+
startOffset,
|
|
75
|
+
offsetLength,
|
|
76
|
+
context->getSampleRate(),
|
|
77
|
+
context->getCurrentSampleFrame());
|
|
73
78
|
|
|
74
79
|
if (!isPlaying() && !isStopScheduled()) {
|
|
75
80
|
processingBus->zero();
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
namespace audioapi {
|
|
14
14
|
|
|
15
15
|
class AudioBus;
|
|
16
|
-
|
|
16
|
+
struct OscillatorOptions;
|
|
17
17
|
|
|
18
18
|
class OscillatorNode : public AudioScheduledSourceNode {
|
|
19
19
|
public:
|
|
20
20
|
explicit OscillatorNode(
|
|
21
|
-
std::shared_ptr<BaseAudioContext> context,
|
|
21
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
22
22
|
const OscillatorOptions &options);
|
|
23
23
|
|
|
24
24
|
[[nodiscard]] std::shared_ptr<AudioParam> getFrequencyParam() const;
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
namespace audioapi {
|
|
25
25
|
#if !RN_AUDIO_API_FFMPEG_DISABLED
|
|
26
|
-
StreamerNode::StreamerNode(
|
|
26
|
+
StreamerNode::StreamerNode(
|
|
27
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
28
|
+
const StreamerOptions &options)
|
|
27
29
|
: AudioScheduledSourceNode(context),
|
|
28
30
|
fmtCtx_(nullptr),
|
|
29
31
|
codecCtx_(nullptr),
|
|
@@ -38,7 +40,10 @@ StreamerNode::StreamerNode(std::shared_ptr<BaseAudioContext> context, const Stre
|
|
|
38
40
|
maxResampledSamples_(0),
|
|
39
41
|
processedSamples_(0) {}
|
|
40
42
|
#else
|
|
41
|
-
StreamerNode::StreamerNode(
|
|
43
|
+
StreamerNode::StreamerNode(
|
|
44
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
45
|
+
const StreamerOptions &options)
|
|
46
|
+
: AudioScheduledSourceNode(context) {}
|
|
42
47
|
#endif // RN_AUDIO_API_FFMPEG_DISABLED
|
|
43
48
|
|
|
44
49
|
StreamerNode::~StreamerNode() {
|
|
@@ -112,7 +117,13 @@ std::shared_ptr<AudioBus> StreamerNode::processNode(
|
|
|
112
117
|
processingBus->zero();
|
|
113
118
|
return processingBus;
|
|
114
119
|
}
|
|
115
|
-
updatePlaybackInfo(
|
|
120
|
+
updatePlaybackInfo(
|
|
121
|
+
processingBus,
|
|
122
|
+
framesToProcess,
|
|
123
|
+
startOffset,
|
|
124
|
+
offsetLength,
|
|
125
|
+
context->getSampleRate(),
|
|
126
|
+
context->getCurrentSampleFrame());
|
|
116
127
|
isNodeFinished_.store(isFinished(), std::memory_order_release);
|
|
117
128
|
|
|
118
129
|
if (!isPlaying() && !isStopScheduled()) {
|
|
@@ -217,7 +228,9 @@ void StreamerNode::streamAudio() {
|
|
|
217
228
|
}
|
|
218
229
|
}
|
|
219
230
|
|
|
220
|
-
bool StreamerNode::processFrameWithResampler(
|
|
231
|
+
bool StreamerNode::processFrameWithResampler(
|
|
232
|
+
AVFrame *frame,
|
|
233
|
+
std::shared_ptr<BaseAudioContext> context) {
|
|
221
234
|
// Check if we need to reallocate the resampled buffer
|
|
222
235
|
int out_samples = swr_get_out_samples(swrCtx_, frame->nb_samples);
|
|
223
236
|
if (out_samples > maxResampledSamples_) {
|
|
@@ -59,11 +59,13 @@ struct StreamingData {
|
|
|
59
59
|
namespace audioapi {
|
|
60
60
|
|
|
61
61
|
class AudioBus;
|
|
62
|
-
|
|
62
|
+
struct StreamerOptions;
|
|
63
63
|
|
|
64
64
|
class StreamerNode : public AudioScheduledSourceNode {
|
|
65
65
|
public:
|
|
66
|
-
explicit StreamerNode(
|
|
66
|
+
explicit StreamerNode(
|
|
67
|
+
const std::shared_ptr<BaseAudioContext> &context,
|
|
68
|
+
const StreamerOptions &options);
|
|
67
69
|
~StreamerNode() override;
|
|
68
70
|
|
|
69
71
|
/**
|
|
@@ -29,9 +29,8 @@ void AudioFileWriter::invokeOnErrorCallback(const std::string &message) {
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
std::unordered_map<std::string, EventValue> eventPayload = {};
|
|
33
|
-
|
|
34
|
-
audioEventHandlerRegistry_->invokeHandlerWithEventBody("error", callbackId, eventPayload);
|
|
32
|
+
std::unordered_map<std::string, EventValue> eventPayload = {{"message", message}};
|
|
33
|
+
audioEventHandlerRegistry_->invokeHandlerWithEventBody(AudioEvent::RECORDER_ERROR, callbackId, eventPayload);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
bool AudioFileWriter::isFileOpen() {
|
|
@@ -76,7 +76,7 @@ void AudioRecorderCallback::invokeCallback(const std::shared_ptr<AudioBus> &bus,
|
|
|
76
76
|
eventPayload.insert({"numFrames", numFrames});
|
|
77
77
|
|
|
78
78
|
if (audioEventHandlerRegistry_) {
|
|
79
|
-
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
79
|
+
audioEventHandlerRegistry_->invokeHandlerWithEventBody(AudioEvent::AUDIO_READY, callbackId_, eventPayload);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -97,9 +97,8 @@ void AudioRecorderCallback::invokeOnErrorCallback(const std::string &message) {
|
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
std::unordered_map<std::string, EventValue> eventPayload = {};
|
|
101
|
-
|
|
102
|
-
audioEventHandlerRegistry_->invokeHandlerWithEventBody("error", callbackId, eventPayload);
|
|
100
|
+
std::unordered_map<std::string, EventValue> eventPayload = {{"message", message}};
|
|
101
|
+
audioEventHandlerRegistry_->invokeHandlerWithEventBody(AudioEvent::RECORDER_ERROR, callbackId, eventPayload);
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
} // namespace audioapi
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
|
|
5
|
+
enum class AudioEvent {
|
|
6
|
+
PLAYBACK_NOTIFICATION_PLAY,
|
|
7
|
+
PLAYBACK_NOTIFICATION_PAUSE,
|
|
8
|
+
PLAYBACK_NOTIFICATION_STOP,
|
|
9
|
+
PLAYBACK_NOTIFICATION_NEXT_TRACK,
|
|
10
|
+
PLAYBACK_NOTIFICATION_PREVIOUS_TRACK,
|
|
11
|
+
PLAYBACK_NOTIFICATION_SKIP_FORWARD,
|
|
12
|
+
PLAYBACK_NOTIFICATION_SKIP_BACKWARD,
|
|
13
|
+
PLAYBACK_NOTIFICATION_SEEK_FORWARD,
|
|
14
|
+
PLAYBACK_NOTIFICATION_SEEK_BACKWARD,
|
|
15
|
+
PLAYBACK_NOTIFICATION_SEEK_TO,
|
|
16
|
+
PLAYBACK_NOTIFICATION_DISMISSED,
|
|
17
|
+
RECORDING_NOTIFICATION_RESUME,
|
|
18
|
+
RECORDING_NOTIFICATION_PAUSE,
|
|
19
|
+
ROUTE_CHANGE,
|
|
20
|
+
INTERRUPTION,
|
|
21
|
+
VOLUME_CHANGE,
|
|
22
|
+
DUCK,
|
|
23
|
+
ENDED,
|
|
24
|
+
LOOP_ENDED,
|
|
25
|
+
AUDIO_READY,
|
|
26
|
+
POSITION_CHANGED,
|
|
27
|
+
BUFFER_ENDED,
|
|
28
|
+
RECORDER_ERROR,
|
|
29
|
+
};
|
|
30
|
+
} // namespace audioapi
|