player/Listener: add virtual method OnPlayerState(), wrapping IDLE_PLAYER
This eliminates most of the remaining global "player" idle events.
This commit is contained in:
parent
047561dc22
commit
64f84d5468
1
NEWS
1
NEWS
@ -2,6 +2,7 @@ ver 0.24 (not yet released)
|
|||||||
* protocol
|
* protocol
|
||||||
- "playlistfind"/"playlistsearch" have "sort" and "window" parameters
|
- "playlistfind"/"playlistsearch" have "sort" and "window" parameters
|
||||||
- filter "prio" (for "playlistfind"/"playlistsearch")
|
- filter "prio" (for "playlistfind"/"playlistsearch")
|
||||||
|
- limit "player" idle events to the current partition
|
||||||
* archive
|
* archive
|
||||||
- add option to disable archive plugins in mpd.conf
|
- add option to disable archive plugins in mpd.conf
|
||||||
* decoder
|
* decoder
|
||||||
|
@ -189,6 +189,12 @@ Partition::OnPlayerError() noexcept
|
|||||||
EmitIdle(IDLE_PLAYER);
|
EmitIdle(IDLE_PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Partition::OnPlayerStateChanged() noexcept
|
||||||
|
{
|
||||||
|
EmitIdle(IDLE_PLAYER);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Partition::OnPlayerSync() noexcept
|
Partition::OnPlayerSync() noexcept
|
||||||
{
|
{
|
||||||
|
@ -278,6 +278,7 @@ private:
|
|||||||
|
|
||||||
/* virtual methods from class PlayerListener */
|
/* virtual methods from class PlayerListener */
|
||||||
void OnPlayerError() noexcept override;
|
void OnPlayerError() noexcept override;
|
||||||
|
void OnPlayerStateChanged() noexcept override;
|
||||||
void OnPlayerSync() noexcept override;
|
void OnPlayerSync() noexcept override;
|
||||||
void OnPlayerTagModified() noexcept override;
|
void OnPlayerTagModified() noexcept override;
|
||||||
void OnBorderPause() noexcept override;
|
void OnBorderPause() noexcept override;
|
||||||
|
@ -28,6 +28,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void OnPlayerError() noexcept = 0;
|
virtual void OnPlayerError() noexcept = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some state of the player has changed. This maps to
|
||||||
|
* #IDLE_PLAYER.
|
||||||
|
*/
|
||||||
|
virtual void OnPlayerStateChanged() noexcept = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must call playlist_sync().
|
* Must call playlist_sync().
|
||||||
*/
|
*/
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
#include "CrossFade.hxx"
|
#include "CrossFade.hxx"
|
||||||
#include "pcm/MixRampGlue.hxx"
|
#include "pcm/MixRampGlue.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
#include "Idle.hxx"
|
|
||||||
#include "util/Compiler.h"
|
#include "util/Compiler.h"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "thread/Name.hxx"
|
#include "thread/Name.hxx"
|
||||||
@ -582,8 +581,7 @@ Player::OpenOutput() noexcept
|
|||||||
paused = false;
|
paused = false;
|
||||||
|
|
||||||
pc.state = PlayerState::PLAY;
|
pc.state = PlayerState::PLAY;
|
||||||
|
pc.listener.OnPlayerStateChanged();
|
||||||
idle_add(IDLE_PLAYER);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -617,7 +615,7 @@ Player::CheckDecoderStartup(std::unique_lock<Mutex> &lock) noexcept
|
|||||||
(buffer_before_play_size + sizeof(MusicChunk::data) - 1)
|
(buffer_before_play_size + sizeof(MusicChunk::data) - 1)
|
||||||
/ sizeof(MusicChunk::data);
|
/ sizeof(MusicChunk::data);
|
||||||
|
|
||||||
idle_add(IDLE_PLAYER);
|
pc.listener.OnPlayerStateChanged();
|
||||||
|
|
||||||
if (pending_seek > SongTime::zero()) {
|
if (pending_seek > SongTime::zero()) {
|
||||||
assert(pc.seeking);
|
assert(pc.seeking);
|
||||||
@ -707,7 +705,7 @@ Player::SeekDecoder(std::unique_lock<Mutex> &lock) noexcept
|
|||||||
pc.outputs.Cancel();
|
pc.outputs.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
idle_add(IDLE_PLAYER);
|
pc.listener.OnPlayerStateChanged();
|
||||||
|
|
||||||
if (!dc.IsSeekableCurrentSong(*pc.next_song)) {
|
if (!dc.IsSeekableCurrentSong(*pc.next_song)) {
|
||||||
/* the decoder is already decoding the "next" song -
|
/* the decoder is already decoding the "next" song -
|
||||||
@ -1108,7 +1106,7 @@ Player::SongBorder() noexcept
|
|||||||
pc.outputs.Drain();
|
pc.outputs.Drain();
|
||||||
|
|
||||||
pc.outputs.Pause();
|
pc.outputs.Pause();
|
||||||
idle_add(IDLE_PLAYER);
|
pc.listener.OnPlayerStateChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user