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
30a82076
Commit
30a82076
authored
Feb 21, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlayerListener: new interface to replace GlobalEvents access
parent
860339c1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
76 additions
and
14 deletions
+76
-14
Makefile.am
Makefile.am
+1
-0
Partition.cxx
src/Partition.cxx
+13
-0
Partition.hxx
src/Partition.hxx
+7
-2
PlayerControl.cxx
src/PlayerControl.cxx
+3
-2
PlayerControl.hxx
src/PlayerControl.hxx
+7
-3
PlayerListener.hxx
src/PlayerListener.hxx
+36
-0
PlayerThread.cxx
src/PlayerThread.cxx
+4
-4
run_output.cxx
test/run_output.cxx
+5
-3
No files found.
Makefile.am
View file @
30a82076
...
...
@@ -137,6 +137,7 @@ libmpd_a_SOURCES = \
src/Permission.cxx src/Permission.hxx
\
src/PlayerThread.cxx src/PlayerThread.hxx
\
src/PlayerControl.cxx src/PlayerControl.hxx
\
src/PlayerListener.hxx
\
src/Playlist.cxx src/Playlist.hxx
\
src/PlaylistError.cxx src/PlaylistError.hxx
\
src/PlaylistGlobal.cxx src/PlaylistGlobal.hxx
\
...
...
src/Partition.cxx
View file @
30a82076
...
...
@@ -23,6 +23,7 @@
#include "output/MultipleOutputs.hxx"
#include "mixer/Volume.hxx"
#include "Idle.hxx"
#include "GlobalEvents.hxx"
#ifdef ENABLE_DATABASE
...
...
@@ -51,6 +52,18 @@ Partition::SyncWithPlayer()
}
void
Partition
::
OnPlayerSync
()
{
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
}
void
Partition
::
OnPlayerTagModified
()
{
GlobalEvents
::
Emit
(
GlobalEvents
::
TAG
);
}
void
Partition
::
OnMixerVolumeChanged
(
gcc_unused
Mixer
&
mixer
,
gcc_unused
int
volume
)
{
InvalidateHardwareVolume
();
...
...
src/Partition.hxx
View file @
30a82076
...
...
@@ -24,6 +24,7 @@
#include "output/MultipleOutputs.hxx"
#include "mixer/Listener.hxx"
#include "PlayerControl.hxx"
#include "PlayerListener.hxx"
struct
Instance
;
class
MultipleOutputs
;
...
...
@@ -33,7 +34,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
MixerListener
{
struct
Partition
final
:
private
PlayerListener
,
private
MixerListener
{
Instance
&
instance
;
struct
playlist
playlist
;
...
...
@@ -48,7 +49,7 @@ struct Partition final : private MixerListener {
unsigned
buffered_before_play
)
:
instance
(
_instance
),
playlist
(
max_length
),
outputs
(
*
this
),
pc
(
outputs
,
buffer_chunks
,
buffered_before_play
)
{}
pc
(
*
this
,
outputs
,
buffer_chunks
,
buffered_before_play
)
{}
void
ClearQueue
()
{
playlist
.
Clear
(
pc
);
...
...
@@ -192,6 +193,10 @@ struct Partition final : private MixerListener {
void
SyncWithPlayer
();
private
:
/* virtual methods from class PlayerListener */
virtual
void
OnPlayerSync
()
override
;
virtual
void
OnPlayerTagModified
()
override
;
/* virtual methods from class MixerListener */
virtual
void
OnMixerVolumeChanged
(
Mixer
&
mixer
,
int
volume
)
override
;
};
...
...
src/PlayerControl.cxx
View file @
30a82076
...
...
@@ -26,10 +26,11 @@
#include <assert.h>
PlayerControl
::
PlayerControl
(
MultipleOutputs
&
_outputs
,
PlayerControl
::
PlayerControl
(
PlayerListener
&
_listener
,
MultipleOutputs
&
_outputs
,
unsigned
_buffer_chunks
,
unsigned
_buffered_before_play
)
:
outputs
(
_outputs
),
:
listener
(
_listener
),
outputs
(
_outputs
),
buffer_chunks
(
_buffer_chunks
),
buffered_before_play
(
_buffered_before_play
),
command
(
PlayerCommand
::
NONE
),
...
...
src/PlayerControl.hxx
View file @
30a82076
...
...
@@ -29,6 +29,7 @@
#include <stdint.h>
class
PlayerListener
;
class
MultipleOutputs
;
class
DetachedSong
;
...
...
@@ -92,6 +93,8 @@ struct player_status {
};
struct
PlayerControl
{
PlayerListener
&
listener
;
MultipleOutputs
&
outputs
;
unsigned
buffer_chunks
;
...
...
@@ -137,8 +140,8 @@ struct PlayerControl {
* A copy of the current #DetachedSong after its tags have
* been updated by the decoder (for example, a radio stream
* that has sent a new tag after switching to the next song).
* This shall be used by
the GlobalEvents::TAG handler to
* update the current #DetachedSong in the queue.
* This shall be used by
PlayerListener::OnPlayerTagModified()
*
to
update the current #DetachedSong in the queue.
*
* Protected by #mutex. Set by the PlayerThread and consumed
* by the main thread.
...
...
@@ -173,7 +176,8 @@ struct PlayerControl {
*/
bool
border_pause
;
PlayerControl
(
MultipleOutputs
&
_outputs
,
PlayerControl
(
PlayerListener
&
_listener
,
MultipleOutputs
&
_outputs
,
unsigned
buffer_chunks
,
unsigned
buffered_before_play
);
~
PlayerControl
();
...
...
src/PlayerListener.hxx
0 → 100644
View file @
30a82076
/*
* Copyright (C) 2003-2014 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_PLAYER_LISTENER_HXX
#define MPD_PLAYER_LISTENER_HXX
class
PlayerListener
{
public
:
/**
* Must call playlist_sync().
*/
virtual
void
OnPlayerSync
()
=
0
;
/**
* The current song's tag has changed.
*/
virtual
void
OnPlayerTagModified
()
=
0
;
};
#endif
src/PlayerThread.cxx
View file @
30a82076
...
...
@@ -19,6 +19,7 @@
#include "config.h"
#include "PlayerThread.hxx"
#include "PlayerListener.hxx"
#include "decoder/DecoderThread.hxx"
#include "decoder/DecoderControl.hxx"
#include "MusicPipe.hxx"
...
...
@@ -31,7 +32,6 @@
#include "output/MultipleOutputs.hxx"
#include "tag/Tag.hxx"
#include "Idle.hxx"
#include "GlobalEvents.hxx"
#include "util/Domain.hxx"
#include "thread/Name.hxx"
#include "Log.hxx"
...
...
@@ -359,7 +359,7 @@ Player::WaitForDecoder()
pc
.
Unlock
();
/* call syncPlaylistWithQueue() in the main thread */
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
pc
.
listener
.
OnPlayerSync
(
);
return
true
;
}
...
...
@@ -696,7 +696,7 @@ update_song_tag(PlayerControl &pc, DetachedSong &song, const Tag &new_tag)
/* the main thread will update the playlist version when he
receives this event */
GlobalEvents
::
Emit
(
GlobalEvents
::
TAG
);
pc
.
listener
.
OnPlayerTagModified
(
);
/* notify all clients that the tag of the current song has
changed */
...
...
@@ -1124,7 +1124,7 @@ player_task(void *arg)
pc
.
Unlock
();
do_play
(
pc
,
dc
,
buffer
);
GlobalEvents
::
Emit
(
GlobalEvents
::
PLAYLIST
);
pc
.
listener
.
OnPlayerSync
(
);
pc
.
Lock
();
break
;
...
...
test/run_output.cxx
View file @
30a82076
...
...
@@ -53,10 +53,11 @@ filter_plugin_by_name(gcc_unused const char *name)
return
NULL
;
}
PlayerControl
::
PlayerControl
(
gcc_unused
MultipleOutputs
&
_outputs
,
PlayerControl
::
PlayerControl
(
PlayerListener
&
_listener
,
MultipleOutputs
&
_outputs
,
gcc_unused
unsigned
_buffer_chunks
,
gcc_unused
unsigned
_buffered_before_play
)
:
outputs
(
_outputs
)
{}
:
listener
(
_listener
),
outputs
(
_outputs
)
{}
PlayerControl
::~
PlayerControl
()
{}
static
AudioOutput
*
...
...
@@ -69,7 +70,8 @@ load_audio_output(EventLoop &event_loop, const char *name)
return
nullptr
;
}
static
struct
PlayerControl
dummy_player_control
(
*
(
MultipleOutputs
*
)
nullptr
,
static
struct
PlayerControl
dummy_player_control
(
*
(
PlayerListener
*
)
nullptr
,
*
(
MultipleOutputs
*
)
nullptr
,
32
,
4
);
Error
error
;
...
...
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