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.h86
1 files changed, 60 insertions, 26 deletions
diff --git a/src/player_control.h b/src/player_control.h
index 5a04ab0f9..8be6c4694 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,22 @@ 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;
struct song *next_song;
- const struct song *errored_song;
double seek_where;
float cross_fade_seconds;
float mixramp_db;
@@ -184,14 +198,6 @@ player_lock_signal(struct player_control *pc)
player_unlock(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.
- */
-void
-pc_song_deleted(struct player_control *pc, const struct song *song);
-
void
pc_play(struct player_control *pc, struct song *song);
@@ -213,8 +219,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);
@@ -227,8 +249,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);
@@ -257,16 +282,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