decoder_control: store GCond object, not a player_control
Remove the decoder dependency on player_control. All player_control was needed for is to signal the player thread, and we can do that with a simple GCond as well.
This commit is contained in:
parent
39c5af5dbc
commit
a0ad96a787
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue