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
a1f902d1
Commit
a1f902d1
authored
Mar 08, 2020
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor formatting for improved readability.
parent
427f1f99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
79 deletions
+79
-79
miniaudio.h
miniaudio.h
+79
-79
No files found.
miniaudio.h
View file @
a1f902d1
...
@@ -7856,108 +7856,108 @@ Timing
...
@@ -7856,108 +7856,108 @@ 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) {
QueryPerformanceFrequency(&g_ma_TimerFrequency);
}
if (g_ma_TimerFrequency.QuadPart == 0) {
QueryPerformanceCounter(&counter);
QueryPerformanceFrequency(&g_ma_TimerFrequency)
;
pTimer->counter = counter.QuadPart
;
}
}
QueryPerformanceCounter(&counter);
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
pTimer->counter = counter.QuadPart;
{
}
LARGE_INTEGER counter;
if (!QueryPerformanceCounter(&counter)) {
return 0;
}
static double ma_timer_get_time_in_seconds(ma_timer* pTimer)
return (double)(counter.QuadPart - pTimer->counter) / g_ma_TimerFrequency.QuadPart;
{
LARGE_INTEGER counter;
if (!QueryPerformanceCounter(&counter)) {
return 0;
}
}
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
#if _POSIX_C_SOURCE >= 199309L
#if defined(CLOCK_MONOTONIC)
#define MA_CLOCK_ID CLOCK_MONOTONIC
#else
#else
#define MA_CLOCK_ID CLOCK_REALTIME
#if _POSIX_C_SOURCE >= 199309L
#endif
#if defined(CLOCK_MONOTONIC)
#define MA_CLOCK_ID CLOCK_MONOTONIC
#else
#define MA_CLOCK_ID CLOCK_REALTIME
#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;
struct timespec newTime;
struct timespec newTime;
clock_gettime(MA_CLOCK_ID, &newTime);
clock_gettime(MA_CLOCK_ID, &newTime);
newTimeCounter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
newTimeCounter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec;
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;
struct timeval newTime;
struct timeval newTime;
gettimeofday(&newTime, NULL);
gettimeofday(&newTime, NULL);
newTimeCounter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
newTimeCounter = (newTime.tv_sec * 1000000) + newTime.tv_usec;
oldTimeCounter = pTimer->counter;
oldTimeCounter = pTimer->counter;
return (newTimeCounter - oldTimeCounter) / 1000000.0;
return (newTimeCounter - oldTimeCounter) / 1000000.0;
}
}
#endif
#endif
#endif
#endif
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