Instance: move GlobalEvents::Monitor to Partition

All remaining events are specific to the Partition.
This commit is contained in:
Max Kellermann 2016-03-10 22:47:47 +01:00
parent e2bc92d128
commit 483daa5882
4 changed files with 12 additions and 10 deletions

View File

@ -23,7 +23,6 @@
#include "check.h"
#include "event/Loop.hxx"
#include "event/MaskMonitor.hxx"
#include "GlobalEvents.hxx"
#include "Compiler.h"
#ifdef ENABLE_NEIGHBOR_PLUGINS
@ -66,8 +65,6 @@ struct Instance final
public NeighborListener
#endif
{
GlobalEvents::Monitor global_events;
CallbackMaskMonitor<Instance> idle_monitor;
#ifdef ENABLE_NEIGHBOR_PLUGINS
@ -93,8 +90,7 @@ struct Instance final
StateFile *state_file;
Instance()
:global_events(event_loop),
idle_monitor(event_loop, *this, &Instance::OnIdle) {}
:idle_monitor(event_loop, *this, &Instance::OnIdle) {}
/**
* Initiate shutdown. Wrapper for EventLoop::Break().

View File

@ -29,7 +29,9 @@ Partition::Partition(Instance &_instance,
unsigned max_length,
unsigned buffer_chunks,
unsigned buffered_before_play)
:instance(_instance), playlist(max_length, *this),
:instance(_instance),
global_events(instance.event_loop),
playlist(max_length, *this),
outputs(*this),
pc(*this, outputs, buffer_chunks, buffered_before_play)
{
@ -95,13 +97,13 @@ Partition::OnQueueSongStarted()
void
Partition::OnPlayerSync()
{
instance.global_events.Emit(GlobalEvents::PLAYLIST);
global_events.Emit(GlobalEvents::PLAYLIST);
}
void
Partition::OnPlayerTagModified()
{
instance.global_events.Emit(GlobalEvents::TAG);
global_events.Emit(GlobalEvents::TAG);
}
void

View File

@ -20,6 +20,7 @@
#ifndef MPD_PARTITION_HXX
#define MPD_PARTITION_HXX
#include "GlobalEvents.hxx"
#include "queue/Playlist.hxx"
#include "queue/Listener.hxx"
#include "output/MultipleOutputs.hxx"
@ -40,6 +41,8 @@ class SongLoader;
struct Partition final : QueueListener, PlayerListener, MixerListener {
Instance &instance;
GlobalEvents::Monitor global_events;
struct playlist playlist;
MultipleOutputs outputs;

View File

@ -26,6 +26,7 @@
#include "PlaylistGlobal.hxx"
#include "Main.hxx"
#include "Instance.hxx"
#include "Partition.hxx"
static void
playlist_tag_event(void)
@ -42,6 +43,6 @@ playlist_event(void)
void
playlist_global_init()
{
instance->global_events.Register(GlobalEvents::TAG, playlist_tag_event);
instance->global_events.Register(GlobalEvents::PLAYLIST, playlist_event);
instance->partition->global_events.Register(GlobalEvents::TAG, playlist_tag_event);
instance->partition->global_events.Register(GlobalEvents::PLAYLIST, playlist_event);
}