aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/decoder_api.c15
-rw-r--r--src/decoder_control.c7
-rw-r--r--src/decoder_control.h16
-rw-r--r--src/decoder_internal.c3
-rw-r--r--src/decoder_thread.c3
-rw-r--r--src/player_control.c2
-rw-r--r--src/player_thread.c2
7 files changed, 20 insertions, 28 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index ccfbd3df6..8eb296533 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -21,7 +21,6 @@
#include "decoder_api.h"
#include "decoder_internal.h"
#include "decoder_control.h"
-#include "player_control.h"
#include "audio.h"
#include "song.h"
#include "buffer.h"
@@ -63,10 +62,9 @@ decoder_initialized(struct decoder *decoder,
decoder_lock(dc);
dc->state = DECODE_STATE_DECODE;
+ g_cond_signal(dc->client_cond);
decoder_unlock(dc);
- player_lock_signal(dc->player_control);
-
g_debug("audio_format=%s, seekable=%s",
audio_format_to_string(&dc->in_audio_format, &af_string),
seekable ? "true" : "false");
@@ -115,9 +113,8 @@ decoder_command_finished(struct decoder *decoder)
}
dc->command = DECODE_COMMAND_NONE;
+ g_cond_signal(dc->client_cond);
decoder_unlock(dc);
-
- player_lock_signal(dc->player_control);
}
double decoder_seek_where(G_GNUC_UNUSED struct decoder * decoder)
@@ -214,7 +211,7 @@ do_send_tag(struct decoder *decoder, struct input_stream *is,
/* there is a partial chunk - flush it, we want the
tag in a new chunk */
decoder_flush_chunk(decoder);
- player_lock_signal(decoder->dc->player_control);
+ g_cond_signal(decoder->dc->client_cond);
}
assert(decoder->chunk == NULL);
@@ -329,7 +326,7 @@ decoder_data(struct decoder *decoder,
if (dest == NULL) {
/* the chunk is full, flush it */
decoder_flush_chunk(decoder);
- player_lock_signal(dc->player_control);
+ g_cond_signal(dc->client_cond);
continue;
}
@@ -348,7 +345,7 @@ decoder_data(struct decoder *decoder,
if (full) {
/* the chunk is full, flush it */
decoder_flush_chunk(decoder);
- player_lock_signal(dc->player_control);
+ g_cond_signal(dc->client_cond);
}
data += nbytes;
@@ -432,7 +429,7 @@ decoder_replay_gain(struct decoder *decoder,
replay gain values affect the following
samples */
decoder_flush_chunk(decoder);
- player_lock_signal(decoder->dc->player_control);
+ g_cond_signal(decoder->dc->client_cond);
}
} else
decoder->replay_gain_serial = 0;
diff --git a/src/decoder_control.c b/src/decoder_control.c
index a570b2441..15f60790f 100644
--- a/src/decoder_control.c
+++ b/src/decoder_control.c
@@ -19,7 +19,6 @@
#include "config.h"
#include "decoder_control.h"
-#include "player_control.h"
#include "pipe.h"
#include <assert.h>
@@ -28,15 +27,15 @@
#define G_LOG_DOMAIN "decoder_control"
struct decoder_control *
-dc_new(struct player_control *pc)
+dc_new(GCond *client_cond)
{
struct decoder_control *dc = g_new(struct decoder_control, 1);
- dc->player_control = pc;
dc->thread = NULL;
dc->mutex = g_mutex_new();
dc->cond = g_cond_new();
+ dc->client_cond = client_cond;
dc->state = DECODE_STATE_STOP;
dc->command = DECODE_COMMAND_NONE;
@@ -65,7 +64,7 @@ static void
dc_command_wait_locked(struct decoder_control *dc)
{
while (dc->command != DECODE_COMMAND_NONE)
- player_wait_decoder(dc->player_control, dc);
+ g_cond_wait(dc->client_cond, dc->mutex);
}
static void
diff --git a/src/decoder_control.h b/src/decoder_control.h
index f0e369c71..34b486525 100644
--- a/src/decoder_control.h
+++ b/src/decoder_control.h
@@ -27,8 +27,6 @@
#include <assert.h>
-struct player_control;
-
enum decoder_state {
DECODE_STATE_STOP = 0,
DECODE_STATE_START,
@@ -44,12 +42,6 @@ enum decoder_state {
};
struct decoder_control {
- /**
- * The player thread which calls us. This pointer is used to
- * signal command completion.
- */
- struct player_control *player_control;
-
/** the handle of the decoder thread, or NULL if the decoder
thread isn't running */
GThread *thread;
@@ -66,6 +58,12 @@ struct decoder_control {
*/
GCond *cond;
+ /**
+ * The trigger of this object's client. It is signalled
+ * whenever an event occurs.
+ */
+ GCond *client_cond;
+
enum decoder_state state;
enum decoder_command command;
@@ -107,7 +105,7 @@ struct decoder_control {
G_GNUC_MALLOC
struct decoder_control *
-dc_new(struct player_control *pc);
+dc_new(GCond *client_cond);
void
dc_free(struct decoder_control *dc);
diff --git a/src/decoder_internal.c b/src/decoder_internal.c
index a4aadd4f0..0d2ba570b 100644
--- a/src/decoder_internal.c
+++ b/src/decoder_internal.c
@@ -20,7 +20,6 @@
#include "config.h"
#include "decoder_internal.h"
#include "decoder_control.h"
-#include "player_control.h"
#include "pipe.h"
#include "input_stream.h"
#include "buffer.h"
@@ -65,7 +64,7 @@ need_chunks(struct decoder_control *dc, struct input_stream *is, bool do_wait)
if ((is == NULL || !decoder_input_buffer(dc, is)) && do_wait) {
decoder_wait(dc);
- player_signal(dc->player_control);
+ g_cond_signal(dc->client_cond);
return dc->command;
}
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 0bed2e81d..5b05896e4 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -26,7 +26,6 @@
#include "decoder_api.h"
#include "replay_gain_ape.h"
#include "input_stream.h"
-#include "player_control.h"
#include "pipe.h"
#include "song.h"
#include "tag.h"
@@ -67,7 +66,7 @@ decoder_command_finished_locked(struct decoder_control *dc)
dc->command = DECODE_COMMAND_NONE;
- player_signal(dc->player_control);
+ g_cond_signal(dc->client_cond);
}
/**
diff --git a/src/player_control.c b/src/player_control.c
index 049fc0d1f..40725e12a 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -69,7 +69,7 @@ player_wait_decoder(struct player_control *pc, struct decoder_control *dc)
{
assert(pc != NULL);
assert(dc != NULL);
- assert(dc->player_control == pc);
+ assert(dc->client_cond == pc->cond);
/* during this function, the decoder lock is held, because
we're waiting for the decoder thread */
diff --git a/src/player_thread.c b/src/player_thread.c
index 6be7b8884..d2ff1534d 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -1024,7 +1024,7 @@ player_task(gpointer arg)
{
struct player_control *pc = arg;
- struct decoder_control *dc = dc_new(pc);
+ struct decoder_control *dc = dc_new(pc->cond);
decoder_thread_start(dc);
player_buffer = music_buffer_new(pc->buffer_chunks);