aboutsummaryrefslogtreecommitdiffstats
path: root/src/PlayerControl.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/PlayerControl.hxx')
-rw-r--r--src/PlayerControl.hxx69
1 files changed, 39 insertions, 30 deletions
diff --git a/src/PlayerControl.hxx b/src/PlayerControl.hxx
index 61bb408d2..4d06a1827 100644
--- a/src/PlayerControl.hxx
+++ b/src/PlayerControl.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * 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
@@ -17,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_PLAYER_H
-#define MPD_PLAYER_H
+#ifndef MPD_PLAYER_CONTROL_HXX
+#define MPD_PLAYER_CONTROL_HXX
#include "AudioFormat.hxx"
#include "thread/Mutex.hxx"
@@ -26,10 +26,13 @@
#include "thread/Thread.hxx"
#include "util/Error.hxx"
#include "CrossFade.hxx"
+#include "Chrono.hxx"
#include <stdint.h>
-struct Song;
+class PlayerListener;
+class MultipleOutputs;
+class DetachedSong;
enum class PlayerState : uint8_t {
STOP,
@@ -46,7 +49,7 @@ enum class PlayerCommand : uint8_t {
CLOSE_AUDIO,
/**
- * At least one audio_output.enabled flag has been modified;
+ * At least one AudioOutput.enabled flag has been modified;
* commit those changes to the output threads.
*/
UPDATE_AUDIO,
@@ -86,14 +89,18 @@ struct player_status {
PlayerState state;
uint16_t bit_rate;
AudioFormat audio_format;
- float total_time;
- float elapsed_time;
+ SignedSongTime total_time;
+ SongTime elapsed_time;
};
struct PlayerControl {
- unsigned buffer_chunks;
+ PlayerListener &listener;
- unsigned int buffered_before_play;
+ MultipleOutputs &outputs;
+
+ const unsigned buffer_chunks;
+
+ const unsigned buffered_before_play;
/**
* The handle of the player thread.
@@ -131,21 +138,21 @@ struct PlayerControl {
Error error;
/**
- * A copy of the current #Song 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 #Song in the queue.
+ * 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 PlayerListener::OnPlayerTagModified()
+ * to update the current #DetachedSong in the queue.
*
* Protected by #mutex. Set by the PlayerThread and consumed
* by the main thread.
*/
- Song *tagged_song;
+ DetachedSong *tagged_song;
uint16_t bit_rate;
AudioFormat audio_format;
- float total_time;
- float elapsed_time;
+ SignedSongTime total_time;
+ SongTime elapsed_time;
/**
* The next queued song.
@@ -153,9 +160,9 @@ struct PlayerControl {
* This is a duplicate, and must be freed when this attribute
* is cleared.
*/
- Song *next_song;
+ DetachedSong *next_song;
- double seek_where;
+ SongTime seek_time;
CrossFadeSettings cross_fade;
@@ -170,7 +177,9 @@ struct PlayerControl {
*/
bool border_pause;
- PlayerControl(unsigned buffer_chunks,
+ PlayerControl(PlayerListener &_listener,
+ MultipleOutputs &_outputs,
+ unsigned buffer_chunks,
unsigned buffered_before_play);
~PlayerControl();
@@ -299,7 +308,7 @@ public:
* @param song the song to be queued; the given instance will
* be owned and freed by the player
*/
- void Play(Song *song);
+ void Play(DetachedSong *song);
/**
* see PlayerCommand::CANCEL
@@ -371,9 +380,9 @@ public:
/**
* Set the #tagged_song attribute to a newly allocated copy of
- * the given #Song. Locks and unlocks the object.
+ * the given #DetachedSong. Locks and unlocks the object.
*/
- void LockSetTaggedSong(const Song &song);
+ void LockSetTaggedSong(const DetachedSong &song);
void ClearTaggedSong();
@@ -382,8 +391,8 @@ public:
*
* Caller must lock the object.
*/
- Song *ReadTaggedSong() {
- Song *result = tagged_song;
+ DetachedSong *ReadTaggedSong() {
+ DetachedSong *result = tagged_song;
tagged_song = nullptr;
return result;
}
@@ -391,9 +400,9 @@ public:
/**
* Like ReadTaggedSong(), but locks and unlocks the object.
*/
- Song *LockReadTaggedSong() {
+ DetachedSong *LockReadTaggedSong() {
Lock();
- Song *result = ReadTaggedSong();
+ DetachedSong *result = ReadTaggedSong();
Unlock();
return result;
}
@@ -403,7 +412,7 @@ public:
void UpdateAudio();
private:
- void EnqueueSongLocked(Song *song) {
+ void EnqueueSongLocked(DetachedSong *song) {
assert(song != nullptr);
assert(next_song == nullptr);
@@ -416,7 +425,7 @@ public:
* @param song the song to be queued; the given instance will be owned
* and freed by the player
*/
- void EnqueueSong(Song *song);
+ void EnqueueSong(DetachedSong *song);
/**
* Makes the player thread seek the specified song to a position.
@@ -426,7 +435,7 @@ public:
* @return true on success, false on failure (e.g. if MPD isn't
* playing currently)
*/
- bool Seek(Song *song, float seek_time);
+ bool Seek(DetachedSong *song, SongTime t);
void SetCrossFade(float cross_fade_seconds);