Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
miniaudio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
miniaudio
Commits
a1b0ab98
Commit
a1b0ab98
authored
Feb 25, 2023
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WebAudio: Fix error about missing `_malloc()` and `_free()` functions.
parent
e2db4230
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
13 deletions
+22
-13
miniaudio.h
miniaudio.h
+22
-13
No files found.
miniaudio.h
View file @
a1b0ab98
...
@@ -39191,6 +39191,16 @@ static ma_bool32 ma_is_capture_supported__webaudio()
...
@@ -39191,6 +39191,16 @@ static ma_bool32 ma_is_capture_supported__webaudio()
#ifdef __cplusplus
#ifdef __cplusplus
extern "C" {
extern "C" {
#endif
#endif
void* EMSCRIPTEN_KEEPALIVE ma_malloc_emscripten(size_t sz, const ma_allocation_callbacks* pAllocationCallbacks)
{
return ma_malloc(sz, pAllocationCallbacks);
}
void EMSCRIPTEN_KEEPALIVE ma_free_emscripten(void* p, const ma_allocation_callbacks* pAllocationCallbacks)
{
ma_free(p, pAllocationCallbacks);
}
void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
void EMSCRIPTEN_KEEPALIVE ma_device_process_pcm_frames_capture__webaudio(ma_device* pDevice, int frameCount, float* pFrames)
{
{
ma_device_handle_backend_data_callback(pDevice, NULL, pFrames, (ma_uint32)frameCount);
ma_device_handle_backend_data_callback(pDevice, NULL, pFrames, (ma_uint32)frameCount);
...
@@ -39288,6 +39298,7 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
...
@@ -39288,6 +39298,7 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
EM_ASM({
EM_ASM({
var device = miniaudio.get_device_by_index($0);
var device = miniaudio.get_device_by_index($0);
var pAllocationCallbacks = $3;
/* Make sure all nodes are disconnected and marked for collection. */
/* Make sure all nodes are disconnected and marked for collection. */
if (device.scriptNode !== undefined) {
if (device.scriptNode !== undefined) {
...
@@ -39309,7 +39320,7 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
...
@@ -39309,7 +39320,7 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
/* Can't forget to free the intermediary buffer. This is the buffer that's shared between JavaScript and C. */
/* Can't forget to free the intermediary buffer. This is the buffer that's shared between JavaScript and C. */
if (device.intermediaryBuffer !== undefined) {
if (device.intermediaryBuffer !== undefined) {
Module._free(device.intermediaryBuffer
);
_ma_free_emscripten(device.intermediaryBuffer, pAllocationCallbacks
);
device.intermediaryBuffer = undefined;
device.intermediaryBuffer = undefined;
device.intermediaryBufferView = undefined;
device.intermediaryBufferView = undefined;
device.intermediaryBufferSizeInBytes = undefined;
device.intermediaryBufferSizeInBytes = undefined;
...
@@ -39317,7 +39328,7 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
...
@@ -39317,7 +39328,7 @@ static void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_ty
/* Make sure the device is untracked so the slot can be reused later. */
/* Make sure the device is untracked so the slot can be reused later. */
miniaudio.untrack_device_by_index($0);
miniaudio.untrack_device_by_index($0);
}, deviceIndex, deviceType);
}, deviceIndex, deviceType
, &pDevice->pContext->allocationCallbacks
);
}
}
static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
static ma_result ma_device_uninit__webaudio(ma_device* pDevice)
...
@@ -39399,6 +39410,7 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
...
@@ -39399,6 +39410,7 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
var bufferSize = $2; /* In PCM frames. */
var bufferSize = $2; /* In PCM frames. */
var isCapture = $3;
var isCapture = $3;
var pDevice = $4;
var pDevice = $4;
var pAllocationCallbacks = $5;
if (typeof(window.miniaudio) === 'undefined') {
if (typeof(window.miniaudio) === 'undefined') {
return -1; /* Context not initialized. */
return -1; /* Context not initialized. */
...
@@ -39411,12 +39423,9 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
...
@@ -39411,12 +39423,9 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
device.webaudio.suspend();
device.webaudio.suspend();
device.state = 1; /* ma_device_state_stopped */
device.state = 1; /* ma_device_state_stopped */
/*
/* We need an intermediary buffer which we use for JavaScript and C interop. This buffer stores interleaved f32 PCM data. */
We need an intermediary buffer which we use for JavaScript and C interop. This buffer stores interleaved f32 PCM data. Because it's passed between
JavaScript and C it needs to be allocated and freed using Module._malloc() and Module._free().
*/
device.intermediaryBufferSizeInBytes = channels * bufferSize * 4;
device.intermediaryBufferSizeInBytes = channels * bufferSize * 4;
device.intermediaryBuffer =
Module._malloc(device.intermediaryBufferSizeInByte
s);
device.intermediaryBuffer =
_ma_malloc_emscripten(device.intermediaryBufferSizeInBytes, pAllocationCallback
s);
device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
device.intermediaryBufferView = new Float32Array(Module.HEAPF32.buffer, device.intermediaryBuffer, device.intermediaryBufferSizeInBytes);
/*
/*
...
@@ -39557,7 +39566,7 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
...
@@ -39557,7 +39566,7 @@ static ma_result ma_device_init_by_type__webaudio(ma_device* pDevice, const ma_d
}
}
return miniaudio.track_device(device);
return miniaudio.track_device(device);
}, channels, sampleRate, periodSizeInFrames, deviceType == ma_device_type_capture, pDevice);
}, channels, sampleRate, periodSizeInFrames, deviceType == ma_device_type_capture, pDevice
, &pDevice->pContext->allocationCallbacks
);
if (deviceIndex < 0) {
if (deviceIndex < 0) {
return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
return MA_FAILED_TO_OPEN_BACKEND_DEVICE;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment