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
a431274b
Commit
a431274b
authored
Dec 20, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Control: add "occupied" flag to skip REFRESH
Reduces main thread contention. Avoids blocking the main thread in "status" commands.
parent
994c9a01
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletion
+30
-1
Control.cxx
src/player/Control.cxx
+3
-1
Control.hxx
src/player/Control.hxx
+23
-0
Thread.cxx
src/player/Thread.cxx
+4
-0
No files found.
src/player/Control.cxx
View file @
a431274b
...
...
@@ -44,6 +44,7 @@ PlayerControl::PlayerControl(PlayerListener &_listener,
PlayerControl
::~
PlayerControl
()
noexcept
{
assert
(
!
occupied
);
}
bool
...
...
@@ -155,7 +156,8 @@ PlayerControl::LockGetStatus() noexcept
player_status
status
;
const
std
::
lock_guard
<
Mutex
>
protect
(
mutex
);
SynchronousCommand
(
PlayerCommand
::
REFRESH
);
if
(
!
occupied
)
SynchronousCommand
(
PlayerCommand
::
REFRESH
);
status
.
state
=
state
;
...
...
src/player/Control.hxx
View file @
a431274b
...
...
@@ -185,6 +185,29 @@ struct PlayerControl final : AudioOutputClient {
*/
bool
border_pause
=
false
;
/**
* If this flag is set, then the player thread is currently
* occupied and will not be able to respond quickly to
* commands (e.g. waiting for the decoder thread to finish
* seeking). This is used to skip #PlayerCommand::REFRESH to
* avoid blocking the main thread.
*/
bool
occupied
=
false
;
struct
ScopeOccupied
{
PlayerControl
&
pc
;
explicit
ScopeOccupied
(
PlayerControl
&
_pc
)
noexcept
:
pc
(
_pc
)
{
assert
(
!
pc
.
occupied
);
pc
.
occupied
=
true
;
}
~
ScopeOccupied
()
noexcept
{
assert
(
pc
.
occupied
);
pc
.
occupied
=
false
;
}
};
AudioFormat
audio_format
;
uint16_t
bit_rate
;
...
...
src/player/Thread.cxx
View file @
a431274b
...
...
@@ -367,6 +367,8 @@ Player::StartDecoder(MusicPipe &_pipe) noexcept
void
Player
::
StopDecoder
()
noexcept
{
const
PlayerControl
::
ScopeOccupied
occupied
(
pc
);
dc
.
Stop
();
if
(
dc
.
pipe
!=
nullptr
)
{
...
...
@@ -624,6 +626,8 @@ Player::SeekDecoder() noexcept
}
try
{
const
PlayerControl
::
ScopeOccupied
occupied
(
pc
);
dc
.
Seek
(
where
+
start_time
);
}
catch
(...)
{
/* decoder failure */
...
...
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