mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 17:24:03 +02:00
Minor formatting for improved readability.
This commit is contained in:
+38
-38
@@ -7856,9 +7856,9 @@ Timing
|
|||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
#ifdef MA_WIN32
|
#ifdef MA_WIN32
|
||||||
LARGE_INTEGER g_ma_TimerFrequency = {{0}};
|
static LARGE_INTEGER g_ma_TimerFrequency = {{0}};
|
||||||
static void ma_timer_init(ma_timer* pTimer)
|
static void ma_timer_init(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER counter;
|
LARGE_INTEGER counter;
|
||||||
|
|
||||||
if (g_ma_TimerFrequency.QuadPart == 0) {
|
if (g_ma_TimerFrequency.QuadPart == 0) {
|
||||||
@@ -7867,63 +7867,63 @@ static void ma_timer_init(ma_timer* pTimer)
|
|||||||
|
|
||||||
QueryPerformanceCounter(&counter);
|
QueryPerformanceCounter(&counter);
|
||||||
pTimer->counter = counter.QuadPart;
|
pTimer->counter = counter.QuadPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER counter;
|
LARGE_INTEGER counter;
|
||||||
if (!QueryPerformanceCounter(&counter)) {
|
if (!QueryPerformanceCounter(&counter)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (double)(counter.QuadPart - pTimer->counter) / g_ma_TimerFrequency.QuadPart;
|
return (double)(counter.QuadPart - pTimer->counter) / g_ma_TimerFrequency.QuadPart;
|
||||||
}
|
}
|
||||||
#elif defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
|
#elif defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200)
|
||||||
ma_uint64 g_ma_TimerFrequency = 0;
|
static ma_uint64 g_ma_TimerFrequency = 0;
|
||||||
static void ma_timer_init(ma_timer* pTimer)
|
static void ma_timer_init(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
mach_timebase_info_data_t baseTime;
|
mach_timebase_info_data_t baseTime;
|
||||||
mach_timebase_info(&baseTime);
|
mach_timebase_info(&baseTime);
|
||||||
g_ma_TimerFrequency = (baseTime.denom * 1e9) / baseTime.numer;
|
g_ma_TimerFrequency = (baseTime.denom * 1e9) / baseTime.numer;
|
||||||
|
|
||||||
pTimer->counter = mach_absolute_time();
|
pTimer->counter = mach_absolute_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
ma_uint64 newTimeCounter = mach_absolute_time();
|
ma_uint64 newTimeCounter = mach_absolute_time();
|
||||||
ma_uint64 oldTimeCounter = pTimer->counter;
|
ma_uint64 oldTimeCounter = pTimer->counter;
|
||||||
|
|
||||||
return (newTimeCounter - oldTimeCounter) / g_ma_TimerFrequency;
|
return (newTimeCounter - oldTimeCounter) / g_ma_TimerFrequency;
|
||||||
}
|
}
|
||||||
#elif defined(MA_EMSCRIPTEN)
|
#elif defined(MA_EMSCRIPTEN)
|
||||||
static MA_INLINE void ma_timer_init(ma_timer* pTimer)
|
static MA_INLINE void ma_timer_init(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
pTimer->counterD = emscripten_get_now();
|
pTimer->counterD = emscripten_get_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
static MA_INLINE double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
static MA_INLINE double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
return (emscripten_get_now() - pTimer->counterD) / 1000; /* Emscripten is in milliseconds. */
|
return (emscripten_get_now() - pTimer->counterD) / 1000; /* Emscripten is in milliseconds. */
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if _POSIX_C_SOURCE >= 199309L
|
#if _POSIX_C_SOURCE >= 199309L
|
||||||
#if defined(CLOCK_MONOTONIC)
|
#if defined(CLOCK_MONOTONIC)
|
||||||
#define MA_CLOCK_ID CLOCK_MONOTONIC
|
#define MA_CLOCK_ID CLOCK_MONOTONIC
|
||||||
#else
|
#else
|
||||||
#define MA_CLOCK_ID CLOCK_REALTIME
|
#define MA_CLOCK_ID CLOCK_REALTIME
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ma_timer_init(ma_timer* pTimer)
|
static void ma_timer_init(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
struct timespec newTime;
|
struct timespec newTime;
|
||||||
clock_gettime(MA_CLOCK_ID, &newTime);
|
clock_gettime(MA_CLOCK_ID, &newTime);
|
||||||
|
|
||||||
pTimer->counter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
|
pTimer->counter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
ma_uint64 newTimeCounter;
|
ma_uint64 newTimeCounter;
|
||||||
ma_uint64 oldTimeCounter;
|
ma_uint64 oldTimeCounter;
|
||||||
|
|
||||||
@@ -7934,18 +7934,18 @@ static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
|||||||
oldTimeCounter = pTimer->counter;
|
oldTimeCounter = pTimer->counter;
|
||||||
|
|
||||||
return (newTimeCounter - oldTimeCounter) / 1000000000.0;
|
return (newTimeCounter - oldTimeCounter) / 1000000000.0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void ma_timer_init(ma_timer* pTimer)
|
static void ma_timer_init(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
struct timeval newTime;
|
struct timeval newTime;
|
||||||
gettimeofday(&newTime, NULL);
|
gettimeofday(&newTime, NULL);
|
||||||
|
|
||||||
pTimer->counter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
|
pTimer->counter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
||||||
{
|
{
|
||||||
ma_uint64 newTimeCounter;
|
ma_uint64 newTimeCounter;
|
||||||
ma_uint64 oldTimeCounter;
|
ma_uint64 oldTimeCounter;
|
||||||
|
|
||||||
@@ -7956,8 +7956,8 @@ static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
|
|||||||
oldTimeCounter = pTimer->counter;
|
oldTimeCounter = pTimer->counter;
|
||||||
|
|
||||||
return (newTimeCounter - oldTimeCounter) / 1000000.0;
|
return (newTimeCounter - oldTimeCounter) / 1000000.0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user