Partition: eliminate GlobalEvents.hxx, add mask constants
This commit is contained in:
@@ -132,7 +132,6 @@ libmpd_a_SOURCES = \
|
|||||||
src/IOThread.cxx src/IOThread.hxx \
|
src/IOThread.cxx src/IOThread.hxx \
|
||||||
src/Instance.cxx src/Instance.hxx \
|
src/Instance.cxx src/Instance.hxx \
|
||||||
src/win32/Win32Main.cxx \
|
src/win32/Win32Main.cxx \
|
||||||
src/GlobalEvents.hxx \
|
|
||||||
src/MixRampInfo.hxx \
|
src/MixRampInfo.hxx \
|
||||||
src/MusicBuffer.cxx src/MusicBuffer.hxx \
|
src/MusicBuffer.cxx src/MusicBuffer.hxx \
|
||||||
src/MusicPipe.cxx src/MusicPipe.hxx \
|
src/MusicPipe.cxx src/MusicPipe.hxx \
|
||||||
|
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2003-2016 The Music Player Daemon Project
|
|
||||||
* http://www.musicpd.org
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MPD_GLOBAL_EVENTS_HXX
|
|
||||||
#define MPD_GLOBAL_EVENTS_HXX
|
|
||||||
|
|
||||||
namespace GlobalEvents {
|
|
||||||
enum Event {
|
|
||||||
/** must call playlist_sync() */
|
|
||||||
PLAYLIST,
|
|
||||||
|
|
||||||
/** the current song's tag has changed */
|
|
||||||
TAG,
|
|
||||||
|
|
||||||
MAX
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* MAIN_NOTIFY_H */
|
|
@@ -23,7 +23,6 @@
|
|||||||
#include "DetachedSong.hxx"
|
#include "DetachedSong.hxx"
|
||||||
#include "mixer/Volume.hxx"
|
#include "mixer/Volume.hxx"
|
||||||
#include "Idle.hxx"
|
#include "Idle.hxx"
|
||||||
#include "GlobalEvents.hxx"
|
|
||||||
|
|
||||||
Partition::Partition(Instance &_instance,
|
Partition::Partition(Instance &_instance,
|
||||||
unsigned max_length,
|
unsigned max_length,
|
||||||
@@ -37,15 +36,6 @@ Partition::Partition(Instance &_instance,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Partition::EmitGlobalEvent(GlobalEvents::Event event)
|
|
||||||
{
|
|
||||||
assert((unsigned)event < GlobalEvents::MAX);
|
|
||||||
|
|
||||||
const unsigned mask = 1u << unsigned(event);
|
|
||||||
global_events.OrMask(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Partition::EmitIdle(unsigned mask)
|
Partition::EmitIdle(unsigned mask)
|
||||||
{
|
{
|
||||||
@@ -106,13 +96,13 @@ Partition::OnQueueSongStarted()
|
|||||||
void
|
void
|
||||||
Partition::OnPlayerSync()
|
Partition::OnPlayerSync()
|
||||||
{
|
{
|
||||||
EmitGlobalEvent(GlobalEvents::PLAYLIST);
|
EmitGlobalEvent(SYNC_WITH_PLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Partition::OnPlayerTagModified()
|
Partition::OnPlayerTagModified()
|
||||||
{
|
{
|
||||||
EmitGlobalEvent(GlobalEvents::TAG);
|
EmitGlobalEvent(TAG_MODIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -127,9 +117,9 @@ Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
|
|||||||
void
|
void
|
||||||
Partition::OnGlobalEvent(unsigned mask)
|
Partition::OnGlobalEvent(unsigned mask)
|
||||||
{
|
{
|
||||||
if ((mask & (1u << unsigned(GlobalEvents::TAG))) != 0)
|
if ((mask & TAG_MODIFIED) != 0)
|
||||||
TagModified();
|
TagModified();
|
||||||
|
|
||||||
if ((mask & (1u << unsigned(GlobalEvents::PLAYLIST))) != 0)
|
if ((mask & SYNC_WITH_PLAYER) != 0)
|
||||||
SyncWithPlayer();
|
SyncWithPlayer();
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
#define MPD_PARTITION_HXX
|
#define MPD_PARTITION_HXX
|
||||||
|
|
||||||
#include "event/MaskMonitor.hxx"
|
#include "event/MaskMonitor.hxx"
|
||||||
#include "GlobalEvents.hxx"
|
|
||||||
#include "queue/Playlist.hxx"
|
#include "queue/Playlist.hxx"
|
||||||
#include "queue/Listener.hxx"
|
#include "queue/Listener.hxx"
|
||||||
#include "output/MultipleOutputs.hxx"
|
#include "output/MultipleOutputs.hxx"
|
||||||
@@ -40,6 +39,9 @@ class SongLoader;
|
|||||||
* a playlist, a player, outputs etc.
|
* a playlist, a player, outputs etc.
|
||||||
*/
|
*/
|
||||||
struct Partition final : QueueListener, PlayerListener, MixerListener {
|
struct Partition final : QueueListener, PlayerListener, MixerListener {
|
||||||
|
static constexpr unsigned TAG_MODIFIED = 0x1;
|
||||||
|
static constexpr unsigned SYNC_WITH_PLAYER = 0x2;
|
||||||
|
|
||||||
Instance &instance;
|
Instance &instance;
|
||||||
|
|
||||||
CallbackMaskMonitor<Partition> global_events;
|
CallbackMaskMonitor<Partition> global_events;
|
||||||
@@ -55,7 +57,9 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
|
|||||||
unsigned buffer_chunks,
|
unsigned buffer_chunks,
|
||||||
unsigned buffered_before_play);
|
unsigned buffered_before_play);
|
||||||
|
|
||||||
void EmitGlobalEvent(GlobalEvents::Event event);
|
void EmitGlobalEvent(unsigned mask) {
|
||||||
|
global_events.OrMask(mask);
|
||||||
|
}
|
||||||
|
|
||||||
void EmitIdle(unsigned mask);
|
void EmitIdle(unsigned mask);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user