player/Thread: move mutex lock out of ActivateDecoder()
This commit is contained in:
@@ -299,7 +299,7 @@ private:
|
|||||||
* yet, therefore we don't know the audio format yet. To
|
* yet, therefore we don't know the audio format yet. To
|
||||||
* finish decoder startup, call CheckDecoderStartup().
|
* finish decoder startup, call CheckDecoderStartup().
|
||||||
*
|
*
|
||||||
* The player lock is not held.
|
* Caller must lock the mutex.
|
||||||
*/
|
*/
|
||||||
void ActivateDecoder() noexcept;
|
void ActivateDecoder() noexcept;
|
||||||
|
|
||||||
@@ -419,9 +419,6 @@ Player::ActivateDecoder() noexcept
|
|||||||
|
|
||||||
queued = false;
|
queued = false;
|
||||||
|
|
||||||
{
|
|
||||||
const std::lock_guard<Mutex> lock(pc.mutex);
|
|
||||||
|
|
||||||
pc.ClearTaggedSong();
|
pc.ClearTaggedSong();
|
||||||
|
|
||||||
song = std::exchange(pc.next_song, nullptr);
|
song = std::exchange(pc.next_song, nullptr);
|
||||||
@@ -436,11 +433,13 @@ Player::ActivateDecoder() noexcept
|
|||||||
pc.total_time = song->GetDuration();
|
pc.total_time = song->GetDuration();
|
||||||
pc.bit_rate = 0;
|
pc.bit_rate = 0;
|
||||||
pc.audio_format.Clear();
|
pc.audio_format.Clear();
|
||||||
}
|
|
||||||
|
|
||||||
|
{
|
||||||
/* call syncPlaylistWithQueue() in the main thread */
|
/* call syncPlaylistWithQueue() in the main thread */
|
||||||
|
const ScopeUnlock unlock(pc.mutex);
|
||||||
pc.listener.OnPlayerSync();
|
pc.listener.OnPlayerSync();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the real duration of the song, comprising the duration
|
* Returns the real duration of the song, comprising the duration
|
||||||
@@ -634,9 +633,9 @@ Player::SeekDecoder() noexcept
|
|||||||
|
|
||||||
/* re-start the decoder */
|
/* re-start the decoder */
|
||||||
StartDecoder(*pipe);
|
StartDecoder(*pipe);
|
||||||
|
const std::lock_guard<Mutex> lock(pc.mutex);
|
||||||
ActivateDecoder();
|
ActivateDecoder();
|
||||||
|
|
||||||
const std::lock_guard<Mutex> lock(pc.mutex);
|
|
||||||
if (!WaitDecoderStartup())
|
if (!WaitDecoderStartup())
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -966,7 +965,10 @@ Player::SongBorder() noexcept
|
|||||||
|
|
||||||
pc.outputs.SongBorder();
|
pc.outputs.SongBorder();
|
||||||
|
|
||||||
|
{
|
||||||
|
const std::lock_guard<Mutex> lock(pc.mutex);
|
||||||
ActivateDecoder();
|
ActivateDecoder();
|
||||||
|
}
|
||||||
|
|
||||||
const bool border_pause = pc.LockApplyBorderPause();
|
const bool border_pause = pc.LockApplyBorderPause();
|
||||||
if (border_pause) {
|
if (border_pause) {
|
||||||
@@ -981,9 +983,9 @@ Player::Run() noexcept
|
|||||||
pipe = new MusicPipe();
|
pipe = new MusicPipe();
|
||||||
|
|
||||||
StartDecoder(*pipe);
|
StartDecoder(*pipe);
|
||||||
|
pc.Lock();
|
||||||
ActivateDecoder();
|
ActivateDecoder();
|
||||||
|
|
||||||
pc.Lock();
|
|
||||||
pc.state = PlayerState::PLAY;
|
pc.state = PlayerState::PLAY;
|
||||||
|
|
||||||
pc.CommandFinished();
|
pc.CommandFinished();
|
||||||
|
Reference in New Issue
Block a user