Partition: add a local idle_monitor

Make idle events per-partition, but leave Instance::EmitIdle() and its
underlying idle_monitor which broadcasts idle events to all
partitions.
This commit is contained in:
Max Kellermann
2020-01-20 13:28:58 +01:00
parent 879bafb837
commit 49309b419f
6 changed files with 32 additions and 26 deletions
+12 -3
View File
@@ -63,6 +63,11 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
boost::intrusive::link_mode<boost::intrusive::normal_link>>>,
boost::intrusive::constant_time_size<false>> clients;
/**
* Monitor for idle events local to this partition.
*/
MaskMonitor idle_monitor;
MaskMonitor global_events;
struct playlist playlist;
@@ -91,10 +96,11 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
/**
* Emit an "idle" event to all clients of this partition.
*
* This method is not thread-safe and may only be called from
* the main thread.
* This method can be called from any thread.
*/
void EmitIdle(unsigned mask) noexcept;
void EmitIdle(unsigned mask) noexcept {
idle_monitor.OrMask(mask);
}
/**
* Populate the #InputCacheManager with soon-to-be-played song
@@ -282,6 +288,9 @@ private:
/* virtual methods from class MixerListener */
void OnMixerVolumeChanged(Mixer &mixer, int volume) noexcept override;
/* callback for #idle_monitor */
void OnIdleMonitor(unsigned mask) noexcept;
/* callback for #global_events */
void OnGlobalEvent(unsigned mask) noexcept;
};