Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7d579e74
Commit
7d579e74
authored
Nov 14, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/alsa/NonBlock: throw exception on error
Avoid another potential deadlock: if no file descriptors are registered, our non-blocking ALSA code cannot ever work.
parent
e0f777d4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
NonBlock.cxx
src/lib/alsa/NonBlock.cxx
+14
-5
NonBlock.hxx
src/lib/alsa/NonBlock.hxx
+3
-1
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+7
-1
No files found.
src/lib/alsa/NonBlock.cxx
View file @
7d579e74
...
...
@@ -20,22 +20,31 @@
#include "config.h"
#include "NonBlock.hxx"
#include "event/MultiSocketMonitor.hxx"
#include "util/RuntimeError.hxx"
std
::
chrono
::
steady_clock
::
duration
PrepareAlsaPcmSockets
(
MultiSocketMonitor
&
m
,
snd_pcm_t
*
pcm
,
ReusableArray
<
pollfd
>
&
pfd_buffer
)
noexcept
ReusableArray
<
pollfd
>
&
pfd_buffer
)
{
int
count
=
snd_pcm_poll_descriptors_count
(
pcm
);
if
(
count
<=
0
)
{
m
.
ClearSocketList
();
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
if
(
count
==
0
)
throw
std
::
runtime_error
(
"snd_pcm_poll_descriptors_count() failed"
);
else
throw
FormatRuntimeError
(
"snd_pcm_poll_descriptors_count() failed: %s"
,
snd_strerror
(
-
count
));
}
struct
pollfd
*
pfds
=
pfd_buffer
.
Get
(
count
);
count
=
snd_pcm_poll_descriptors
(
pcm
,
pfds
,
count
);
if
(
count
<
0
)
count
=
0
;
if
(
count
<=
0
)
{
if
(
count
==
0
)
throw
std
::
runtime_error
(
"snd_pcm_poll_descriptors() failed"
);
else
throw
FormatRuntimeError
(
"snd_pcm_poll_descriptors() failed: %s"
,
snd_strerror
(
-
count
));
}
m
.
ReplaceSocketList
(
pfds
,
count
);
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
...
...
src/lib/alsa/NonBlock.hxx
View file @
7d579e74
...
...
@@ -33,10 +33,12 @@ class MultiSocketMonitor;
* Update #MultiSocketMonitor's socket list from
* snd_pcm_poll_descriptors(). To be called from
* MultiSocketMonitor::PrepareSockets().
*
* Throws exception on error.
*/
std
::
chrono
::
steady_clock
::
duration
PrepareAlsaPcmSockets
(
MultiSocketMonitor
&
m
,
snd_pcm_t
*
pcm
,
ReusableArray
<
pollfd
>
&
pfd_buffer
)
noexcept
;
ReusableArray
<
pollfd
>
&
pfd_buffer
);
/**
* Update #MultiSocketMonitor's socket list from
...
...
src/output/plugins/AlsaOutputPlugin.cxx
View file @
7d579e74
...
...
@@ -815,7 +815,13 @@ AlsaOutput::PrepareSockets() noexcept
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
return
PrepareAlsaPcmSockets
(
*
this
,
pcm
,
pfd_buffer
);
try
{
return
PrepareAlsaPcmSockets
(
*
this
,
pcm
,
pfd_buffer
);
}
catch
(...)
{
ClearSocketList
();
LockCaughtError
();
return
std
::
chrono
::
steady_clock
::
duration
(
-
1
);
}
}
void
...
...
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