Partition: use CallbackMaskMonitor, replacing class GlobalEvents::Monitor

This commit is contained in:
Max Kellermann
2016-03-10 22:44:34 +01:00
parent 483daa5882
commit 5ca6026787
10 changed files with 30 additions and 191 deletions

View File

@@ -30,13 +30,22 @@ Partition::Partition(Instance &_instance,
unsigned buffer_chunks,
unsigned buffered_before_play)
:instance(_instance),
global_events(instance.event_loop),
global_events(instance.event_loop, *this, &Partition::OnGlobalEvent),
playlist(max_length, *this),
outputs(*this),
pc(*this, outputs, buffer_chunks, buffered_before_play)
{
}
void
Partition::EmitGlobalEvent(GlobalEvents::Event event)
{
assert((unsigned)event < GlobalEvents::MAX);
const unsigned mask = 1u << unsigned(event);
global_events.OrMask(mask);
}
void
Partition::EmitIdle(unsigned mask)
{
@@ -97,13 +106,13 @@ Partition::OnQueueSongStarted()
void
Partition::OnPlayerSync()
{
global_events.Emit(GlobalEvents::PLAYLIST);
EmitGlobalEvent(GlobalEvents::PLAYLIST);
}
void
Partition::OnPlayerTagModified()
{
global_events.Emit(GlobalEvents::TAG);
EmitGlobalEvent(GlobalEvents::TAG);
}
void
@@ -114,3 +123,13 @@ Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
/* notify clients */
EmitIdle(IDLE_MIXER);
}
void
Partition::OnGlobalEvent(unsigned mask)
{
if ((mask & (1u << unsigned(GlobalEvents::TAG))) != 0)
TagModified();
if ((mask & (1u << unsigned(GlobalEvents::PLAYLIST))) != 0)
SyncWithPlayer();
}