player/Thread: hold mutex while calling SongBorder()
Eliminates unnecessary mutex locks.
This commit is contained in:
@@ -414,11 +414,6 @@ public:
|
|||||||
return border_pause;
|
return border_pause;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LockApplyBorderPause() noexcept {
|
|
||||||
const std::lock_guard<Mutex> lock(mutex);
|
|
||||||
return ApplyBorderPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Kill() noexcept;
|
void Kill() noexcept;
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
|
@@ -333,7 +333,7 @@ private:
|
|||||||
* has consumed all chunks of the current song, and we should start
|
* has consumed all chunks of the current song, and we should start
|
||||||
* sending chunks from the next one.
|
* sending chunks from the next one.
|
||||||
*
|
*
|
||||||
* The player lock is not held.
|
* Caller must lock the mutex.
|
||||||
*/
|
*/
|
||||||
void SongBorder() noexcept;
|
void SongBorder() noexcept;
|
||||||
|
|
||||||
@@ -968,20 +968,22 @@ Player::PlayNextChunk() noexcept
|
|||||||
inline void
|
inline void
|
||||||
Player::SongBorder() noexcept
|
Player::SongBorder() noexcept
|
||||||
{
|
{
|
||||||
FormatDefault(player_domain, "played \"%s\"", song->GetURI());
|
|
||||||
|
|
||||||
throttle_silence_log.Reset();
|
|
||||||
|
|
||||||
ReplacePipe(dc.pipe);
|
|
||||||
|
|
||||||
pc.outputs.SongBorder();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const std::lock_guard<Mutex> lock(pc.mutex);
|
const ScopeUnlock unlock(pc.mutex);
|
||||||
ActivateDecoder();
|
|
||||||
|
FormatDefault(player_domain, "played \"%s\"", song->GetURI());
|
||||||
|
|
||||||
|
throttle_silence_log.Reset();
|
||||||
|
|
||||||
|
ReplacePipe(dc.pipe);
|
||||||
|
|
||||||
|
|
||||||
|
pc.outputs.SongBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool border_pause = pc.LockApplyBorderPause();
|
ActivateDecoder();
|
||||||
|
|
||||||
|
const bool border_pause = pc.ApplyBorderPause();
|
||||||
if (border_pause) {
|
if (border_pause) {
|
||||||
paused = true;
|
paused = true;
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
@@ -1101,7 +1103,6 @@ Player::Run() noexcept
|
|||||||
} else if (IsDecoderAtNextSong()) {
|
} else if (IsDecoderAtNextSong()) {
|
||||||
/* at the beginning of a new song */
|
/* at the beginning of a new song */
|
||||||
|
|
||||||
const ScopeUnlock unlock(pc.mutex);
|
|
||||||
SongBorder();
|
SongBorder();
|
||||||
} else if (dc.IsIdle()) {
|
} else if (dc.IsIdle()) {
|
||||||
/* check the size of the pipe again, because
|
/* check the size of the pipe again, because
|
||||||
|
Reference in New Issue
Block a user