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
15a54230
Commit
15a54230
authored
Dec 22, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Thread: move unlock call down
Eliminate more unlock/lock transitions, making the code more robust.
parent
f0d18488
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
Thread.cxx
src/player/Thread.cxx
+12
-13
No files found.
src/player/Thread.cxx
View file @
15a54230
...
...
@@ -989,23 +989,23 @@ Player::Run() noexcept
break
;
}
pc
.
Unlock
();
if
(
buffering
)
{
/* buffering at the start of the song - wait
until the buffer is large enough, to
prevent stuttering on slow machines */
if
(
pipe
->
GetSize
()
<
pc
.
buffered_before_play
&&
!
dc
.
Lock
IsIdle
())
{
!
dc
.
IsIdle
())
{
/* not enough decoded buffer space yet */
if
(
!
paused
&&
output_open
&&
pc
.
outputs
.
Check
()
<
4
&&
!
SendSilence
())
break
;
{
const
ScopeUnlock
unlock
(
pc
.
mutex
);
if
(
!
paused
&&
output_open
&&
pc
.
outputs
.
Check
()
<
4
&&
!
SendSilence
())
break
;
}
pc
.
Lock
();
/* XXX race condition: check decoder again */
dc
.
WaitForDecoder
();
continue
;
...
...
@@ -1018,8 +1018,6 @@ Player::Run() noexcept
if
(
decoder_starting
)
{
/* wait until the decoder is initialized completely */
pc
.
Lock
();
if
(
!
CheckDecoderStartup
())
{
pc
.
Unlock
();
break
;
...
...
@@ -1028,13 +1026,12 @@ Player::Run() noexcept
continue
;
}
if
(
dc
.
Lock
IsIdle
()
&&
queued
&&
dc
.
pipe
==
pipe
)
{
if
(
dc
.
IsIdle
()
&&
queued
&&
dc
.
pipe
==
pipe
)
{
/* the decoder has finished the current song;
make it decode the next song */
assert
(
dc
.
pipe
==
nullptr
||
dc
.
pipe
==
pipe
);
const
std
::
lock_guard
<
Mutex
>
lock
(
pc
.
mutex
);
StartDecoder
(
*
new
MusicPipe
());
}
...
...
@@ -1043,7 +1040,7 @@ Player::Run() noexcept
!
pc
.
border_pause
&&
IsDecoderAtNextSong
()
&&
xfade_state
==
CrossFadeState
::
UNKNOWN
&&
!
dc
.
Lock
IsStarting
())
{
!
dc
.
IsStarting
())
{
/* enable cross fading in this song? if yes,
calculate how many chunks will be required
for it */
...
...
@@ -1065,6 +1062,8 @@ Player::Run() noexcept
xfade_state
=
CrossFadeState
::
DISABLED
;
}
pc
.
Unlock
();
if
(
paused
)
{
pc
.
Lock
();
...
...
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