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
d0e735ee
Commit
d0e735ee
authored
Dec 14, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
player/Thread: mutex must be locked inside CheckDecoderStartup()
parent
ece59710
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
22 deletions
+21
-22
Thread.cxx
src/player/Thread.cxx
+21
-22
No files found.
src/player/Thread.cxx
View file @
d0e735ee
...
...
@@ -200,7 +200,7 @@ private:
* ActivateDecoder()). This function checks if the decoder
* initialization has completed yet.
*
*
The player lock is not held
.
*
Caller must lock the mutex
.
*/
bool
CheckDecoderStartup
();
...
...
@@ -213,14 +213,19 @@ private:
* allowed to be used while a command is being handled.
*/
bool
WaitDecoderStartup
()
{
const
ScopeLock
lock
(
pc
.
mutex
);
while
(
decoder_starting
)
{
if
(
!
CheckDecoderStartup
())
{
/* if decoder startup fails, make sure
the previous song is not being
played anymore */
pc
.
outputs
.
Cancel
();
{
const
ScopeUnlock
unlock
(
pc
.
mutex
);
pc
.
outputs
.
Cancel
();
}
pc
.
Lock
CommandFinished
();
pc
.
CommandFinished
();
return
false
;
}
}
...
...
@@ -487,36 +492,28 @@ Player::CheckDecoderStartup()
{
assert
(
decoder_starting
);
pc
.
Lock
();
if
(
!
ForwardDecoderError
())
{
/* the decoder failed */
pc
.
Unlock
();
return
false
;
}
else
if
(
!
dc
.
IsStarting
())
{
/* the decoder is ready and ok */
pc
.
Unlock
();
if
(
output_open
&&
!
pc
.
Lock
WaitOutputConsumed
(
1
))
!
pc
.
WaitOutputConsumed
(
1
))
/* the output devices havn't finished playing
all chunks yet - wait for that */
return
true
;
{
const
ScopeLock
lock
(
pc
.
mutex
);
pc
.
total_time
=
real_song_duration
(
*
dc
.
song
,
dc
.
total_time
);
pc
.
audio_format
=
dc
.
in_audio_format
;
}
idle_add
(
IDLE_PLAYER
);
pc
.
total_time
=
real_song_duration
(
*
dc
.
song
,
dc
.
total_time
);
pc
.
audio_format
=
dc
.
in_audio_format
;
play_audio_format
=
dc
.
out_audio_format
;
decoder_starting
=
false
;
const
ScopeUnlock
unlock
(
pc
.
mutex
);
idle_add
(
IDLE_PLAYER
);
if
(
!
paused
&&
!
OpenOutput
())
{
FormatError
(
player_domain
,
"problems opening audio device "
...
...
@@ -530,7 +527,6 @@ Player::CheckDecoderStartup()
/* the decoder is not yet ready; wait
some more */
dc
.
WaitForDecoder
();
pc
.
Unlock
();
return
true
;
}
...
...
@@ -1011,10 +1007,13 @@ Player::Run()
if
(
decoder_starting
)
{
/* wait until the decoder is initialized completely */
if
(
!
CheckDecoderStartup
())
pc
.
Lock
();
if
(
!
CheckDecoderStartup
())
{
pc
.
Unlock
();
break
;
}
pc
.
Lock
();
continue
;
}
...
...
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