sfml.js 1.0.0-rc.2 → 1.1.0
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/README.ja.md +16 -11
- package/README.ko.md +16 -11
- package/README.md +16 -11
- package/README.zh-CN.md +16 -11
- package/assets/breakout.png +0 -0
- package/binding.gyp +23 -16
- package/dist/audio/effect-processor.js +9 -3
- package/dist/audio/input-sound-file.js +41 -15
- package/dist/audio/listener.js +33 -11
- package/dist/audio/music.js +41 -18
- package/dist/audio/output-sound-file.js +4 -2
- package/dist/audio/playback-device.js +11 -3
- package/dist/audio/sound-buffer-recorder.js +8 -5
- package/dist/audio/sound-buffer.js +40 -17
- package/dist/audio/sound-file-factory.js +21 -9
- package/dist/audio/sound-file-reader.js +21 -7
- package/dist/audio/sound-recorder.js +36 -15
- package/dist/audio/sound-source.js +117 -40
- package/dist/audio/sound-stream.js +14 -5
- package/dist/audio/sound.js +9 -4
- package/dist/audio/value.js +42 -16
- package/dist/graphics/blend-mode.js +2 -1
- package/dist/graphics/boolean-vector.d.ts +1 -2
- package/dist/graphics/boolean-vector.js +19 -9
- package/dist/graphics/color.js +2 -1
- package/dist/graphics/convex-shape.js +7 -3
- package/dist/graphics/font.js +52 -23
- package/dist/graphics/glsl-matrix.js +8 -3
- package/dist/graphics/glsl.js +47 -16
- package/dist/graphics/glyph.js +27 -10
- package/dist/graphics/image.js +30 -14
- package/dist/graphics/rect.js +15 -8
- package/dist/graphics/render-states.js +18 -9
- package/dist/graphics/render-target.js +49 -23
- package/dist/graphics/render-texture.js +24 -12
- package/dist/graphics/render-window.js +6 -3
- package/dist/graphics/shader.js +67 -32
- package/dist/graphics/shape.js +25 -13
- package/dist/graphics/sprite.js +19 -9
- package/dist/graphics/stencil-mode.js +10 -6
- package/dist/graphics/swap.js +2 -1
- package/dist/graphics/text.js +123 -48
- package/dist/graphics/texture.js +48 -24
- package/dist/graphics/transform.js +29 -13
- package/dist/graphics/transformable.js +2 -1
- package/dist/graphics/vertex-array.js +40 -18
- package/dist/graphics/vertex-buffer.js +39 -19
- package/dist/graphics/vertex.js +6 -3
- package/dist/graphics/view.js +30 -14
- package/dist/index.d.ts +4 -4
- package/dist/internal/audio-codec-registry.js +12 -6
- package/dist/internal/audio-input-stream.js +2 -1
- package/dist/internal/audio-music-pump.js +58 -24
- package/dist/internal/audio-recorder-session.js +17 -7
- package/dist/internal/audio-worker-session.js +28 -10
- package/dist/internal/audio-worker.js +40 -21
- package/dist/internal/glsl-value.d.ts +3 -1
- package/dist/internal/glsl-value.js +18 -8
- package/dist/internal/graphics-state.js +29 -15
- package/dist/internal/input-stream.d.ts +3 -1
- package/dist/internal/input-stream.js +16 -7
- package/dist/internal/numeric-properties.js +2 -1
- package/dist/internal/render-states.js +2 -1
- package/dist/internal/scalar.js +22 -13
- package/dist/internal/shaped-glyph.d.ts +3 -1
- package/dist/internal/shaped-glyph.js +12 -4
- package/dist/internal/struct-view.d.ts +3 -1
- package/dist/internal/struct-view.js +3 -1
- package/dist/internal/transformable.js +2 -1
- package/dist/network/common.js +23 -11
- package/dist/network/dns.js +25 -17
- package/dist/network/ftp.js +43 -18
- package/dist/network/http.js +126 -56
- package/dist/network/ip-address.js +50 -25
- package/dist/network/packet.js +63 -25
- package/dist/network/sftp.js +175 -74
- package/dist/network/socket-selector.js +28 -14
- package/dist/network/socket.js +71 -30
- package/dist/network/tcp-listener.js +42 -19
- package/dist/network/tcp-socket.js +111 -53
- package/dist/network/tls-material.js +2 -1
- package/dist/network/udp-socket.js +68 -33
- package/dist/system/angle.js +2 -1
- package/dist/system/clock.js +4 -2
- package/dist/system/err.js +5 -2
- package/dist/system/file-input-stream.js +8 -4
- package/dist/system/input-stream.js +6 -3
- package/dist/system/operators.d.ts +1 -1
- package/dist/system/operators.js +90 -50
- package/dist/system/sleep.js +4 -2
- package/dist/system/time.js +12 -6
- package/dist/system/vector2.js +6 -7
- package/dist/system/vector3.js +11 -6
- package/dist/window/clipboard.js +2 -1
- package/dist/window/context.js +10 -5
- package/dist/window/cursor.js +2 -1
- package/dist/window/event.js +9 -5
- package/dist/window/mouse.js +4 -2
- package/dist/window/video-mode.js +2 -1
- package/dist/window/window.js +19 -12
- package/native/addon.cc +25 -12
- package/native/audio-binding.cc +266 -126
- package/native/audio-codec-binding.cc +147 -77
- package/native/audio-device-binding.cc +76 -49
- package/native/audio-file-binding.cc +116 -67
- package/native/audio-recorder-binding.cc +147 -98
- package/native/audio-recorder.h +1 -1
- package/native/audio-state.h +53 -30
- package/native/audio-stream-binding.cc +148 -94
- package/native/audio-stream.h +5 -4
- package/native/audio-worker-binding.cc +163 -81
- package/native/audio-worker.h +35 -19
- package/native/batch-drawable.cc +29 -16
- package/native/batch-drawable.h +11 -8
- package/native/context-binding.cc +40 -27
- package/native/context-settings.h +15 -8
- package/native/deferred-delete.cc +9 -6
- package/native/deferred-delete.h +7 -8
- package/native/error-stream-binding.cc +42 -28
- package/native/font-binding.cc +89 -48
- package/native/graphics-binding.cc +122 -72
- package/native/graphics-state.h +50 -36
- package/native/image-binding.cc +38 -24
- package/native/image-state.h +26 -18
- package/native/input-binding.cc +42 -27
- package/native/render-window-binding.cc +38 -23
- package/native/shader-binding.cc +115 -50
- package/native/shape-binding.cc +94 -49
- package/native/shape-state.h +18 -9
- package/native/shaped-glyph-storage.h +9 -5
- package/native/stream-binding.cc +143 -117
- package/native/system-binding.cc +17 -12
- package/native/text-binding.cc +68 -35
- package/native/text-state.h +25 -18
- package/native/texture-binding.cc +42 -33
- package/native/texture-resource.h +20 -12
- package/native/time-value.h +3 -1
- package/native/transformable-binding.cc +12 -6
- package/native/transformable-state.h +6 -6
- package/native/value-binding.h +46 -28
- package/native/value-layout.h +10 -10
- package/native/values-binding.cc +29 -23
- package/native/vertex-binding.cc +18 -12
- package/native/vertex-buffer-binding.cc +38 -24
- package/native/vertex-storage.h +2 -2
- package/native/view-data.h +4 -3
- package/native/window-binding.cc +75 -45
- package/native/window-event.h +20 -11
- package/native/window-owner.h +15 -12
- package/package.json +43 -50
- package/src/audio/effect-processor.ts +9 -3
- package/src/audio/input-sound-file.ts +108 -36
- package/src/audio/listener.ts +39 -13
- package/src/audio/music.ts +112 -47
- package/src/audio/output-sound-file.ts +40 -11
- package/src/audio/playback-device.ts +23 -8
- package/src/audio/sound-buffer-recorder.ts +35 -13
- package/src/audio/sound-buffer.ts +166 -58
- package/src/audio/sound-file-factory.ts +127 -49
- package/src/audio/sound-file-reader.ts +49 -15
- package/src/audio/sound-recorder.ts +100 -34
- package/src/audio/sound-source.ts +142 -45
- package/src/audio/sound-stream.ts +15 -5
- package/src/audio/sound.ts +12 -4
- package/src/audio/value.ts +89 -26
- package/src/graphics/blend-mode.ts +3 -1
- package/src/graphics/boolean-vector.ts +56 -26
- package/src/graphics/color.ts +3 -1
- package/src/graphics/convex-shape.ts +10 -3
- package/src/graphics/font.ts +171 -50
- package/src/graphics/glsl-matrix.ts +9 -3
- package/src/graphics/glsl.ts +81 -35
- package/src/graphics/glyph.ts +67 -26
- package/src/graphics/image.ts +119 -45
- package/src/graphics/rect.ts +56 -24
- package/src/graphics/render-states.ts +31 -14
- package/src/graphics/render-target.ts +197 -81
- package/src/graphics/render-texture.ts +36 -12
- package/src/graphics/render-window.ts +9 -3
- package/src/graphics/shader.ts +186 -61
- package/src/graphics/shape.ts +93 -35
- package/src/graphics/sprite.ts +64 -25
- package/src/graphics/stencil-mode.ts +12 -6
- package/src/graphics/swap.ts +3 -2
- package/src/graphics/text.ts +229 -74
- package/src/graphics/texture.ts +180 -61
- package/src/graphics/transform.ts +132 -47
- package/src/graphics/transformable.ts +3 -1
- package/src/graphics/vertex-array.ts +87 -35
- package/src/graphics/vertex-buffer.ts +97 -33
- package/src/graphics/vertex.ts +9 -3
- package/src/graphics/view.ts +59 -21
- package/src/index.ts +101 -23
- package/src/internal/audio-codec-registry.ts +18 -6
- package/src/internal/audio-input-stream.ts +6 -2
- package/src/internal/audio-music-pump.ts +116 -41
- package/src/internal/audio-native.ts +249 -96
- package/src/internal/audio-recorder-session.ts +68 -24
- package/src/internal/audio-worker-session.ts +65 -21
- package/src/internal/audio-worker.ts +85 -41
- package/src/internal/glsl-value.ts +26 -11
- package/src/internal/graphics-state.ts +57 -20
- package/src/internal/input-stream.ts +23 -10
- package/src/internal/native.ts +252 -99
- package/src/internal/numeric-properties.ts +2 -1
- package/src/internal/render-states.ts +3 -1
- package/src/internal/scalar.ts +33 -14
- package/src/internal/shaped-glyph.ts +25 -12
- package/src/internal/struct-view.ts +40 -13
- package/src/internal/transformable.ts +3 -1
- package/src/network/common.ts +35 -11
- package/src/network/dns.ts +95 -38
- package/src/network/ftp.ts +129 -47
- package/src/network/http.ts +232 -77
- package/src/network/ip-address.ts +118 -48
- package/src/network/packet.ts +161 -54
- package/src/network/sftp.ts +498 -168
- package/src/network/socket-selector.ts +66 -26
- package/src/network/socket.ts +133 -46
- package/src/network/tcp-listener.ts +78 -29
- package/src/network/tcp-socket.ts +240 -95
- package/src/network/tls-material.ts +6 -2
- package/src/network/udp-socket.ts +147 -53
- package/src/system/angle.ts +3 -1
- package/src/system/clock.ts +12 -4
- package/src/system/err.ts +5 -2
- package/src/system/file-input-stream.ts +12 -4
- package/src/system/input-stream.ts +9 -3
- package/src/system/operators.ts +290 -115
- package/src/system/sleep.ts +6 -2
- package/src/system/time.ts +18 -6
- package/src/system/timeout-with-predicate.ts +19 -8
- package/src/system/vector2.ts +101 -49
- package/src/system/vector3.ts +85 -36
- package/src/window/clipboard.ts +3 -1
- package/src/window/context.ts +15 -5
- package/src/window/cursor.ts +3 -1
- package/src/window/event.ts +26 -12
- package/src/window/mouse.ts +6 -2
- package/src/window/video-mode.ts +3 -1
- package/src/window/window.ts +119 -37
- package/test/native/audio-probes.cc +74 -36
- package/test/native/deferred-delete-probes.cc +17 -11
- package/test/native/drawable-probes.cc +70 -36
- package/test/native/exception-probes.cc +14 -9
- package/test/native/image-probes.cc +20 -10
- package/test/native/matrix-probes.cc +8 -4
- package/test/native/network-oracle.cc +17 -11
- package/test/native/render-texture-probes.cc +33 -24
- package/test/native/shader-probes.cc +9 -9
- package/test/native/shape-probes.cc +37 -23
- package/test/native/sprite-probes.cc +41 -25
- package/test/native/system-probes.cc +58 -35
- package/test/native/text-probes.cc +77 -44
- package/test/native/texture-probes.cc +43 -26
- package/test/native/time-probes.cc +18 -12
- package/test/native/transform-probes.cc +15 -10
- package/test/native/transformable-probes.cc +23 -17
- package/test/native/value-oracle.h +9 -4
- package/test/native/value-probes.cc +31 -23
- package/test/native/vertex-array-probes.cc +22 -14
- package/test/native/vertex-buffer-probes.cc +28 -17
- package/test/native/view-probes.cc +29 -17
- package/test/native/window-probes.cc +66 -33
- package/tools/ensure-sfml.cjs +9 -0
- package/tools/generate-network-constants.cjs +11 -6
- package/tools/generate-window-constants.cjs +31 -12
- package/docs/README.ja.md +0 -30
- package/docs/README.ko.md +0 -30
- package/docs/README.md +0 -30
- package/docs/README.zh-CN.md +0 -30
- package/docs/api.ja.md +0 -84
- package/docs/api.ko.md +0 -84
- package/docs/api.md +0 -81
- package/docs/api.zh-CN.md +0 -81
- package/docs/audio.ja.md +0 -249
- package/docs/audio.ko.md +0 -251
- package/docs/audio.md +0 -252
- package/docs/audio.zh-CN.md +0 -252
- package/docs/concepts.ja.md +0 -130
- package/docs/concepts.ko.md +0 -130
- package/docs/concepts.md +0 -131
- package/docs/concepts.zh-CN.md +0 -131
- package/docs/development.ja.md +0 -148
- package/docs/development.ko.md +0 -148
- package/docs/development.md +0 -150
- package/docs/development.zh-CN.md +0 -150
- package/docs/getting-started.ja.md +0 -154
- package/docs/getting-started.ko.md +0 -154
- package/docs/getting-started.md +0 -156
- package/docs/getting-started.zh-CN.md +0 -156
- package/docs/graphics.ja.md +0 -256
- package/docs/graphics.ko.md +0 -254
- package/docs/graphics.md +0 -255
- package/docs/graphics.zh-CN.md +0 -257
- package/docs/network.ja.md +0 -214
- package/docs/network.ko.md +0 -216
- package/docs/network.md +0 -218
- package/docs/network.zh-CN.md +0 -218
- package/docs/system.ja.md +0 -169
- package/docs/system.ko.md +0 -171
- package/docs/system.md +0 -173
- package/docs/system.zh-CN.md +0 -173
- package/docs/window.ja.md +0 -138
- package/docs/window.ko.md +0 -140
- package/docs/window.md +0 -141
- package/docs/window.zh-CN.md +0 -141
- package/native/exception-boundary.h +0 -97
- package/native/numeric-fields.h +0 -96
- package/native/shared-handle.h +0 -69
- package/test/tsconfig.json +0 -8
- package/tools/configure-lsp.cjs +0 -23
- package/tools/lib_downloader.cjs +0 -92
- package/tools/lib_downloader_urls.cjs +0 -23
|
@@ -1,49 +1,67 @@
|
|
|
1
|
-
#include "audio-worker.h"
|
|
2
|
-
|
|
3
1
|
#include <limits>
|
|
4
2
|
#include <unordered_map>
|
|
5
3
|
|
|
4
|
+
#include "audio-worker.h"
|
|
5
|
+
|
|
6
6
|
namespace sfmljs::audio {
|
|
7
7
|
namespace {
|
|
8
8
|
std::mutex registryMutex;
|
|
9
9
|
std::unordered_map<std::uint64_t, std::weak_ptr<AudioWorkerState>> registry;
|
|
10
10
|
std::uint64_t nextToken{};
|
|
11
|
-
}
|
|
11
|
+
} // namespace
|
|
12
12
|
|
|
13
|
-
std::shared_ptr<AudioWorkerState> CreateWorkerState(
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
std::shared_ptr<AudioWorkerState> CreateWorkerState(unsigned kind,
|
|
14
|
+
unsigned frames,
|
|
15
|
+
unsigned channels,
|
|
16
|
+
unsigned rate,
|
|
17
|
+
unsigned slots) {
|
|
16
18
|
if (kind > 2 || frames < 64 || frames > 65536 || channels < 1 ||
|
|
17
19
|
channels > 32 || rate < 1 || slots < 2 || slots > 32) {
|
|
18
20
|
throw std::range_error("Invalid audio queue dimensions");
|
|
19
21
|
}
|
|
20
|
-
return std::make_shared<AudioWorkerState>(
|
|
22
|
+
return std::make_shared<AudioWorkerState>(
|
|
23
|
+
kind, frames, channels, rate, slots);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
v8::Local<v8::Value> RegisterWorker(
|
|
26
|
+
v8::Local<v8::Value> RegisterWorker(
|
|
27
|
+
const std::shared_ptr<AudioWorkerState>& state) {
|
|
24
28
|
std::lock_guard lock(registryMutex);
|
|
25
|
-
std::erase_if(registry,
|
|
29
|
+
std::erase_if(registry,
|
|
30
|
+
[](const auto& item) { return item.second.expired(); });
|
|
26
31
|
const auto token = ++nextToken;
|
|
27
32
|
registry.emplace(token, state);
|
|
28
33
|
return v8::BigInt::NewFromUnsigned(v8::Isolate::GetCurrent(), token);
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
v8::Local<v8::Object> MapWorker(
|
|
36
|
+
v8::Local<v8::Object> MapWorker(
|
|
37
|
+
const std::shared_ptr<AudioWorkerState>& state) {
|
|
32
38
|
auto result = Nan::New<v8::Object>();
|
|
33
39
|
Set(result, "handle", AudioWorkerHandle::Create(state));
|
|
34
|
-
Set(result,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
Set(result,
|
|
41
|
+
"fields",
|
|
42
|
+
MapShared(v8::Isolate::GetCurrent(),
|
|
43
|
+
state,
|
|
44
|
+
state->fields.data(),
|
|
45
|
+
sizeof(state->fields)));
|
|
46
|
+
Set(result,
|
|
47
|
+
"time",
|
|
48
|
+
MapShared(v8::Isolate::GetCurrent(),
|
|
49
|
+
state,
|
|
50
|
+
state->time.data(),
|
|
51
|
+
sizeof(state->time)));
|
|
38
52
|
auto mapPipe = [&](AudioPipe& pipe) {
|
|
39
53
|
auto array = Nan::New<v8::Array>(static_cast<int>(pipe.blocks.size()));
|
|
40
54
|
for (unsigned i = 0; i < pipe.blocks.size(); ++i) {
|
|
41
55
|
auto& block = *pipe.blocks[i];
|
|
42
56
|
auto buffer = state->kind == 2
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
? MapShared(v8::Isolate::GetCurrent(),
|
|
58
|
+
state,
|
|
59
|
+
block.floats.data(),
|
|
60
|
+
block.floats.size() * sizeof(float))
|
|
61
|
+
: MapShared(v8::Isolate::GetCurrent(),
|
|
62
|
+
state,
|
|
63
|
+
block.pcm.data(),
|
|
64
|
+
block.pcm.size() * sizeof(std::int16_t));
|
|
47
65
|
Nan::Set(array, i, buffer).FromJust();
|
|
48
66
|
}
|
|
49
67
|
return array;
|
|
@@ -54,13 +72,19 @@ v8::Local<v8::Object> MapWorker(const std::shared_ptr<AudioWorkerState>& state)
|
|
|
54
72
|
}
|
|
55
73
|
|
|
56
74
|
bool AudioWorkerState::Stream(sf::SoundStream::Chunk& chunk) {
|
|
57
|
-
if (streamLease) {
|
|
75
|
+
if (streamLease) {
|
|
76
|
+
input.Release();
|
|
77
|
+
streamLease = false;
|
|
78
|
+
}
|
|
58
79
|
if (closed.load(std::memory_order_acquire)) return false;
|
|
59
80
|
const auto current = generation.load(std::memory_order_acquire);
|
|
60
81
|
for (unsigned i = 0; i < input.blocks.size(); ++i) {
|
|
61
82
|
auto* block = input.Read();
|
|
62
83
|
if (!block) break;
|
|
63
|
-
if (block->generation != current) {
|
|
84
|
+
if (block->generation != current) {
|
|
85
|
+
input.Release();
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
64
88
|
chunk = {block->pcm.data(), block->count};
|
|
65
89
|
loop = block->loop;
|
|
66
90
|
streamLease = true;
|
|
@@ -74,12 +98,17 @@ bool AudioWorkerState::Stream(sf::SoundStream::Chunk& chunk) {
|
|
|
74
98
|
|
|
75
99
|
void AudioWorkerState::Capture(const std::int16_t* samples, std::size_t count) {
|
|
76
100
|
if (closed.load(std::memory_order_acquire) ||
|
|
77
|
-
finish.load(std::memory_order_acquire))
|
|
101
|
+
finish.load(std::memory_order_acquire))
|
|
102
|
+
return;
|
|
78
103
|
const unsigned capacity = frames * channels;
|
|
79
104
|
while (count) {
|
|
80
105
|
auto* block = input.Write();
|
|
81
|
-
if (!block) {
|
|
82
|
-
|
|
106
|
+
if (!block) {
|
|
107
|
+
overruns.fetch_add(count, std::memory_order_relaxed);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const auto size =
|
|
111
|
+
static_cast<unsigned>(std::min<std::size_t>(count, capacity));
|
|
83
112
|
std::memcpy(block->pcm.data(), samples, size * sizeof(*samples));
|
|
84
113
|
block->count = size;
|
|
85
114
|
block->channels = channels;
|
|
@@ -89,8 +118,11 @@ void AudioWorkerState::Capture(const std::int16_t* samples, std::size_t count) {
|
|
|
89
118
|
}
|
|
90
119
|
}
|
|
91
120
|
|
|
92
|
-
void AudioWorkerState::Effect(const float* in,
|
|
93
|
-
unsigned&
|
|
121
|
+
void AudioWorkerState::Effect(const float* in,
|
|
122
|
+
unsigned& inFrames,
|
|
123
|
+
float* out,
|
|
124
|
+
unsigned& outFrames,
|
|
125
|
+
unsigned channelCount) {
|
|
94
126
|
if (closed.load(std::memory_order_acquire) || channelCount > channels ||
|
|
95
127
|
channelCount == 0) {
|
|
96
128
|
std::fill_n(out, outFrames * channelCount, 0.f);
|
|
@@ -106,7 +138,8 @@ void AudioWorkerState::Effect(const float* in, unsigned& inFrames, float* out,
|
|
|
106
138
|
block->channels = channelCount;
|
|
107
139
|
block->tail = !in;
|
|
108
140
|
block->generation = current;
|
|
109
|
-
if (accepted)
|
|
141
|
+
if (accepted)
|
|
142
|
+
std::memcpy(block->floats.data(), in, block->count * sizeof(float));
|
|
110
143
|
pending.fetch_add(1, std::memory_order_relaxed);
|
|
111
144
|
input.Publish();
|
|
112
145
|
} else {
|
|
@@ -126,7 +159,8 @@ void AudioWorkerState::Effect(const float* in, unsigned& inFrames, float* out,
|
|
|
126
159
|
}
|
|
127
160
|
const auto count = std::min(requested - written,
|
|
128
161
|
(block->count - outputOffset) / channelCount);
|
|
129
|
-
std::memcpy(out + written * channelCount,
|
|
162
|
+
std::memcpy(out + written * channelCount,
|
|
163
|
+
block->floats.data() + outputOffset,
|
|
130
164
|
count * channelCount * sizeof(float));
|
|
131
165
|
written += count;
|
|
132
166
|
outputOffset += count * channelCount;
|
|
@@ -142,14 +176,15 @@ void AudioWorkerState::Effect(const float* in, unsigned& inFrames, float* out,
|
|
|
142
176
|
}
|
|
143
177
|
if (written < requested) {
|
|
144
178
|
underruns.fetch_add(requested - written, std::memory_order_relaxed);
|
|
145
|
-
std::fill(
|
|
179
|
+
std::fill(
|
|
180
|
+
out + written * channelCount, out + requested * channelCount, 0.f);
|
|
146
181
|
}
|
|
147
182
|
}
|
|
148
183
|
|
|
149
184
|
class WorkerStream final : public sf::SoundStream {
|
|
150
185
|
public:
|
|
151
186
|
WorkerStream(std::shared_ptr<AudioWorkerState> state,
|
|
152
|
-
|
|
187
|
+
const std::vector<sf::SoundChannel>& channels)
|
|
153
188
|
: state_(std::move(state)) {
|
|
154
189
|
initialize(state_->channels, state_->rate, channels);
|
|
155
190
|
}
|
|
@@ -162,10 +197,12 @@ class WorkerStream final : public sf::SoundStream {
|
|
|
162
197
|
std::optional<std::uint64_t> onLoop() override {
|
|
163
198
|
if (state_->loop < 0) return std::nullopt;
|
|
164
199
|
const auto sample = static_cast<std::uint64_t>(state_->loop);
|
|
165
|
-
state_->Seek(static_cast<std::int64_t>(
|
|
166
|
-
|
|
200
|
+
state_->Seek(static_cast<std::int64_t>(sample / state_->channels * 1000000 /
|
|
201
|
+
state_->rate),
|
|
202
|
+
state_->loop);
|
|
167
203
|
return sample;
|
|
168
204
|
}
|
|
205
|
+
|
|
169
206
|
private:
|
|
170
207
|
std::shared_ptr<AudioWorkerState> state_;
|
|
171
208
|
};
|
|
@@ -175,8 +212,10 @@ NAN_METHOD(CreateAudioStream) {
|
|
|
175
212
|
std::vector<sf::SoundChannel> map;
|
|
176
213
|
if (!Unsigned(info[0], frames) || !Unsigned(info[1], channels) ||
|
|
177
214
|
!Unsigned(info[2], rate) || !Unsigned(info[3], slots) ||
|
|
178
|
-
!Channels(info[4], map))
|
|
179
|
-
|
|
215
|
+
!Channels(info[4], map))
|
|
216
|
+
return;
|
|
217
|
+
if (map.size() != channels)
|
|
218
|
+
return Nan::ThrowRangeError("Channel map size mismatch");
|
|
180
219
|
auto state = CreateWorkerState(0, frames, channels, rate, slots);
|
|
181
220
|
auto source = MakeThreadOwned<Source>();
|
|
182
221
|
source->kind = 2;
|
|
@@ -194,12 +233,17 @@ NAN_METHOD(OpenAudioMusicStream) {
|
|
|
194
233
|
std::vector<sf::SoundChannel> map;
|
|
195
234
|
if (!handle || !Unsigned(info[1], frames) || !Unsigned(info[2], channels) ||
|
|
196
235
|
!Unsigned(info[3], rate) || !Unsigned(info[4], slots) ||
|
|
197
|
-
!Channels(info[5], map))
|
|
236
|
+
!Channels(info[5], map))
|
|
237
|
+
return;
|
|
198
238
|
bool lossless{};
|
|
199
|
-
const auto count = info[6]->IsBigInt()
|
|
200
|
-
|
|
239
|
+
const auto count = info[6]->IsBigInt()
|
|
240
|
+
? info[6].As<v8::BigInt>()->Uint64Value(&lossless)
|
|
241
|
+
: 0;
|
|
242
|
+
if (!lossless || map.size() != channels)
|
|
243
|
+
return Nan::ThrowRangeError("Invalid music metadata");
|
|
201
244
|
auto source = handle->owner();
|
|
202
|
-
if (source->kind != 1 && source->kind != 3)
|
|
245
|
+
if (source->kind != 1 && source->kind != 3)
|
|
246
|
+
return Nan::ThrowTypeError("Expected Music");
|
|
203
247
|
auto state = CreateWorkerState(0, frames, channels, rate, slots);
|
|
204
248
|
state->music = true;
|
|
205
249
|
state->sampleCount = count;
|
|
@@ -222,15 +266,21 @@ NAN_METHOD(OpenAudioMusicStream) {
|
|
|
222
266
|
}
|
|
223
267
|
|
|
224
268
|
NAN_METHOD(AttachAudioWorker) {
|
|
225
|
-
if (!info[0]->IsBigInt())
|
|
269
|
+
if (!info[0]->IsBigInt())
|
|
270
|
+
return Nan::ThrowTypeError("Expected an audio worker token");
|
|
226
271
|
const auto token = info[0].As<v8::BigInt>()->Uint64Value();
|
|
227
272
|
std::shared_ptr<AudioWorkerState> state;
|
|
228
273
|
{
|
|
229
274
|
std::lock_guard lock(registryMutex);
|
|
230
275
|
const auto found = registry.find(token);
|
|
231
|
-
if (found != registry.end()) {
|
|
276
|
+
if (found != registry.end()) {
|
|
277
|
+
state = found->second.lock();
|
|
278
|
+
registry.erase(found);
|
|
279
|
+
}
|
|
232
280
|
}
|
|
233
|
-
if (!state)
|
|
281
|
+
if (!state)
|
|
282
|
+
return Nan::ThrowError(
|
|
283
|
+
"Audio worker token has expired or was already used");
|
|
234
284
|
info.GetReturnValue().Set(MapWorker(state));
|
|
235
285
|
}
|
|
236
286
|
|
|
@@ -239,32 +289,41 @@ NAN_METHOD(PollAudioWorker) {
|
|
|
239
289
|
if (!handle) return;
|
|
240
290
|
auto& state = *handle->owner();
|
|
241
291
|
if (state.closed.load(std::memory_order_acquire)) {
|
|
242
|
-
info.GetReturnValue().Set(-3);
|
|
292
|
+
info.GetReturnValue().Set(-3);
|
|
293
|
+
return;
|
|
243
294
|
}
|
|
244
295
|
if (state.kind == 1 && state.finish.load(std::memory_order_acquire)) {
|
|
245
|
-
info.GetReturnValue().Set(
|
|
296
|
+
info.GetReturnValue().Set(
|
|
297
|
+
state.running.load(std::memory_order_acquire) ? -1 : -3);
|
|
246
298
|
return;
|
|
247
299
|
}
|
|
248
|
-
if (state.leased)
|
|
300
|
+
if (state.leased)
|
|
301
|
+
return Nan::ThrowError("Previous audio block is still leased");
|
|
249
302
|
auto& f = state.fields;
|
|
250
303
|
if (state.kind == 0) {
|
|
251
304
|
const auto sequence = state.seekSequence.load(std::memory_order_acquire);
|
|
252
305
|
const auto generation = state.generation.load(std::memory_order_acquire);
|
|
253
|
-
if (sequence & 1) {
|
|
306
|
+
if (sequence & 1) {
|
|
307
|
+
info.GetReturnValue().Set(-1);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
254
310
|
if (state.workerGeneration != generation) {
|
|
255
311
|
const auto offset = state.seek.load(std::memory_order_relaxed);
|
|
256
312
|
const auto sample = state.seekSample.load(std::memory_order_relaxed);
|
|
257
313
|
if (state.seekSequence.load(std::memory_order_acquire) != sequence) {
|
|
258
|
-
info.GetReturnValue().Set(-1);
|
|
314
|
+
info.GetReturnValue().Set(-1);
|
|
315
|
+
return;
|
|
259
316
|
}
|
|
260
317
|
state.workerGeneration = generation;
|
|
261
318
|
state.workerEof = false;
|
|
262
319
|
state.time[0] = offset;
|
|
263
320
|
state.time[5] = sample;
|
|
264
|
-
info.GetReturnValue().Set(-2);
|
|
321
|
+
info.GetReturnValue().Set(-2);
|
|
322
|
+
return;
|
|
265
323
|
}
|
|
266
324
|
if (state.workerEof || !state.input.Write()) {
|
|
267
|
-
info.GetReturnValue().Set(-1);
|
|
325
|
+
info.GetReturnValue().Set(-1);
|
|
326
|
+
return;
|
|
268
327
|
}
|
|
269
328
|
f[0] = static_cast<int>(state.input.tail % state.input.blocks.size());
|
|
270
329
|
f[2] = state.frames * state.channels;
|
|
@@ -272,12 +331,15 @@ NAN_METHOD(PollAudioWorker) {
|
|
|
272
331
|
f[4] = state.looping.load(std::memory_order_acquire);
|
|
273
332
|
state.time[1] = 0;
|
|
274
333
|
state.time[2] = static_cast<std::int64_t>(state.sampleCount);
|
|
275
|
-
state.time[3] = static_cast<std::int64_t>(
|
|
276
|
-
|
|
334
|
+
state.time[3] = static_cast<std::int64_t>(
|
|
335
|
+
state.loopOffset.load(std::memory_order_acquire));
|
|
336
|
+
state.time[4] = static_cast<std::int64_t>(
|
|
337
|
+
state.loopLength.load(std::memory_order_acquire));
|
|
277
338
|
} else {
|
|
278
339
|
auto* input = state.input.Read();
|
|
279
340
|
while (input && state.kind == 2 &&
|
|
280
|
-
input->generation !=
|
|
341
|
+
input->generation !=
|
|
342
|
+
state.generation.load(std::memory_order_acquire)) {
|
|
281
343
|
state.input.Release();
|
|
282
344
|
state.pending.fetch_sub(1, std::memory_order_release);
|
|
283
345
|
state.workerOffset = 0;
|
|
@@ -285,10 +347,12 @@ NAN_METHOD(PollAudioWorker) {
|
|
|
285
347
|
}
|
|
286
348
|
if (!input && state.kind == 1 &&
|
|
287
349
|
!state.running.load(std::memory_order_acquire)) {
|
|
288
|
-
info.GetReturnValue().Set(-3);
|
|
350
|
+
info.GetReturnValue().Set(-3);
|
|
351
|
+
return;
|
|
289
352
|
}
|
|
290
353
|
if (!input || (state.kind == 2 && !state.output.Write())) {
|
|
291
|
-
info.GetReturnValue().Set(-1);
|
|
354
|
+
info.GetReturnValue().Set(-1);
|
|
355
|
+
return;
|
|
292
356
|
}
|
|
293
357
|
f[0] = static_cast<int>(state.input.head % state.input.blocks.size());
|
|
294
358
|
f[1] = static_cast<int>(state.output.tail % state.output.blocks.size());
|
|
@@ -310,7 +374,8 @@ NAN_METHOD(CommitAudioWorker) {
|
|
|
310
374
|
if (!state.leased) return Nan::ThrowError("No leased audio block");
|
|
311
375
|
auto& f = state.fields;
|
|
312
376
|
if (state.kind == 0) {
|
|
313
|
-
if (f[2] < 0 ||
|
|
377
|
+
if (f[2] < 0 ||
|
|
378
|
+
static_cast<unsigned>(f[2]) > state.frames * state.channels ||
|
|
314
379
|
f[2] % state.channels || (f[2] == 0 && f[3])) {
|
|
315
380
|
return Nan::ThrowRangeError("Invalid stream sample count");
|
|
316
381
|
}
|
|
@@ -322,13 +387,15 @@ NAN_METHOD(CommitAudioWorker) {
|
|
|
322
387
|
state.workerEof = !block->more;
|
|
323
388
|
state.input.Publish();
|
|
324
389
|
} else if (state.kind == 1) {
|
|
325
|
-
state.processed.fetch_add(state.input.Read()->count,
|
|
390
|
+
state.processed.fetch_add(state.input.Read()->count,
|
|
391
|
+
std::memory_order_relaxed);
|
|
326
392
|
state.input.Release();
|
|
327
393
|
if (!info[1]->IsTrue()) state.finish.store(true, std::memory_order_release);
|
|
328
394
|
} else {
|
|
329
395
|
auto* input = state.input.Read();
|
|
330
396
|
if (f[6] < 0 || static_cast<unsigned>(f[6]) > state.frames || f[7] < 0 ||
|
|
331
|
-
static_cast<unsigned>(f[7]) >
|
|
397
|
+
static_cast<unsigned>(f[7]) >
|
|
398
|
+
(input->count - state.workerOffset) / input->channels ||
|
|
332
399
|
(f[6] == 0 && f[7] == 0 && !input->tail)) {
|
|
333
400
|
return Nan::ThrowRangeError("Invalid effect frame counts or no progress");
|
|
334
401
|
}
|
|
@@ -343,7 +410,7 @@ NAN_METHOD(CommitAudioWorker) {
|
|
|
343
410
|
state.processed.fetch_add(f[7], std::memory_order_relaxed);
|
|
344
411
|
if (input->tail || state.workerOffset == input->count) {
|
|
345
412
|
if (input->tail && input->generation ==
|
|
346
|
-
|
|
413
|
+
state.generation.load(std::memory_order_acquire)) {
|
|
347
414
|
state.tailDone.store(f[6] == 0, std::memory_order_release);
|
|
348
415
|
}
|
|
349
416
|
state.input.Release();
|
|
@@ -367,14 +434,15 @@ NAN_METHOD(AudioWorkerStats) {
|
|
|
367
434
|
*values = {state->underruns.load(std::memory_order_relaxed),
|
|
368
435
|
state->overruns.load(std::memory_order_relaxed),
|
|
369
436
|
state->processed.load(std::memory_order_relaxed)};
|
|
370
|
-
info.GetReturnValue().Set(
|
|
371
|
-
|
|
437
|
+
info.GetReturnValue().Set(
|
|
438
|
+
MapShared(info.GetIsolate(), values, values->data(), sizeof(*values)));
|
|
372
439
|
}
|
|
373
440
|
|
|
374
441
|
NAN_METHOD(CreateAudioEffect) {
|
|
375
442
|
unsigned frames, channels, slots;
|
|
376
443
|
if (!Unsigned(info[0], frames) || !Unsigned(info[1], channels) ||
|
|
377
|
-
!Unsigned(info[2], slots))
|
|
444
|
+
!Unsigned(info[2], slots))
|
|
445
|
+
return;
|
|
378
446
|
auto state = CreateWorkerState(2, frames, channels, 1, slots);
|
|
379
447
|
auto result = Nan::New<v8::Object>();
|
|
380
448
|
Set(result, "handle", AudioWorkerHandle::Create(state));
|
|
@@ -392,15 +460,18 @@ NAN_METHOD(SetAudioEffect) {
|
|
|
392
460
|
: owner.AsStream()->getPlayingOffset();
|
|
393
461
|
owner.sound->stop();
|
|
394
462
|
action();
|
|
395
|
-
if (owner.AsSound())
|
|
396
|
-
|
|
463
|
+
if (owner.AsSound())
|
|
464
|
+
owner.AsSound()->setPlayingOffset(offset);
|
|
465
|
+
else
|
|
466
|
+
owner.AsStream()->setPlayingOffset(offset);
|
|
397
467
|
if (status != sf::SoundSource::Status::Stopped) owner.sound->play();
|
|
398
468
|
if (status == sf::SoundSource::Status::Paused) owner.sound->pause();
|
|
399
469
|
};
|
|
400
470
|
if (info[1]->IsNullOrUndefined()) {
|
|
401
471
|
change([&] { source->owner()->sound->setEffectProcessor({}); });
|
|
402
472
|
if (source->owner()->effect) {
|
|
403
|
-
source->owner()->effect->attached.store(nullptr,
|
|
473
|
+
source->owner()->effect->attached.store(nullptr,
|
|
474
|
+
std::memory_order_release);
|
|
404
475
|
source->owner()->effect.reset();
|
|
405
476
|
}
|
|
406
477
|
return;
|
|
@@ -408,40 +479,51 @@ NAN_METHOD(SetAudioEffect) {
|
|
|
408
479
|
auto* handle = AudioWorkerHandle::From(info[1]);
|
|
409
480
|
if (!handle) return;
|
|
410
481
|
auto state = handle->owner();
|
|
411
|
-
if (state->kind != 2)
|
|
482
|
+
if (state->kind != 2)
|
|
483
|
+
return Nan::ThrowTypeError("Expected an effect processor");
|
|
412
484
|
if (state->closed.load(std::memory_order_acquire)) {
|
|
413
485
|
return Nan::ThrowError("Effect processor is closed");
|
|
414
486
|
}
|
|
415
487
|
if (source->owner()->effect == state) return;
|
|
416
488
|
Source* expected = nullptr;
|
|
417
|
-
if (!state->attached.compare_exchange_strong(expected,
|
|
489
|
+
if (!state->attached.compare_exchange_strong(expected,
|
|
490
|
+
source->owner().get())) {
|
|
418
491
|
return Nan::ThrowError("An effect processor can be attached to one source");
|
|
419
492
|
}
|
|
420
493
|
change([&] {
|
|
421
494
|
if (source->owner()->effect) {
|
|
422
|
-
source->owner()->effect->attached.store(nullptr,
|
|
495
|
+
source->owner()->effect->attached.store(nullptr,
|
|
496
|
+
std::memory_order_release);
|
|
423
497
|
}
|
|
424
498
|
source->owner()->effect = state;
|
|
425
499
|
state->Seek(0);
|
|
426
|
-
source->owner()->sound->setEffectProcessor(
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
500
|
+
source->owner()->sound->setEffectProcessor([state](const float* in,
|
|
501
|
+
unsigned& inFrames,
|
|
502
|
+
float* out,
|
|
503
|
+
unsigned& outFrames,
|
|
504
|
+
unsigned channels) {
|
|
505
|
+
state->Effect(in, inFrames, out, outFrames, channels);
|
|
506
|
+
});
|
|
431
507
|
});
|
|
432
508
|
}
|
|
433
509
|
|
|
434
|
-
}
|
|
510
|
+
} // namespace sfmljs::audio
|
|
435
511
|
|
|
436
512
|
NAN_MODULE_INIT(InitializeAudioWorkers) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
sfmljs::SetMethod<OpenAudioMusicStream>(
|
|
440
|
-
|
|
441
|
-
sfmljs::SetMethod<
|
|
442
|
-
|
|
443
|
-
sfmljs::SetMethod<
|
|
444
|
-
sfmljs::SetMethod<
|
|
445
|
-
|
|
446
|
-
sfmljs::SetMethod<
|
|
513
|
+
sfmljs::SetMethod<sfmljs::audio::CreateAudioStream>(target,
|
|
514
|
+
"createAudioStream");
|
|
515
|
+
sfmljs::SetMethod<sfmljs::audio::OpenAudioMusicStream>(
|
|
516
|
+
target, "openAudioMusicStream");
|
|
517
|
+
sfmljs::SetMethod<sfmljs::audio::AttachAudioWorker>(target,
|
|
518
|
+
"attachAudioWorker");
|
|
519
|
+
sfmljs::SetMethod<sfmljs::audio::PollAudioWorker>(target, "pollAudioWorker");
|
|
520
|
+
sfmljs::SetMethod<sfmljs::audio::CommitAudioWorker>(target,
|
|
521
|
+
"commitAudioWorker");
|
|
522
|
+
sfmljs::SetMethod<sfmljs::audio::CloseAudioWorker>(target,
|
|
523
|
+
"closeAudioWorker");
|
|
524
|
+
sfmljs::SetMethod<sfmljs::audio::AudioWorkerStats>(target,
|
|
525
|
+
"audioWorkerStats");
|
|
526
|
+
sfmljs::SetMethod<sfmljs::audio::CreateAudioEffect>(target,
|
|
527
|
+
"createAudioEffect");
|
|
528
|
+
sfmljs::SetMethod<sfmljs::audio::SetAudioEffect>(target, "setAudioEffect");
|
|
447
529
|
}
|
package/native/audio-worker.h
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include "audio-state.h"
|
|
4
|
-
|
|
5
3
|
#include <atomic>
|
|
6
4
|
#include <cstring>
|
|
7
5
|
|
|
6
|
+
#include "audio-state.h"
|
|
7
|
+
|
|
8
8
|
namespace sfmljs::audio {
|
|
9
9
|
|
|
10
10
|
// The producer owns an empty slot and the consumer owns a published slot.
|
|
@@ -23,13 +23,15 @@ struct AudioBlock {
|
|
|
23
23
|
|
|
24
24
|
struct AudioPipe {
|
|
25
25
|
std::vector<std::unique_ptr<AudioBlock>> blocks;
|
|
26
|
-
std::size_t head{};
|
|
27
|
-
std::size_t tail{};
|
|
26
|
+
std::size_t head{}; // consumer only
|
|
27
|
+
std::size_t tail{}; // producer only
|
|
28
28
|
AudioPipe(unsigned slots, unsigned samples, bool floating) {
|
|
29
29
|
for (unsigned i = 0; i < slots; ++i) {
|
|
30
30
|
auto block = std::make_unique<AudioBlock>();
|
|
31
|
-
if (floating)
|
|
32
|
-
|
|
31
|
+
if (floating)
|
|
32
|
+
block->floats.resize(samples);
|
|
33
|
+
else
|
|
34
|
+
block->pcm.resize(samples);
|
|
33
35
|
blocks.push_back(std::move(block));
|
|
34
36
|
}
|
|
35
37
|
}
|
|
@@ -38,14 +40,16 @@ struct AudioPipe {
|
|
|
38
40
|
return block->ready.load(std::memory_order_acquire) ? nullptr : block;
|
|
39
41
|
}
|
|
40
42
|
void Publish() {
|
|
41
|
-
blocks[tail++ % blocks.size()]->ready.store(true,
|
|
43
|
+
blocks[tail++ % blocks.size()]->ready.store(true,
|
|
44
|
+
std::memory_order_release);
|
|
42
45
|
}
|
|
43
46
|
AudioBlock* Read() {
|
|
44
47
|
auto* block = blocks[head % blocks.size()].get();
|
|
45
48
|
return block->ready.load(std::memory_order_acquire) ? block : nullptr;
|
|
46
49
|
}
|
|
47
50
|
void Release() {
|
|
48
|
-
blocks[head++ % blocks.size()]->ready.store(false,
|
|
51
|
+
blocks[head++ % blocks.size()]->ready.store(false,
|
|
52
|
+
std::memory_order_release);
|
|
49
53
|
}
|
|
50
54
|
};
|
|
51
55
|
|
|
@@ -90,9 +94,15 @@ struct AudioWorkerState {
|
|
|
90
94
|
unsigned outputOffset{};
|
|
91
95
|
std::int64_t loop{};
|
|
92
96
|
|
|
93
|
-
AudioWorkerState(unsigned mode,
|
|
94
|
-
unsigned
|
|
95
|
-
|
|
97
|
+
AudioWorkerState(unsigned mode,
|
|
98
|
+
unsigned blockFrames,
|
|
99
|
+
unsigned channelCount,
|
|
100
|
+
unsigned sampleRate,
|
|
101
|
+
unsigned slots)
|
|
102
|
+
: kind(mode),
|
|
103
|
+
frames(blockFrames),
|
|
104
|
+
channels(channelCount),
|
|
105
|
+
rate(sampleRate),
|
|
96
106
|
input(slots, blockFrames * channelCount, mode == 2),
|
|
97
107
|
output(slots, blockFrames * channelCount, mode == 2),
|
|
98
108
|
silence(mode == 0 ? blockFrames * channelCount : 0) {}
|
|
@@ -104,18 +114,24 @@ struct AudioWorkerState {
|
|
|
104
114
|
generation.fetch_add(1, std::memory_order_release);
|
|
105
115
|
if (kind == 0) seekSequence.fetch_add(1, std::memory_order_release);
|
|
106
116
|
}
|
|
107
|
-
bool Stream(sf::SoundStream::Chunk& chunk);
|
|
117
|
+
bool Stream(sf::SoundStream::Chunk& chunk); // NOLINT(runtime/references)
|
|
108
118
|
void Capture(const std::int16_t* samples, std::size_t count);
|
|
109
|
-
void Effect(const float* in,
|
|
110
|
-
unsigned&
|
|
119
|
+
void Effect(const float* in,
|
|
120
|
+
unsigned& inFrames, // NOLINT(runtime/references)
|
|
121
|
+
float* out,
|
|
122
|
+
unsigned& outFrames, // NOLINT(runtime/references)
|
|
123
|
+
unsigned channelCount);
|
|
111
124
|
};
|
|
112
125
|
|
|
113
126
|
using AudioWorkerHandle = SharedHandle<AudioWorkerState>;
|
|
114
127
|
|
|
115
|
-
std::shared_ptr<AudioWorkerState> CreateWorkerState(
|
|
116
|
-
|
|
117
|
-
|
|
128
|
+
std::shared_ptr<AudioWorkerState> CreateWorkerState(unsigned kind,
|
|
129
|
+
unsigned frames,
|
|
130
|
+
unsigned channels,
|
|
131
|
+
unsigned rate,
|
|
132
|
+
unsigned slots);
|
|
118
133
|
v8::Local<v8::Object> MapWorker(const std::shared_ptr<AudioWorkerState>& state);
|
|
119
|
-
v8::Local<v8::Value> RegisterWorker(
|
|
134
|
+
v8::Local<v8::Value> RegisterWorker(
|
|
135
|
+
const std::shared_ptr<AudioWorkerState>& state);
|
|
120
136
|
|
|
121
|
-
}
|
|
137
|
+
} // namespace sfmljs::audio
|