react-native-audio-api 0.4.15 → 0.4.16
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.
|
@@ -16,8 +16,7 @@ AudioBufferSourceNode::AudioBufferSourceNode(BaseAudioContext *context)
|
|
|
16
16
|
loopEnd_(0),
|
|
17
17
|
vReadIndex_(0.0) {
|
|
18
18
|
buffer_ = std::shared_ptr<AudioBuffer>(nullptr);
|
|
19
|
-
alignedBus_ = std::
|
|
20
|
-
RENDER_QUANTUM_SIZE, 1, context_->getSampleRate());
|
|
19
|
+
alignedBus_ = std::shared_ptr<AudioBus>(nullptr);
|
|
21
20
|
|
|
22
21
|
detuneParam_ = std::make_shared<AudioParam>(0.0, MIN_DETUNE, MAX_DETUNE);
|
|
23
22
|
playbackRateParam_ = std::make_shared<AudioParam>(
|
|
@@ -26,6 +25,13 @@ AudioBufferSourceNode::AudioBufferSourceNode(BaseAudioContext *context)
|
|
|
26
25
|
isInitialized_ = true;
|
|
27
26
|
}
|
|
28
27
|
|
|
28
|
+
AudioBufferSourceNode::~AudioBufferSourceNode() {
|
|
29
|
+
Locker locker(getBufferLock());
|
|
30
|
+
|
|
31
|
+
buffer_ = std::shared_ptr<AudioBuffer>(nullptr);
|
|
32
|
+
alignedBus_ = std::shared_ptr<AudioBus>(nullptr);
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
bool AudioBufferSourceNode::getLoop() const {
|
|
30
36
|
return loop_;
|
|
31
37
|
}
|
|
@@ -69,8 +75,7 @@ void AudioBufferSourceNode::setBuffer(
|
|
|
69
75
|
|
|
70
76
|
if (!buffer) {
|
|
71
77
|
buffer_ = std::shared_ptr<AudioBuffer>(nullptr);
|
|
72
|
-
alignedBus_ = std::
|
|
73
|
-
RENDER_QUANTUM_SIZE, 1, context_->getSampleRate());
|
|
78
|
+
alignedBus_ = std::shared_ptr<AudioBus>(nullptr);
|
|
74
79
|
loopEnd_ = 0;
|
|
75
80
|
return;
|
|
76
81
|
}
|
|
@@ -80,6 +85,7 @@ void AudioBufferSourceNode::setBuffer(
|
|
|
80
85
|
|
|
81
86
|
alignedBus_ = std::make_shared<AudioBus>(
|
|
82
87
|
buffer_->getLength(), channelCount_, context_->getSampleRate());
|
|
88
|
+
|
|
83
89
|
alignedBus_->zero();
|
|
84
90
|
alignedBus_->sum(buffer_->bus_.get());
|
|
85
91
|
|
|
@@ -116,13 +122,13 @@ std::mutex &AudioBufferSourceNode::getBufferLock() {
|
|
|
116
122
|
void AudioBufferSourceNode::processNode(
|
|
117
123
|
const std::shared_ptr<AudioBus> &processingBus,
|
|
118
124
|
int framesToProcess) {
|
|
119
|
-
|
|
120
|
-
if (!buffer_) {
|
|
125
|
+
if (!Locker::tryLock(getBufferLock())) {
|
|
121
126
|
processingBus->zero();
|
|
122
127
|
return;
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
|
|
130
|
+
// No audio data to fill, zero the output and return.
|
|
131
|
+
if (!buffer_) {
|
|
126
132
|
processingBus->zero();
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
@@ -179,6 +185,11 @@ void AudioBufferSourceNode::processWithoutInterpolation(
|
|
|
179
185
|
size_t framesToCopy = std::min(framesToEnd, framesLeft);
|
|
180
186
|
framesToCopy = framesToCopy > 0 ? framesToCopy : 0;
|
|
181
187
|
|
|
188
|
+
assert(readIndex >= 0);
|
|
189
|
+
assert(writeIndex >= 0);
|
|
190
|
+
assert(readIndex + framesToCopy <= alignedBus_->getSize());
|
|
191
|
+
assert(writeIndex + framesToCopy <= processingBus->getSize());
|
|
192
|
+
|
|
182
193
|
// Direction is forward, we can normally copy the data
|
|
183
194
|
if (direction == 1) {
|
|
184
195
|
processingBus->copy(
|
|
@@ -16,6 +16,7 @@ class AudioParam;
|
|
|
16
16
|
class AudioBufferSourceNode : public AudioScheduledSourceNode {
|
|
17
17
|
public:
|
|
18
18
|
explicit AudioBufferSourceNode(BaseAudioContext *context);
|
|
19
|
+
~AudioBufferSourceNode();
|
|
19
20
|
|
|
20
21
|
[[nodiscard]] bool getLoop() const;
|
|
21
22
|
[[nodiscard]] double getLoopStart() const;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.16",
|
|
4
4
|
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification",
|
|
5
5
|
"bin": {
|
|
6
6
|
"setup-custom-wasm": "./scripts/setup-custom-wasm.js"
|