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
485ed0b1
Commit
485ed0b1
authored
Apr 26, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/alsa: make the "active" attribute thread-safe
parent
7d546f80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+12
-4
No files found.
src/output/plugins/AlsaOutputPlugin.cxx
View file @
485ed0b1
...
...
@@ -123,8 +123,7 @@ class AlsaOutput final
* After Open(), has this output been activated by a Play()
* command?
*
* This attribute is not thread-safe. It is only used by the
* client thread (the thread which calls AudioOutput public methods).
* Protected by #mutex.
*/
bool
active
;
...
...
@@ -162,7 +161,7 @@ class AlsaOutput final
Alsa
::
PeriodBuffer
period_buffer
;
/**
* Protects #cond, #error, #drain.
* Protects #cond, #error, #
active, #
drain.
*/
mutable
Mutex
mutex
;
...
...
@@ -228,6 +227,12 @@ private:
#endif
);
gcc_pure
bool
LockIsActive
()
const
noexcept
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
return
active
;
}
/**
* Activate the output by registering the sockets in the
* #EventLoop. Before calling this, filling the ring buffer
...
...
@@ -784,7 +789,7 @@ AlsaOutput::CancelInternal() noexcept
void
AlsaOutput
::
Cancel
()
noexcept
{
if
(
!
active
)
{
if
(
!
LockIsActive
()
)
{
/* early cancel, quick code path without thread
synchronization */
...
...
@@ -880,6 +885,9 @@ AlsaOutput::DispatchSockets() noexcept
try
{
{
const
std
::
lock_guard
<
Mutex
>
lock
(
mutex
);
assert
(
active
);
if
(
drain
)
{
{
ScopeUnlock
unlock
(
mutex
);
...
...
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