aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_control.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder_control.h')
-rw-r--r--src/decoder_control.h94
1 files changed, 50 insertions, 44 deletions
diff --git a/src/decoder_control.h b/src/decoder_control.h
index cab6c69c7..d03c7a805 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -83,28 +83,28 @@ struct decoder_control {
struct music_pipe *pipe;
};
-extern struct decoder_control dc;
-
-void dc_init(void);
+void
+dc_init(struct decoder_control *dc);
-void dc_deinit(void);
+void
+dc_deinit(struct decoder_control *dc);
/**
* Locks the #decoder_control object.
*/
static inline void
-decoder_lock(void)
+decoder_lock(struct decoder_control *dc)
{
- g_mutex_lock(dc.mutex);
+ g_mutex_lock(dc->mutex);
}
/**
* Unlocks the #decoder_control object.
*/
static inline void
-decoder_unlock(void)
+decoder_unlock(struct decoder_control *dc)
{
- g_mutex_unlock(dc.mutex);
+ g_mutex_unlock(dc->mutex);
}
/**
@@ -113,9 +113,9 @@ decoder_unlock(void)
* prior to calling this function.
*/
static inline void
-decoder_wait(void)
+decoder_wait(struct decoder_control *dc)
{
- g_cond_wait(dc.cond, dc.mutex);
+ g_cond_wait(dc->cond, dc->mutex);
}
/**
@@ -124,75 +124,81 @@ decoder_wait(void)
* this function.
*/
static inline void
-decoder_signal(void)
+decoder_signal(struct decoder_control *dc)
{
- g_cond_signal(dc.cond);
+ g_cond_signal(dc->cond);
}
-static inline bool decoder_is_idle(void)
+static inline bool
+decoder_is_idle(const struct decoder_control *dc)
{
- return (dc.state == DECODE_STATE_STOP ||
- dc.state == DECODE_STATE_ERROR) &&
- dc.command != DECODE_COMMAND_START;
+ return (dc->state == DECODE_STATE_STOP ||
+ dc->state == DECODE_STATE_ERROR) &&
+ dc->command != DECODE_COMMAND_START;
}
-static inline bool decoder_is_starting(void)
+static inline bool
+decoder_is_starting(const struct decoder_control *dc)
{
- return dc.command == DECODE_COMMAND_START ||
- dc.state == DECODE_STATE_START;
+ return dc->command == DECODE_COMMAND_START ||
+ dc->state == DECODE_STATE_START;
}
-static inline bool decoder_has_failed(void)
+static inline bool
+decoder_has_failed(const struct decoder_control *dc)
{
- assert(dc.command == DECODE_COMMAND_NONE);
+ assert(dc->command == DECODE_COMMAND_NONE);
- return dc.state == DECODE_STATE_ERROR;
+ return dc->state == DECODE_STATE_ERROR;
}
-static inline bool decoder_lock_is_idle(void)
+static inline bool
+decoder_lock_is_idle(struct decoder_control *dc)
{
bool ret;
- decoder_lock();
- ret = decoder_is_idle();
- decoder_unlock();
+ decoder_lock(dc);
+ ret = decoder_is_idle(dc);
+ decoder_unlock(dc);
return ret;
}
-static inline bool decoder_lock_is_starting(void)
+static inline bool
+decoder_lock_is_starting(struct decoder_control *dc)
{
bool ret;
- decoder_lock();
- ret = decoder_is_starting();
- decoder_unlock();
+ decoder_lock(dc);
+ ret = decoder_is_starting(dc);
+ decoder_unlock(dc);
return ret;
}
-static inline bool decoder_lock_has_failed(void)
+static inline bool
+decoder_lock_has_failed(struct decoder_control *dc)
{
bool ret;
- decoder_lock();
- ret = decoder_has_failed();
- decoder_unlock();
+ decoder_lock(dc);
+ ret = decoder_has_failed(dc);
+ decoder_unlock(dc);
return ret;
}
-static inline struct song *
-decoder_current_song(void)
+static inline const struct song *
+decoder_current_song(const struct decoder_control *dc)
{
- switch (dc.state) {
+ switch (dc->state) {
case DECODE_STATE_STOP:
case DECODE_STATE_ERROR:
return NULL;
case DECODE_STATE_START:
case DECODE_STATE_DECODE:
- return dc.current_song;
+ return dc->current_song;
}
assert(false);
@@ -200,21 +206,21 @@ decoder_current_song(void)
}
void
-dc_command_wait(void);
+dc_command_wait(struct decoder_control *dc);
void
-dc_start(struct song *song);
+dc_start(struct decoder_control *dc, struct song *song);
void
-dc_start_async(struct song *song);
+dc_start_async(struct decoder_control *dc, struct song *song);
void
-dc_stop(void);
+dc_stop(struct decoder_control *dc);
bool
-dc_seek(double where);
+dc_seek(struct decoder_control *dc, double where);
void
-dc_quit(void);
+dc_quit(struct decoder_control *dc);
#endif