Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
5ca60267
Commit
5ca60267
authored
Mar 10, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Partition: use CallbackMaskMonitor, replacing class GlobalEvents::Monitor
parent
483daa58
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
30 additions
and
191 deletions
+30
-191
Makefile.am
Makefile.am
+1
-2
GlobalEvents.cxx
src/GlobalEvents.cxx
+0
-58
GlobalEvents.hxx
src/GlobalEvents.hxx
+0
-24
Instance.cxx
src/Instance.cxx
+0
-16
Instance.hxx
src/Instance.hxx
+0
-11
Main.cxx
src/Main.cxx
+0
-2
Partition.cxx
src/Partition.cxx
+22
-3
Partition.hxx
src/Partition.hxx
+7
-1
PlaylistGlobal.cxx
src/PlaylistGlobal.cxx
+0
-48
PlaylistGlobal.hxx
src/PlaylistGlobal.hxx
+0
-26
No files found.
Makefile.am
View file @
5ca60267
...
@@ -132,7 +132,7 @@ libmpd_a_SOURCES = \
...
@@ -132,7 +132,7 @@ 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.
cxx src/GlobalEvents.
hxx
\
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
\
...
@@ -145,7 +145,6 @@ libmpd_a_SOURCES = \
...
@@ -145,7 +145,6 @@ libmpd_a_SOURCES = \
src/player/Control.cxx src/player/Control.hxx
\
src/player/Control.cxx src/player/Control.hxx
\
src/player/Listener.hxx
\
src/player/Listener.hxx
\
src/PlaylistError.cxx src/PlaylistError.hxx
\
src/PlaylistError.cxx src/PlaylistError.hxx
\
src/PlaylistGlobal.cxx src/PlaylistGlobal.hxx
\
src/PlaylistPrint.cxx src/PlaylistPrint.hxx
\
src/PlaylistPrint.cxx src/PlaylistPrint.hxx
\
src/PlaylistSave.cxx src/PlaylistSave.hxx
\
src/PlaylistSave.cxx src/PlaylistSave.hxx
\
src/playlist/PlaylistStream.cxx src/playlist/PlaylistStream.hxx
\
src/playlist/PlaylistStream.cxx src/playlist/PlaylistStream.hxx
\
...
...
src/GlobalEvents.cxx
deleted
100644 → 0
View file @
483daa58
/*
* 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.
*/
#include "config.h"
#include "GlobalEvents.hxx"
#include <assert.h>
inline
void
GlobalEvents
::
Monitor
::
Invoke
(
Event
event
)
{
assert
((
unsigned
)
event
<
GlobalEvents
::
MAX
);
assert
(
handlers
[
event
]
!=
nullptr
);
handlers
[
event
]();
}
void
GlobalEvents
::
Monitor
::
HandleMask
(
unsigned
f
)
{
for
(
unsigned
i
=
0
;
i
<
MAX
;
++
i
)
if
(
f
&
(
1u
<<
i
))
/* invoke the event handler */
Invoke
(
Event
(
i
));
}
void
GlobalEvents
::
Monitor
::
Register
(
Event
event
,
Handler
callback
)
{
assert
((
unsigned
)
event
<
MAX
);
handlers
[
event
]
=
callback
;
}
void
GlobalEvents
::
Monitor
::
Emit
(
Event
event
)
{
assert
((
unsigned
)
event
<
MAX
);
const
unsigned
mask
=
1u
<<
unsigned
(
event
);
OrMask
(
mask
);
}
src/GlobalEvents.hxx
View file @
5ca60267
...
@@ -20,8 +20,6 @@
...
@@ -20,8 +20,6 @@
#ifndef MPD_GLOBAL_EVENTS_HXX
#ifndef MPD_GLOBAL_EVENTS_HXX
#define MPD_GLOBAL_EVENTS_HXX
#define MPD_GLOBAL_EVENTS_HXX
#include "event/MaskMonitor.hxx"
namespace
GlobalEvents
{
namespace
GlobalEvents
{
enum
Event
{
enum
Event
{
/** must call playlist_sync() */
/** must call playlist_sync() */
...
@@ -32,28 +30,6 @@ namespace GlobalEvents {
...
@@ -32,28 +30,6 @@ namespace GlobalEvents {
MAX
MAX
};
};
typedef
void
(
*
Handler
)();
class
Monitor
final
:
MaskMonitor
{
Handler
handlers
[
MAX
];
public
:
explicit
Monitor
(
EventLoop
&
_loop
)
:
MaskMonitor
(
_loop
)
{}
void
Register
(
Event
event
,
Handler
handler
);
void
Emit
(
Event
event
);
private
:
/**
* Invoke the callback for a certain event.
*/
void
Invoke
(
Event
event
);
protected
:
void
HandleMask
(
unsigned
mask
)
override
;
};
}
}
#endif
/* MAIN_NOTIFY_H */
#endif
/* MAIN_NOTIFY_H */
src/Instance.cxx
View file @
5ca60267
...
@@ -45,22 +45,6 @@ Instance::GetDatabase(Error &error)
...
@@ -45,22 +45,6 @@ Instance::GetDatabase(Error &error)
return
database
;
return
database
;
}
}
#endif
void
Instance
::
TagModified
()
{
partition
->
TagModified
();
}
void
Instance
::
SyncWithPlayer
()
{
partition
->
SyncWithPlayer
();
}
#ifdef ENABLE_DATABASE
void
void
Instance
::
OnDatabaseModified
()
Instance
::
OnDatabaseModified
()
{
{
...
...
src/Instance.hxx
View file @
5ca60267
...
@@ -112,17 +112,6 @@ struct Instance final
...
@@ -112,17 +112,6 @@ struct Instance final
Database
*
GetDatabase
(
Error
&
error
);
Database
*
GetDatabase
(
Error
&
error
);
#endif
#endif
/**
* A tag in the play queue has been modified by the player
* thread. Propagate the change to all subsystems.
*/
void
TagModified
();
/**
* Synchronize the player with the play queue.
*/
void
SyncWithPlayer
();
private
:
private
:
#ifdef ENABLE_DATABASE
#ifdef ENABLE_DATABASE
virtual
void
OnDatabaseModified
()
override
;
virtual
void
OnDatabaseModified
()
override
;
...
...
src/Main.cxx
View file @
5ca60267
...
@@ -22,7 +22,6 @@
...
@@ -22,7 +22,6 @@
#include "Instance.hxx"
#include "Instance.hxx"
#include "CommandLine.hxx"
#include "CommandLine.hxx"
#include "PlaylistFile.hxx"
#include "PlaylistFile.hxx"
#include "PlaylistGlobal.hxx"
#include "MusicChunk.hxx"
#include "MusicChunk.hxx"
#include "StateFile.hxx"
#include "StateFile.hxx"
#include "player/Thread.hxx"
#include "player/Thread.hxx"
...
@@ -523,7 +522,6 @@ try {
...
@@ -523,7 +522,6 @@ try {
}
}
initPermissions
();
initPermissions
();
playlist_global_init
();
spl_global_init
();
spl_global_init
();
#ifdef ENABLE_ARCHIVE
#ifdef ENABLE_ARCHIVE
archive_plugin_init_all
();
archive_plugin_init_all
();
...
...
src/Partition.cxx
View file @
5ca60267
...
@@ -30,7 +30,7 @@ Partition::Partition(Instance &_instance,
...
@@ -30,7 +30,7 @@ Partition::Partition(Instance &_instance,
unsigned
buffer_chunks
,
unsigned
buffer_chunks
,
unsigned
buffered_before_play
)
unsigned
buffered_before_play
)
:
instance
(
_instance
),
:
instance
(
_instance
),
global_events
(
instance
.
event_loop
),
global_events
(
instance
.
event_loop
,
*
this
,
&
Partition
::
OnGlobalEvent
),
playlist
(
max_length
,
*
this
),
playlist
(
max_length
,
*
this
),
outputs
(
*
this
),
outputs
(
*
this
),
pc
(
*
this
,
outputs
,
buffer_chunks
,
buffered_before_play
)
pc
(
*
this
,
outputs
,
buffer_chunks
,
buffered_before_play
)
...
@@ -38,6 +38,15 @@ Partition::Partition(Instance &_instance,
...
@@ -38,6 +38,15 @@ Partition::Partition(Instance &_instance,
}
}
void
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
)
Partition
::
EmitIdle
(
unsigned
mask
)
{
{
idle_add
(
mask
);
idle_add
(
mask
);
...
@@ -97,13 +106,13 @@ Partition::OnQueueSongStarted()
...
@@ -97,13 +106,13 @@ Partition::OnQueueSongStarted()
void
void
Partition
::
OnPlayerSync
()
Partition
::
OnPlayerSync
()
{
{
global_events
.
Emi
t
(
GlobalEvents
::
PLAYLIST
);
EmitGlobalEven
t
(
GlobalEvents
::
PLAYLIST
);
}
}
void
void
Partition
::
OnPlayerTagModified
()
Partition
::
OnPlayerTagModified
()
{
{
global_events
.
Emi
t
(
GlobalEvents
::
TAG
);
EmitGlobalEven
t
(
GlobalEvents
::
TAG
);
}
}
void
void
...
@@ -114,3 +123,13 @@ Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
...
@@ -114,3 +123,13 @@ Partition::OnMixerVolumeChanged(gcc_unused Mixer &mixer, gcc_unused int volume)
/* notify clients */
/* notify clients */
EmitIdle
(
IDLE_MIXER
);
EmitIdle
(
IDLE_MIXER
);
}
}
void
Partition
::
OnGlobalEvent
(
unsigned
mask
)
{
if
((
mask
&
(
1u
<<
unsigned
(
GlobalEvents
::
TAG
)))
!=
0
)
TagModified
();
if
((
mask
&
(
1u
<<
unsigned
(
GlobalEvents
::
PLAYLIST
)))
!=
0
)
SyncWithPlayer
();
}
src/Partition.hxx
View file @
5ca60267
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#ifndef MPD_PARTITION_HXX
#ifndef MPD_PARTITION_HXX
#define MPD_PARTITION_HXX
#define MPD_PARTITION_HXX
#include "event/MaskMonitor.hxx"
#include "GlobalEvents.hxx"
#include "GlobalEvents.hxx"
#include "queue/Playlist.hxx"
#include "queue/Playlist.hxx"
#include "queue/Listener.hxx"
#include "queue/Listener.hxx"
...
@@ -41,7 +42,7 @@ class SongLoader;
...
@@ -41,7 +42,7 @@ class SongLoader;
struct
Partition
final
:
QueueListener
,
PlayerListener
,
MixerListener
{
struct
Partition
final
:
QueueListener
,
PlayerListener
,
MixerListener
{
Instance
&
instance
;
Instance
&
instance
;
GlobalEvents
::
Monitor
global_events
;
CallbackMaskMonitor
<
Partition
>
global_events
;
struct
playlist
playlist
;
struct
playlist
playlist
;
...
@@ -54,6 +55,8 @@ struct Partition final : QueueListener, PlayerListener, MixerListener {
...
@@ -54,6 +55,8 @@ 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
EmitIdle
(
unsigned
mask
);
void
EmitIdle
(
unsigned
mask
);
void
ClearQueue
()
{
void
ClearQueue
()
{
...
@@ -215,6 +218,9 @@ private:
...
@@ -215,6 +218,9 @@ private:
/* virtual methods from class MixerListener */
/* virtual methods from class MixerListener */
virtual
void
OnMixerVolumeChanged
(
Mixer
&
mixer
,
int
volume
)
override
;
virtual
void
OnMixerVolumeChanged
(
Mixer
&
mixer
,
int
volume
)
override
;
/* callback for #global_events */
void
OnGlobalEvent
(
unsigned
mask
);
};
};
#endif
#endif
src/PlaylistGlobal.cxx
deleted
100644 → 0
View file @
483daa58
/*
* 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.
*/
/*
* The manager of the global "struct playlist" instance (g_playlist).
*
*/
#include "config.h"
#include "PlaylistGlobal.hxx"
#include "Main.hxx"
#include "Instance.hxx"
#include "Partition.hxx"
static
void
playlist_tag_event
(
void
)
{
instance
->
TagModified
();
}
static
void
playlist_event
(
void
)
{
instance
->
SyncWithPlayer
();
}
void
playlist_global_init
()
{
instance
->
partition
->
global_events
.
Register
(
GlobalEvents
::
TAG
,
playlist_tag_event
);
instance
->
partition
->
global_events
.
Register
(
GlobalEvents
::
PLAYLIST
,
playlist_event
);
}
src/PlaylistGlobal.hxx
deleted
100644 → 0
View file @
483daa58
/*
* 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_PLAYLIST_GLOBAL_HXX
#define MPD_PLAYLIST_GLOBAL_HXX
void
playlist_global_init
();
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment