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
1617261b
Commit
1617261b
authored
Oct 19, 2016
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALSA: Fix a bug with timers for non-Windows platforms.
parent
f9130d74
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
mini_al.h
mini_al.h
+5
-6
No files found.
mini_al.h
View file @
1617261b
...
@@ -620,7 +620,7 @@ static int mal_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size
...
@@ -620,7 +620,7 @@ static int mal_strncpy_s(char* dst, size_t dstSizeInBytes, const char* src, size
}
}
// Thanks to good old Bit Twiddling Hacks for this one: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
// Thanks to good old Bit Twiddling Hacks for this one: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
static
unsigned
int
mal_next_power_of_2
(
unsigned
int
x
)
static
inline
unsigned
int
mal_next_power_of_2
(
unsigned
int
x
)
{
{
x
--
;
x
--
;
x
|=
x
>>
1
;
x
|=
x
>>
1
;
...
@@ -633,7 +633,7 @@ static unsigned int mal_next_power_of_2(unsigned int x)
...
@@ -633,7 +633,7 @@ static unsigned int mal_next_power_of_2(unsigned int x)
return
x
;
return
x
;
}
}
static
unsigned
int
mal_prev_power_of_2
(
unsigned
int
x
)
static
inline
unsigned
int
mal_prev_power_of_2
(
unsigned
int
x
)
{
{
return
mal_next_power_of_2
(
x
)
>>
1
;
return
mal_next_power_of_2
(
x
)
>>
1
;
}
}
...
@@ -693,7 +693,7 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer)
...
@@ -693,7 +693,7 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer)
void
mal_timer_init
(
mal_timer
*
pTimer
)
void
mal_timer_init
(
mal_timer
*
pTimer
)
{
{
struct
timespec
newTime
;
struct
timespec
newTime
;
clock_gettime
(
CLOCK_
PROCESS_CPUTIME_ID
,
&
newTime
);
clock_gettime
(
CLOCK_
MONOTONIC
,
&
newTime
);
pTimer
->
counter
=
(
newTime
.
tv_sec
*
1000000000LL
)
+
newTime
.
tv_nsec
;
pTimer
->
counter
=
(
newTime
.
tv_sec
*
1000000000LL
)
+
newTime
.
tv_nsec
;
}
}
...
@@ -701,7 +701,7 @@ void mal_timer_init(mal_timer* pTimer)
...
@@ -701,7 +701,7 @@ void mal_timer_init(mal_timer* pTimer)
double
mal_timer_get_time_in_seconds
(
mal_timer
*
pTimer
)
double
mal_timer_get_time_in_seconds
(
mal_timer
*
pTimer
)
{
{
struct
timespec
newTime
;
struct
timespec
newTime
;
clock_gettime
(
CLOCK_
PROCESS_CPUTIME_ID
,
&
newTime
);
clock_gettime
(
CLOCK_
MONOTONIC
,
&
newTime
);
uint64_t
newTimeCounter
=
(
newTime
.
tv_sec
*
1000000000LL
)
+
newTime
.
tv_nsec
;
uint64_t
newTimeCounter
=
(
newTime
.
tv_sec
*
1000000000LL
)
+
newTime
.
tv_nsec
;
uint64_t
oldTimeCounter
=
pTimer
->
counter
;
uint64_t
oldTimeCounter
=
pTimer
->
counter
;
...
@@ -2220,7 +2220,6 @@ static mal_result mal_device_init__alsa(mal_device* pDevice, mal_device_type typ
...
@@ -2220,7 +2220,6 @@ static mal_result mal_device_init__alsa(mal_device* pDevice, mal_device_type typ
}
}
pDevice
->
sampleRate
=
sampleRate
;
pDevice
->
sampleRate
=
sampleRate
;
// Channels.
// Channels.
if
(
snd_pcm_hw_params_set_channels_near
((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
pHWParams
,
&
channels
)
<
0
)
{
if
(
snd_pcm_hw_params_set_channels_near
((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
pHWParams
,
&
channels
)
<
0
)
{
mal_device_uninit__alsa
(
pDevice
);
mal_device_uninit__alsa
(
pDevice
);
...
@@ -2245,7 +2244,7 @@ static mal_result mal_device_init__alsa(mal_device* pDevice, mal_device_type typ
...
@@ -2245,7 +2244,7 @@ static mal_result mal_device_init__alsa(mal_device* pDevice, mal_device_type typ
// Periods.
// Periods.
int
dir
=
1
;
int
dir
=
0
;
if
(
snd_pcm_hw_params_set_periods_near
((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
pHWParams
,
&
fragmentCount
,
&
dir
)
<
0
)
{
if
(
snd_pcm_hw_params_set_periods_near
((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
pHWParams
,
&
fragmentCount
,
&
dir
)
<
0
)
{
mal_device_uninit__alsa
(
pDevice
);
mal_device_uninit__alsa
(
pDevice
);
return
mal_post_error
(
pDevice
,
"[ALSA] Failed to set fragment count. snd_pcm_hw_params_set_periods_near() failed."
,
MAL_FORMAT_NOT_SUPPORTED
);
return
mal_post_error
(
pDevice
,
"[ALSA] Failed to set fragment count. snd_pcm_hw_params_set_periods_near() failed."
,
MAL_FORMAT_NOT_SUPPORTED
);
...
...
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