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
4c434f15
Commit
4c434f15
authored
Nov 07, 2017
by
David Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ALSA: Another attempt at fixing mmap mode.
parent
11a77313
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
21 deletions
+23
-21
mini_al.h
mini_al.h
+23
-21
No files found.
mini_al.h
View file @
4c434f15
...
...
@@ -5102,19 +5102,34 @@ static mal_uint32 mal_device__wait_for_frames__alsa(mal_device* pDevice, mal_boo
mal_uint32
periodSizeInFrames
=
pDevice
->
bufferSizeInFrames
/
pDevice
->
periods
;
while
(
!
pDevice
->
alsa
.
breakFromMainLoop
)
{
snd_pcm_sframes_t
framesAvailable
=
((
mal_snd_pcm_avail_update_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_avail_update
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
);
// Wait for something to become available. The timeout should not affect latency - it's only used to break from the wait
// so we can check whether or not the device has been stopped.
const
int
timeoutInMilliseconds
=
10
;
int
waitResult
=
((
mal_snd_pcm_wait_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_wait
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
timeoutInMilliseconds
);
if
(
waitResult
<
0
)
{
if
(
waitResult
==
-
EPIPE
)
{
if
(((
mal_snd_pcm_recover_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_recover
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
waitResult
,
MAL_TRUE
)
<
0
)
{
return
0
;
}
// Keep the returned number of samples consistent and based on the period size.
if
(
framesAvailable
>=
periodSizeInFrames
)
{
return
periodSizeInFrames
;
if
(
pRequiresRestart
)
*
pRequiresRestart
=
MAL_TRUE
;
// A device recovery means a restart for mmap mode.
}
}
if
(
pDevice
->
alsa
.
breakFromMainLoop
)
{
return
0
;
}
snd_pcm_sframes_t
framesAvailable
=
((
mal_snd_pcm_avail_update_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_avail_update
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
);
if
(
framesAvailable
<
0
)
{
if
(
framesAvailable
==
-
EPIPE
)
{
if
(((
mal_snd_pcm_recover_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_recover
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
framesAvailable
,
MAL_TRUE
)
<
0
)
{
return
0
;
}
if
(
pRequiresRestart
)
*
pRequiresRestart
=
MAL_TRUE
;
// A device recovery means a restart for mmap mode.
// Try again, but if it fails this time just return an error.
framesAvailable
=
((
mal_snd_pcm_avail_update_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_avail_update
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
);
if
(
framesAvailable
<
0
)
{
return
0
;
...
...
@@ -5122,22 +5137,9 @@ static mal_uint32 mal_device__wait_for_frames__alsa(mal_device* pDevice, mal_boo
}
}
const
int
timeoutInMilliseconds
=
1
;
// <-- The larger this value, the longer it'll take to stop the device!
int
waitResult
=
((
mal_snd_pcm_wait_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_wait
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
timeoutInMilliseconds
);
if
(
waitResult
<
0
)
{
if
(
waitResult
==
-
EPIPE
)
{
if
(((
mal_snd_pcm_recover_proc
)
pDevice
->
pContext
->
alsa
.
snd_pcm_recover
)((
snd_pcm_t
*
)
pDevice
->
alsa
.
pPCM
,
waitResult
,
MAL_TRUE
)
<
0
)
{
return
0
;
}
if
(
pRequiresRestart
)
{
*
pRequiresRestart
=
MAL_TRUE
;
}
return
pDevice
->
bufferSizeInFrames
;
}
else
{
return
0
;
}
// Keep the returned number of samples consistent and based on the period size.
if
(
framesAvailable
>=
periodSizeInFrames
)
{
return
periodSizeInFrames
;
}
}
...
...
@@ -5161,7 +5163,7 @@ static mal_bool32 mal_device_write__alsa(mal_device* pDevice)
}
if
(
pDevice
->
alsa
.
pIntermediaryBuffer
==
NULL
)
{
if
(
pDevice
->
alsa
.
isUsingMMap
)
{
// mmap.
mal_bool32
requiresRestart
;
mal_uint32
framesAvailable
=
mal_device__wait_for_frames__alsa
(
pDevice
,
&
requiresRestart
);
...
...
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