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
9a9b6fa3
Commit
9a9b6fa3
authored
Mar 10, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue/Playlist: add interface QueueListener, replacing calls to idle_add()
parent
ba43ec57
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
88 additions
and
14 deletions
+88
-14
Makefile.am
Makefile.am
+1
-0
Partition.cxx
src/Partition.cxx
+19
-1
Partition.hxx
src/Partition.hxx
+7
-1
Listener.hxx
src/queue/Listener.hxx
+43
-0
Playlist.cxx
src/queue/Playlist.cxx
+6
-6
Playlist.hxx
src/queue/Playlist.hxx
+10
-3
PlaylistEdit.cxx
src/queue/PlaylistEdit.cxx
+2
-2
PlaylistUpdate.cxx
src/queue/PlaylistUpdate.cxx
+0
-1
No files found.
Makefile.am
View file @
9a9b6fa3
...
...
@@ -166,6 +166,7 @@ libmpd_a_SOURCES = \
src/queue/PlaylistEdit.cxx
\
src/queue/PlaylistTag.cxx
\
src/queue/PlaylistState.cxx src/queue/PlaylistState.hxx
\
src/queue/Listener.hxx
\
src/ReplayGainConfig.cxx src/ReplayGainConfig.hxx
\
src/ReplayGainInfo.cxx src/ReplayGainInfo.hxx
\
src/DetachedSong.cxx src/DetachedSong.hxx
\
...
...
src/Partition.cxx
View file @
9a9b6fa3
...
...
@@ -29,7 +29,7 @@ Partition::Partition(Instance &_instance,
unsigned
max_length
,
unsigned
buffer_chunks
,
unsigned
buffered_before_play
)
:
instance
(
_instance
),
playlist
(
max_length
),
:
instance
(
_instance
),
playlist
(
max_length
,
*
this
),
outputs
(
*
this
),
pc
(
*
this
,
outputs
,
buffer_chunks
,
buffered_before_play
)
{
...
...
@@ -75,6 +75,24 @@ Partition::SyncWithPlayer()
}
void
Partition
::
OnQueueModified
()
{
EmitIdle
(
IDLE_PLAYLIST
);
}
void
Partition
::
OnQueueOptionsChanged
()
{
EmitIdle
(
IDLE_OPTIONS
);
}
void
Partition
::
OnQueueSongStarted
()
{
EmitIdle
(
IDLE_PLAYER
);
}
void
Partition
::
OnPlayerSync
()
{
instance
.
global_events
.
Emit
(
GlobalEvents
::
PLAYLIST
);
...
...
src/Partition.hxx
View file @
9a9b6fa3
...
...
@@ -21,6 +21,7 @@
#define MPD_PARTITION_HXX
#include "queue/Playlist.hxx"
#include "queue/Listener.hxx"
#include "output/MultipleOutputs.hxx"
#include "mixer/Listener.hxx"
#include "player/Control.hxx"
...
...
@@ -36,7 +37,7 @@ class SongLoader;
* A partition of the Music Player Daemon. It is a separate unit with
* a playlist, a player, outputs etc.
*/
struct
Partition
final
:
private
PlayerListener
,
private
MixerListener
{
struct
Partition
final
:
QueueListener
,
PlayerListener
,
MixerListener
{
Instance
&
instance
;
struct
playlist
playlist
;
...
...
@@ -200,6 +201,11 @@ struct Partition final : private PlayerListener, private MixerListener {
void
SyncWithPlayer
();
private
:
/* virtual methods from class QueueListener */
void
OnQueueModified
()
override
;
void
OnQueueOptionsChanged
()
override
;
void
OnQueueSongStarted
()
override
;
/* virtual methods from class PlayerListener */
virtual
void
OnPlayerSync
()
override
;
virtual
void
OnPlayerTagModified
()
override
;
...
...
src/queue/Listener.hxx
0 → 100644
View file @
9a9b6fa3
/*
* 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_QUEUE_LISTENER_HXX
#define MPD_QUEUE_LISTENER_HXX
class
QueueListener
{
public
:
/**
* Called after the queue has been modified.
*/
virtual
void
OnQueueModified
()
=
0
;
/**
* Called after a playback options have been changed.
*/
virtual
void
OnQueueOptionsChanged
()
=
0
;
/**
* Called after the player has started playing a new song.
* This gets called by playlist::SyncWithPlayer() after it has
* been notified by the player thread.
*/
virtual
void
OnQueueSongStarted
()
=
0
;
};
#endif
src/queue/Playlist.cxx
View file @
9a9b6fa3
...
...
@@ -19,10 +19,10 @@
#include "config.h"
#include "Playlist.hxx"
#include "Listener.hxx"
#include "PlaylistError.hxx"
#include "player/Control.hxx"
#include "DetachedSong.hxx"
#include "Idle.hxx"
#include "Log.hxx"
#include <assert.h>
...
...
@@ -86,7 +86,7 @@ playlist::QueuedSongStarted(PlayerControl &pc)
if
(
queue
.
consume
)
DeleteOrder
(
pc
,
old_current
);
idle_add
(
IDLE_PLAYER
);
listener
.
OnQueueSongStarted
(
);
SongStarted
();
}
...
...
@@ -245,7 +245,7 @@ playlist::SetRepeat(PlayerControl &pc, bool status)
might change when repeat mode is toggled */
UpdateQueuedSong
(
pc
,
GetQueuedSong
());
idle_add
(
IDLE_OPTIONS
);
listener
.
OnQueueOptionsChanged
(
);
}
static
void
...
...
@@ -272,7 +272,7 @@ playlist::SetSingle(PlayerControl &pc, bool status)
might change when single mode is toggled */
UpdateQueuedSong
(
pc
,
GetQueuedSong
());
idle_add
(
IDLE_OPTIONS
);
listener
.
OnQueueOptionsChanged
(
);
}
void
...
...
@@ -282,7 +282,7 @@ playlist::SetConsume(bool status)
return
;
queue
.
consume
=
status
;
idle_add
(
IDLE_OPTIONS
);
listener
.
OnQueueOptionsChanged
(
);
}
void
...
...
@@ -319,7 +319,7 @@ playlist::SetRandom(PlayerControl &pc, bool status)
UpdateQueuedSong
(
pc
,
queued_song
);
idle_add
(
IDLE_OPTIONS
);
listener
.
OnQueueOptionsChanged
(
);
}
int
...
...
src/queue/Playlist.hxx
View file @
9a9b6fa3
...
...
@@ -30,6 +30,7 @@ class Error;
class
SongLoader
;
class
SongTime
;
class
SignedSongTime
;
class
QueueListener
;
struct
playlist
{
/**
...
...
@@ -37,6 +38,8 @@ struct playlist {
*/
Queue
queue
;
QueueListener
&
listener
;
/**
* This value is true if the player is currently playing (or
* should be playing).
...
...
@@ -85,8 +88,11 @@ struct playlist {
*/
int
queued
;
playlist
(
unsigned
max_length
)
:
queue
(
max_length
),
playing
(
false
),
playlist
(
unsigned
max_length
,
QueueListener
&
_listener
)
:
queue
(
max_length
),
listener
(
_listener
),
playing
(
false
),
bulk_edit
(
false
),
current
(
-
1
),
queued
(
-
1
)
{
}
...
...
@@ -129,7 +135,8 @@ struct playlist {
protected
:
/**
* Called by all editing methods after a modification.
* Updates the queue version and emits #IDLE_PLAYLIST.
* Updates the queue version and invokes
* QueueListener::OnQueueModified().
*/
void
OnModified
();
...
...
src/queue/PlaylistEdit.cxx
View file @
9a9b6fa3
...
...
@@ -25,12 +25,12 @@
#include "config.h"
#include "Playlist.hxx"
#include "Listener.hxx"
#include "PlaylistError.hxx"
#include "player/Control.hxx"
#include "util/Error.hxx"
#include "DetachedSong.hxx"
#include "SongLoader.hxx"
#include "Idle.hxx"
#include <memory>
...
...
@@ -47,7 +47,7 @@ playlist::OnModified()
queue
.
IncrementVersion
();
idle_add
(
IDLE_PLAYLIST
);
listener
.
OnQueueModified
(
);
}
void
...
...
src/queue/PlaylistUpdate.cxx
View file @
9a9b6fa3
...
...
@@ -22,7 +22,6 @@
#include "db/Interface.hxx"
#include "db/LightSong.hxx"
#include "DetachedSong.hxx"
#include "Idle.hxx"
#include "util/Error.hxx"
static
bool
...
...
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