aboutsummaryrefslogtreecommitdiffstats
path: root/src/player_control.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/player_control.h')
-rw-r--r--src/player_control.h100
1 files changed, 76 insertions, 24 deletions
diff --git a/src/player_control.h b/src/player_control.h
index a77d31ec5..3b536b8ba 100644
--- a/src/player_control.h
+++ b/src/player_control.h
@@ -66,12 +66,17 @@ enum player_command {
};
enum player_error {
- PLAYER_ERROR_NOERROR = 0,
- PLAYER_ERROR_FILE,
- PLAYER_ERROR_AUDIO,
- PLAYER_ERROR_SYSTEM,
- PLAYER_ERROR_UNKTYPE,
- PLAYER_ERROR_FILENOTFOUND,
+ PLAYER_ERROR_NONE = 0,
+
+ /**
+ * The decoder has failed to decode the song.
+ */
+ PLAYER_ERROR_DECODER,
+
+ /**
+ * The audio output has failed.
+ */
+ PLAYER_ERROR_OUTPUT,
};
struct player_status {
@@ -103,13 +108,30 @@ struct player_control {
enum player_command command;
enum player_state state;
- enum player_error error;
+
+ enum player_error error_type;
+
+ /**
+ * The error that occurred in the player thread. This
+ * attribute is only valid if #error is not
+ * #PLAYER_ERROR_NONE. The object must be freed when this
+ * object transitions back to #PLAYER_ERROR_NONE.
+ */
+ GError *error;
+
uint16_t bit_rate;
struct audio_format audio_format;
float total_time;
float elapsed_time;
+
+ /**
+ * The next queued song.
+ *
+ * This is a duplicate, and must be freed when this attribute
+ * is cleared.
+ */
struct song *next_song;
- const struct song *errored_song;
+
double seek_where;
float cross_fade_seconds;
float mixramp_db;
@@ -194,14 +216,10 @@ player_lock_signal(struct player_control *pc)
}
/**
- * Call this function when the specified song pointer is about to be
- * invalidated. This makes sure that player_control.errored_song does
- * not point to an invalid pointer.
+ * @param song the song to be queued; the given instance will be owned
+ * and freed by the player
*/
void
-pc_song_deleted(struct player_control *pc, const struct song *song);
-
-void
pc_play(struct player_control *pc, struct song *song);
/**
@@ -228,8 +246,24 @@ pc_kill(struct player_control *pc);
void
pc_get_status(struct player_control *pc, struct player_status *status);
-enum player_state
-pc_get_state(struct player_control *pc);
+static inline enum player_state
+pc_get_state(struct player_control *pc)
+{
+ return pc->state;
+}
+
+/**
+ * Set the error. Discards any previous error condition.
+ *
+ * Caller must lock the object.
+ *
+ * @param type the error type; must not be #PLAYER_ERROR_NONE
+ * @param error detailed error information; must not be NULL; the
+ * #player_control takes over ownership of this #GError instance
+ */
+void
+pc_set_error(struct player_control *pc, enum player_error type,
+ GError *error);
void
pc_clear_error(struct player_control *pc);
@@ -242,8 +276,11 @@ pc_clear_error(struct player_control *pc);
char *
pc_get_error_message(struct player_control *pc);
-enum player_error
-pc_get_error(struct player_control *pc);
+static inline enum player_error
+pc_get_error_type(struct player_control *pc)
+{
+ return pc->error_type;
+}
void
pc_stop(struct player_control *pc);
@@ -251,12 +288,18 @@ pc_stop(struct player_control *pc);
void
pc_update_audio(struct player_control *pc);
+/**
+ * @param song the song to be queued; the given instance will be owned
+ * and freed by the player
+ */
void
pc_enqueue_song(struct player_control *pc, struct song *song);
/**
* Makes the player thread seek the specified song to a position.
*
+ * @param song the song to be queued; the given instance will be owned
+ * and freed by the player
* @return true on success, false on failure (e.g. if MPD isn't
* playing currently)
*/
@@ -272,16 +315,25 @@ pc_get_cross_fade(const struct player_control *pc);
void
pc_set_mixramp_db(struct player_control *pc, float mixramp_db);
-float
-pc_get_mixramp_db(const struct player_control *pc);
+static inline float
+pc_get_mixramp_db(const struct player_control *pc)
+{
+ return pc->mixramp_db;
+}
void
pc_set_mixramp_delay(struct player_control *pc, float mixramp_delay_seconds);
-float
-pc_get_mixramp_delay(const struct player_control *pc);
+static inline float
+pc_get_mixramp_delay(const struct player_control *pc)
+{
+ return pc->mixramp_delay_seconds;
+}
-double
-pc_get_total_play_time(const struct player_control *pc);
+static inline double
+pc_get_total_play_time(const struct player_control *pc)
+{
+ return pc->total_play_time;
+}
#endif