player/Thread: remove decoder error check from ActivateDecoder()
It is futile to check for decoder errors before the decoder has finished startup. At this time, it's unlikely that the decoder has already failed.
This commit is contained in:
parent
ccea6dd74b
commit
cf1de78205
@ -260,7 +260,7 @@ private:
|
|||||||
*
|
*
|
||||||
* The player lock is not held.
|
* The player lock is not held.
|
||||||
*/
|
*/
|
||||||
bool ActivateDecoder();
|
void ActivateDecoder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for MultipleOutputs::Open(). Upon failure, it
|
* Wrapper for MultipleOutputs::Open(). Upon failure, it
|
||||||
@ -298,10 +298,8 @@ private:
|
|||||||
* sending chunks from the next one.
|
* sending chunks from the next one.
|
||||||
*
|
*
|
||||||
* The player lock is not held.
|
* The player lock is not held.
|
||||||
*
|
|
||||||
* @return true on success, false on error (playback will be stopped)
|
|
||||||
*/
|
*/
|
||||||
bool SongBorder();
|
void SongBorder();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*
|
/*
|
||||||
@ -369,7 +367,7 @@ Player::ForwardDecoderError()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
Player::ActivateDecoder()
|
Player::ActivateDecoder()
|
||||||
{
|
{
|
||||||
assert(queued || pc.command == PlayerCommand::SEEK);
|
assert(queued || pc.command == PlayerCommand::SEEK);
|
||||||
@ -378,16 +376,6 @@ Player::ActivateDecoder()
|
|||||||
queued = false;
|
queued = false;
|
||||||
|
|
||||||
pc.Lock();
|
pc.Lock();
|
||||||
|
|
||||||
if (!ForwardDecoderError()) {
|
|
||||||
delete pc.next_song;
|
|
||||||
pc.next_song = nullptr;
|
|
||||||
|
|
||||||
pc.Unlock();
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
pc.ClearTaggedSong();
|
pc.ClearTaggedSong();
|
||||||
|
|
||||||
delete song;
|
delete song;
|
||||||
@ -409,8 +397,6 @@ Player::ActivateDecoder()
|
|||||||
|
|
||||||
/* call syncPlaylistWithQueue() in the main thread */
|
/* call syncPlaylistWithQueue() in the main thread */
|
||||||
pc.listener.OnPlayerSync();
|
pc.listener.OnPlayerSync();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -579,11 +565,7 @@ Player::SeekDecoder()
|
|||||||
|
|
||||||
/* re-start the decoder */
|
/* re-start the decoder */
|
||||||
StartDecoder(*pipe);
|
StartDecoder(*pipe);
|
||||||
if (!ActivateDecoder()) {
|
ActivateDecoder();
|
||||||
/* decoder failure */
|
|
||||||
player_command_finished(pc);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!IsDecoderAtCurrentSong()) {
|
if (!IsDecoderAtCurrentSong()) {
|
||||||
/* the decoder is already decoding the "next" song,
|
/* the decoder is already decoding the "next" song,
|
||||||
@ -933,7 +915,7 @@ Player::PlayNextChunk()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline void
|
||||||
Player::SongBorder()
|
Player::SongBorder()
|
||||||
{
|
{
|
||||||
FormatDefault(player_domain, "played \"%s\"", song->GetURI());
|
FormatDefault(player_domain, "played \"%s\"", song->GetURI());
|
||||||
@ -942,8 +924,7 @@ Player::SongBorder()
|
|||||||
|
|
||||||
pc.outputs.SongBorder();
|
pc.outputs.SongBorder();
|
||||||
|
|
||||||
if (!ActivateDecoder())
|
ActivateDecoder();
|
||||||
return false;
|
|
||||||
|
|
||||||
pc.Lock();
|
pc.Lock();
|
||||||
|
|
||||||
@ -957,8 +938,6 @@ Player::SongBorder()
|
|||||||
|
|
||||||
if (border_pause)
|
if (border_pause)
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
@ -967,14 +946,7 @@ Player::Run()
|
|||||||
pipe = new MusicPipe();
|
pipe = new MusicPipe();
|
||||||
|
|
||||||
StartDecoder(*pipe);
|
StartDecoder(*pipe);
|
||||||
if (!ActivateDecoder()) {
|
ActivateDecoder();
|
||||||
assert(song == nullptr);
|
|
||||||
|
|
||||||
StopDecoder();
|
|
||||||
player_command_finished(pc);
|
|
||||||
delete pipe;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pc.Lock();
|
pc.Lock();
|
||||||
pc.state = PlayerState::PLAY;
|
pc.state = PlayerState::PLAY;
|
||||||
@ -1101,8 +1073,7 @@ Player::Run()
|
|||||||
} else if (IsDecoderAtNextSong()) {
|
} else if (IsDecoderAtNextSong()) {
|
||||||
/* at the beginning of a new song */
|
/* at the beginning of a new song */
|
||||||
|
|
||||||
if (!SongBorder())
|
SongBorder();
|
||||||
break;
|
|
||||||
} else if (dc.LockIsIdle()) {
|
} else if (dc.LockIsIdle()) {
|
||||||
/* check the size of the pipe again, because
|
/* check the size of the pipe again, because
|
||||||
the decoder thread may have added something
|
the decoder thread may have added something
|
||||||
|
Loading…
Reference in New Issue
Block a user