Commit 6a2c324f authored by David Reid's avatar David Reid

Merge branch 'dev' into dev_0.9

# Conflicts:
#	mini_al.h
parents c47e9d49 ef072c03
......@@ -1475,7 +1475,11 @@ typedef struct
typedef struct
{
mal_int64 counter;
union
{
mal_int64 counter;
double counterD;
};
} mal_timer;
typedef struct
......@@ -2635,6 +2639,10 @@ mal_uint64 mal_sine_wave_read_f32_ex(mal_sine_wave* pSineWave, mal_uint64 frameC
#include <dlfcn.h>
#endif
#ifdef MAL_EMSCRIPTEN
#include <emscripten/emscripten.h>
#endif
#if !defined(MAL_64BIT) && !defined(MAL_32BIT)
#ifdef _WIN32
#ifdef _WIN64
......@@ -3801,6 +3809,16 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer)
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
#if defined(CLOCK_MONOTONIC)
#define MAL_CLOCK_ID CLOCK_MONOTONIC
......@@ -4064,7 +4082,12 @@ void mal_thread_wait__posix(mal_thread* pThread)
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
}
......@@ -19047,7 +19070,7 @@ mal_bool32 mal_is_capture_supported__webaudio()
{
return EM_ASM_INT({
return (navigator.mediaDevices !== undefined && navigator.mediaDevices.getUserMedia !== undefined);
}) != 0;
}, 0) != 0; /* Must pass in a dummy argument for C99 compatibility. */
}
#ifdef __cplusplus
......@@ -19146,7 +19169,7 @@ mal_result mal_context_get_device_info__webaudio(mal_context* pContext, mal_devi
} catch(e) {
return 0;
}
});
}, 0); /* Must pass in a dummy argument for C99 compatibility. */
pDeviceInfo->maxSampleRate = pDeviceInfo->minSampleRate;
if (pDeviceInfo->minSampleRate == 0) {
return MAL_NO_DEVICE;
......@@ -19488,7 +19511,7 @@ mal_result mal_context_init__webaudio(mal_context* pContext)
}
return 1;
});
}, 0); /* Must pass in a dummy argument for C99 compatibility. */
if (resultFromJS != 1) {
return MAL_FAILED_TO_INIT_BACKEND;
emcc ./mal_test_0.c -o ./bin/mal_test_0_emscripten.html -s WASM=0
\ No newline at end of file
emcc ./mal_test_0.c -o ./bin/mal_test_0_emscripten.html -s WASM=0 -std=c99
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment