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
118c878d
Commit
118c878d
authored
Mar 06, 2019
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename "mal." to "miniaudio." in the WebAudio backend.
parent
3031eb49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
46 deletions
+46
-46
miniaudio.h
miniaudio.h
+28
-28
tests/ma_webaudio_test_0.html
tests/ma_webaudio_test_0.html
+18
-18
No files found.
miniaudio.h
View file @
118c878d
...
@@ -21734,7 +21734,7 @@ void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_type devi
...
@@ -21734,7 +21734,7 @@ void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_type devi
ma_assert(pDevice != NULL);
ma_assert(pDevice != NULL);
EM_ASM({
EM_ASM({
var device = m
al
.get_device_by_index($0);
var device = m
iniaudio
.get_device_by_index($0);
/* 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) {
...
@@ -21763,7 +21763,7 @@ void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_type devi
...
@@ -21763,7 +21763,7 @@ void ma_device_uninit_by_index__webaudio(ma_device* pDevice, ma_device_type devi
}
}
/* 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. */
m
al
.untrack_device_by_index($0);
m
iniaudio
.untrack_device_by_index($0);
}, deviceIndex, deviceType);
}, deviceIndex, deviceType);
}
}
...
@@ -21964,7 +21964,7 @@ ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma_device
...
@@ -21964,7 +21964,7 @@ ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma_device
device.scriptNode.connect(device.webaudio.destination);
device.scriptNode.connect(device.webaudio.destination);
}
}
return m
al
.track_device(device);
return m
iniaudio
.track_device(device);
}, (deviceType == ma_device_type_capture) ? pConfig->capture.channels : pConfig->playback.channels, pConfig->sampleRate, internalBufferSizeInFrames, deviceType == ma_device_type_capture, pDevice);
}, (deviceType == ma_device_type_capture) ? pConfig->capture.channels : pConfig->playback.channels, pConfig->sampleRate, internalBufferSizeInFrames, deviceType == ma_device_type_capture, pDevice);
if (deviceIndex < 0) {
if (deviceIndex < 0) {
...
@@ -21976,7 +21976,7 @@ ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma_device
...
@@ -21976,7 +21976,7 @@ ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma_device
pDevice->capture.internalFormat = ma_format_f32;
pDevice->capture.internalFormat = ma_format_f32;
pDevice->capture.internalChannels = pConfig->capture.channels;
pDevice->capture.internalChannels = pConfig->capture.channels;
ma_get_standard_channel_map(ma_standard_channel_map_webaudio, pDevice->capture.internalChannels, pDevice->capture.internalChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_webaudio, pDevice->capture.internalChannels, pDevice->capture.internalChannelMap);
pDevice->capture.internalSampleRate = EM_ASM_INT({ return m
al
.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
pDevice->capture.internalSampleRate = EM_ASM_INT({ return m
iniaudio
.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
pDevice->capture.internalBufferSizeInFrames = internalBufferSizeInFrames;
pDevice->capture.internalBufferSizeInFrames = internalBufferSizeInFrames;
pDevice->capture.internalPeriods = 1;
pDevice->capture.internalPeriods = 1;
} else {
} else {
...
@@ -21984,7 +21984,7 @@ ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma_device
...
@@ -21984,7 +21984,7 @@ ma_result ma_device_init_by_type__webaudio(ma_context* pContext, const ma_device
pDevice->playback.internalFormat = ma_format_f32;
pDevice->playback.internalFormat = ma_format_f32;
pDevice->playback.internalChannels = pConfig->playback.channels;
pDevice->playback.internalChannels = pConfig->playback.channels;
ma_get_standard_channel_map(ma_standard_channel_map_webaudio, pDevice->playback.internalChannels, pDevice->playback.internalChannelMap);
ma_get_standard_channel_map(ma_standard_channel_map_webaudio, pDevice->playback.internalChannels, pDevice->playback.internalChannelMap);
pDevice->playback.internalSampleRate = EM_ASM_INT({ return m
al
.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
pDevice->playback.internalSampleRate = EM_ASM_INT({ return m
iniaudio
.get_device_by_index($0).webaudio.sampleRate; }, deviceIndex);
pDevice->playback.internalBufferSizeInFrames = internalBufferSizeInFrames;
pDevice->playback.internalBufferSizeInFrames = internalBufferSizeInFrames;
pDevice->playback.internalPeriods = 1;
pDevice->playback.internalPeriods = 1;
}
}
...
@@ -22047,13 +22047,13 @@ ma_result ma_device_start__webaudio(ma_device* pDevice)
...
@@ -22047,13 +22047,13 @@ ma_result ma_device_start__webaudio(ma_device* pDevice)
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
EM_ASM({
EM_ASM({
m
al
.get_device_by_index($0).webaudio.resume();
m
iniaudio
.get_device_by_index($0).webaudio.resume();
}, pDevice->webaudio.indexCapture);
}, pDevice->webaudio.indexCapture);
}
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
EM_ASM({
EM_ASM({
m
al
.get_device_by_index($0).webaudio.resume();
m
iniaudio
.get_device_by_index($0).webaudio.resume();
}, pDevice->webaudio.indexPlayback);
}, pDevice->webaudio.indexPlayback);
}
}
...
@@ -22066,13 +22066,13 @@ ma_result ma_device_stop__webaudio(ma_device* pDevice)
...
@@ -22066,13 +22066,13 @@ ma_result ma_device_stop__webaudio(ma_device* pDevice)
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
EM_ASM({
EM_ASM({
m
al
.get_device_by_index($0).webaudio.suspend();
m
iniaudio
.get_device_by_index($0).webaudio.suspend();
}, pDevice->webaudio.indexCapture);
}, pDevice->webaudio.indexCapture);
}
}
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
EM_ASM({
EM_ASM({
m
al
.get_device_by_index($0).webaudio.suspend();
m
iniaudio
.get_device_by_index($0).webaudio.suspend();
}, pDevice->webaudio.indexPlayback);
}, pDevice->webaudio.indexPlayback);
}
}
...
@@ -22106,47 +22106,47 @@ ma_result ma_context_init__webaudio(ma_context* pContext)
...
@@ -22106,47 +22106,47 @@ ma_result ma_context_init__webaudio(ma_context* pContext)
}
}
if (typeof(mal) === 'undefined') {
if (typeof(mal) === 'undefined') {
m
al
= {};
m
iniaudio
= {};
m
al
.devices = []; /* Device cache for mapping devices to indexes for JavaScript/C interop. */
m
iniaudio
.devices = []; /* Device cache for mapping devices to indexes for JavaScript/C interop. */
m
al
.track_device = function(device) {
m
iniaudio
.track_device = function(device) {
/* Try inserting into a free slot first. */
/* Try inserting into a free slot first. */
for (var iDevice = 0; iDevice < m
al
.devices.length; ++iDevice) {
for (var iDevice = 0; iDevice < m
iniaudio
.devices.length; ++iDevice) {
if (m
al
.devices[iDevice] == null) {
if (m
iniaudio
.devices[iDevice] == null) {
m
al
.devices[iDevice] = device;
m
iniaudio
.devices[iDevice] = device;
return iDevice;
return iDevice;
}
}
}
}
/* Getting here means there is no empty slots in the array so we just push to the end. */
/* Getting here means there is no empty slots in the array so we just push to the end. */
m
al
.devices.push(device);
m
iniaudio
.devices.push(device);
return m
al
.devices.length - 1;
return m
iniaudio
.devices.length - 1;
};
};
m
al
.untrack_device_by_index = function(deviceIndex) {
m
iniaudio
.untrack_device_by_index = function(deviceIndex) {
/* We just set the device's slot to null. The slot will get reused in the next call to ma_track_device. */
/* We just set the device's slot to null. The slot will get reused in the next call to ma_track_device. */
m
al
.devices[deviceIndex] = null;
m
iniaudio
.devices[deviceIndex] = null;
/* Trim the array if possible. */
/* Trim the array if possible. */
while (m
al
.devices.length > 0) {
while (m
iniaudio
.devices.length > 0) {
if (m
al.devices[mal
.devices.length-1] == null) {
if (m
iniaudio.devices[miniaudio
.devices.length-1] == null) {
m
al
.devices.pop();
m
iniaudio
.devices.pop();
} else {
} else {
break;
break;
}
}
}
}
};
};
m
al
.untrack_device = function(device) {
m
iniaudio
.untrack_device = function(device) {
for (var iDevice = 0; iDevice < m
al
.devices.length; ++iDevice) {
for (var iDevice = 0; iDevice < m
iniaudio
.devices.length; ++iDevice) {
if (m
al
.devices[iDevice] == device) {
if (m
iniaudio
.devices[iDevice] == device) {
return m
al
.untrack_device_by_index(iDevice);
return m
iniaudio
.untrack_device_by_index(iDevice);
}
}
}
}
};
};
m
al
.get_device_by_index = function(deviceIndex) {
m
iniaudio
.get_device_by_index = function(deviceIndex) {
return m
al
.devices[deviceIndex];
return m
iniaudio
.devices[deviceIndex];
};
};
}
}
tests/ma_webaudio_test_0.html
View file @
118c878d
...
@@ -217,47 +217,47 @@
...
@@ -217,47 +217,47 @@
if
(
typeof
(
mal
)
===
'
undefined
'
)
{
if
(
typeof
(
mal
)
===
'
undefined
'
)
{
mal
=
{};
mal
=
{};
m
al
.
devices
=
[];
// Device cache for mapping devices to indexes for JavaScript/C interop.
m
iniaudio
.
devices
=
[];
// Device cache for mapping devices to indexes for JavaScript/C interop.
// Returns the index of the device. Throws an exception on error.
// Returns the index of the device. Throws an exception on error.
m
al
.
track_device
=
function
(
device
)
{
m
iniaudio
.
track_device
=
function
(
device
)
{
// Try inserting into a free slot first.
// Try inserting into a free slot first.
for
(
var
iDevice
=
0
;
iDevice
<
m
al
.
devices
.
length
;
++
iDevice
)
{
for
(
var
iDevice
=
0
;
iDevice
<
m
iniaudio
.
devices
.
length
;
++
iDevice
)
{
if
(
m
al
.
devices
[
iDevice
]
==
null
)
{
if
(
m
iniaudio
.
devices
[
iDevice
]
==
null
)
{
m
al
.
devices
[
iDevice
]
=
device
;
m
iniaudio
.
devices
[
iDevice
]
=
device
;
return
iDevice
;
return
iDevice
;
}
}
}
}
// Getting here means there is no empty slots in the array so we just push to the end.
// Getting here means there is no empty slots in the array so we just push to the end.
m
al
.
devices
.
push
(
device
);
m
iniaudio
.
devices
.
push
(
device
);
return
m
al
.
devices
.
length
-
1
;
return
m
iniaudio
.
devices
.
length
-
1
;
};
};
m
al
.
untrack_device_by_index
=
function
(
deviceIndex
)
{
m
iniaudio
.
untrack_device_by_index
=
function
(
deviceIndex
)
{
// We just set the device's slot to null. The slot will get reused in the next call to ma_track_device.
// We just set the device's slot to null. The slot will get reused in the next call to ma_track_device.
m
al
.
devices
[
iDevice
]
=
null
;
m
iniaudio
.
devices
[
iDevice
]
=
null
;
// Trim the array if possible.
// Trim the array if possible.
while
(
m
al
.
devices
.
length
>
0
)
{
while
(
m
iniaudio
.
devices
.
length
>
0
)
{
if
(
m
al
.
devices
[
mal
.
devices
.
length
-
1
]
==
null
)
{
if
(
m
iniaudio
.
devices
[
miniaudio
.
devices
.
length
-
1
]
==
null
)
{
m
al
.
devices
.
pop
();
m
iniaudio
.
devices
.
pop
();
}
else
{
}
else
{
break
;
break
;
}
}
}
}
};
};
m
al
.
untrack_device
=
function
(
device
)
{
m
iniaudio
.
untrack_device
=
function
(
device
)
{
for
(
var
iDevice
=
0
;
iDevice
<
m
al
.
devices
.
length
;
++
iDevice
)
{
for
(
var
iDevice
=
0
;
iDevice
<
m
iniaudio
.
devices
.
length
;
++
iDevice
)
{
if
(
m
al
.
devices
[
iDevice
]
==
device
)
{
if
(
m
iniaudio
.
devices
[
iDevice
]
==
device
)
{
return
m
al
.
untrack_device_by_index
(
iDevice
);
return
m
iniaudio
.
untrack_device_by_index
(
iDevice
);
}
}
}
}
};
};
m
al
.
get_device_by_index
=
function
(
deviceIndex
)
{
m
iniaudio
.
get_device_by_index
=
function
(
deviceIndex
)
{
return
m
al
.
devices
[
deviceIndex
];
return
m
iniaudio
.
devices
[
deviceIndex
];
};
};
}
}
...
...
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