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
4b1c70e4
Commit
4b1c70e4
authored
Dec 31, 2018
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Web Audio: Fix compiler errors when using the -std=c99 switch.
parent
2aa05be5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
6 deletions
+30
-6
mini_al.h
mini_al.h
+29
-5
tests/mal_build_tests_emscripten.bat
tests/mal_build_tests_emscripten.bat
+1
-1
No files found.
mini_al.h
View file @
4b1c70e4
...
@@ -1469,7 +1469,11 @@ typedef struct
...
@@ -1469,7 +1469,11 @@ typedef struct
typedef struct
typedef struct
{
{
mal_int64 counter;
union
{
mal_int64 counter;
double counterD;
};
} mal_timer;
} mal_timer;
typedef struct
typedef struct
...
@@ -2786,6 +2790,10 @@ mal_uint64 mal_sine_wave_read_ex(mal_sine_wave* pSineWave, mal_uint64 frameCount
...
@@ -2786,6 +2790,10 @@ mal_uint64 mal_sine_wave_read_ex(mal_sine_wave* pSineWave, mal_uint64 frameCount
#include <dlfcn.h>
#include <dlfcn.h>
#endif
#endif
#ifdef MAL_EMSCRIPTEN
#include <emscripten/emscripten.h>
#endif
#if !defined(MAL_64BIT) && !defined(MAL_32BIT)
#if !defined(MAL_64BIT) && !defined(MAL_32BIT)
#ifdef _WIN32
#ifdef _WIN32
#ifdef _WIN64
#ifdef _WIN64
...
@@ -4001,6 +4009,16 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer)
...
@@ -4001,6 +4009,16 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer)
return (newTimeCounter - oldTimeCounter) / g_mal_TimerFrequency;
return (newTimeCounter - oldTimeCounter) / g_mal_TimerFrequency;
}
}
#elif defined(MAL_EMSCRIPTEN)
void mal_timer_init(mal_timer* pTimer)
{
pTimer->counterD = emscripten_get_now();
}
double mal_timer_get_time_in_seconds(mal_timer* pTimer)
{
return (emscripten_get_now() - pTimer->counterD) / 1000; /* Emscripten is in milliseconds. */
}
#else
#else
#if defined(CLOCK_MONOTONIC)
#if defined(CLOCK_MONOTONIC)
#define MAL_CLOCK_ID CLOCK_MONOTONIC
#define MAL_CLOCK_ID CLOCK_MONOTONIC
...
@@ -4264,7 +4282,12 @@ void mal_thread_wait__posix(mal_thread* pThread)
...
@@ -4264,7 +4282,12 @@ void mal_thread_wait__posix(mal_thread* pThread)
void mal_sleep__posix(mal_uint32 milliseconds)
void mal_sleep__posix(mal_uint32 milliseconds)
{
{
usleep(milliseconds * 1000); // <-- usleep is in microseconds.
#ifdef MAL_EMSCRIPTEN
(void)milliseconds;
mal_assert(MAL_FALSE); /* The Emscripten build should never sleep. */
#else
usleep(milliseconds * 1000); /* <-- usleep is in microseconds. */
#endif
}
}
...
@@ -19259,13 +19282,14 @@ mal_result mal_context_init__opensl(mal_context* pContext)
...
@@ -19259,13 +19282,14 @@ mal_result mal_context_init__opensl(mal_context* pContext)
//
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#ifdef MAL_HAS_WEBAUDIO
#ifdef MAL_HAS_WEBAUDIO
#include <emscripten/em_asm.h>
#include <emscripten/emscripten.h>
#include <emscripten/emscripten.h>
mal_bool32 mal_is_capture_supported__webaudio()
mal_bool32 mal_is_capture_supported__webaudio()
{
{
return EM_ASM_INT({
return EM_ASM_INT({
return (navigator.mediaDevices !== undefined && navigator.mediaDevices.getUserMedia !== undefined);
return (navigator.mediaDevices !== undefined && navigator.mediaDevices.getUserMedia !== undefined);
}
) != 0;
}
, 0) != 0; /* Must pass in a dummy argument for C99 compatibility. */
}
}
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -19360,7 +19384,7 @@ mal_result mal_context_get_device_info__webaudio(mal_context* pContext, mal_devi
...
@@ -19360,7 +19384,7 @@ mal_result mal_context_get_device_info__webaudio(mal_context* pContext, mal_devi
} catch(e) {
} catch(e) {
return 0;
return 0;
}
}
}
);
}
, 0); /* Must pass in a dummy argument for C99 compatibility. */
pDeviceInfo->maxSampleRate = pDeviceInfo->minSampleRate;
pDeviceInfo->maxSampleRate = pDeviceInfo->minSampleRate;
if (pDeviceInfo->minSampleRate == 0) {
if (pDeviceInfo->minSampleRate == 0) {
return MAL_NO_DEVICE;
return MAL_NO_DEVICE;
...
@@ -19697,7 +19721,7 @@ mal_result mal_context_init__webaudio(mal_context* pContext)
...
@@ -19697,7 +19721,7 @@ mal_result mal_context_init__webaudio(mal_context* pContext)
}
}
return 1;
return 1;
}
);
}
, 0); /* Must pass in a dummy argument for C99 compatibility. */
if (resultFromJS != 1) {
if (resultFromJS != 1) {
return MAL_FAILED_TO_INIT_BACKEND;
return MAL_FAILED_TO_INIT_BACKEND;
tests/mal_build_tests_emscripten.bat
View file @
4b1c70e4
emcc
./mal_test_0.c
-o
./bin/mal_test_0_emscripten.html
-s
WASM
=
0
emcc
./mal_test_0.c
-o
./bin/mal_test_0_emscripten.html
-s
WASM
=
0
-std
=
c99
\ No newline at end of file
\ No newline at end of file
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