decoder_control: replace dc_init() with dc_new()
dc_new() allocates the object and returns it. dc_free() frees it (replaces dc_deinit()).
This commit is contained in:
parent
b6995ca011
commit
b77e62260a
|
@ -27,9 +27,11 @@
|
||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#define G_LOG_DOMAIN "decoder_control"
|
#define G_LOG_DOMAIN "decoder_control"
|
||||||
|
|
||||||
void
|
struct decoder_control *
|
||||||
dc_init(struct decoder_control *dc, struct player_control *pc)
|
dc_new(struct player_control *pc)
|
||||||
{
|
{
|
||||||
|
struct decoder_control *dc = g_new(struct decoder_control, 1);
|
||||||
|
|
||||||
dc->player_control = pc;
|
dc->player_control = pc;
|
||||||
dc->thread = NULL;
|
dc->thread = NULL;
|
||||||
|
|
||||||
|
@ -44,19 +46,19 @@ dc_init(struct decoder_control *dc, struct player_control *pc)
|
||||||
dc->mixramp_start = NULL;
|
dc->mixramp_start = NULL;
|
||||||
dc->mixramp_end = NULL;
|
dc->mixramp_end = NULL;
|
||||||
dc->mixramp_prev_end = NULL;
|
dc->mixramp_prev_end = NULL;
|
||||||
|
|
||||||
|
return dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dc_deinit(struct decoder_control *dc)
|
dc_free(struct decoder_control *dc)
|
||||||
{
|
{
|
||||||
g_cond_free(dc->cond);
|
g_cond_free(dc->cond);
|
||||||
g_mutex_free(dc->mutex);
|
g_mutex_free(dc->mutex);
|
||||||
g_free(dc->mixramp_start);
|
g_free(dc->mixramp_start);
|
||||||
g_free(dc->mixramp_end);
|
g_free(dc->mixramp_end);
|
||||||
g_free(dc->mixramp_prev_end);
|
g_free(dc->mixramp_prev_end);
|
||||||
dc->mixramp_start = NULL;
|
g_free(dc);
|
||||||
dc->mixramp_end = NULL;
|
|
||||||
dc->mixramp_prev_end = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -105,11 +105,12 @@ struct decoder_control {
|
||||||
char *mixramp_prev_end;
|
char *mixramp_prev_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
G_GNUC_MALLOC
|
||||||
dc_init(struct decoder_control *dc, struct player_control *pc);
|
struct decoder_control *
|
||||||
|
dc_new(struct player_control *pc);
|
||||||
|
|
||||||
void
|
void
|
||||||
dc_deinit(struct decoder_control *dc);
|
dc_free(struct decoder_control *dc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locks the #decoder_control object.
|
* Locks the #decoder_control object.
|
||||||
|
|
|
@ -1023,10 +1023,9 @@ static gpointer
|
||||||
player_task(gpointer arg)
|
player_task(gpointer arg)
|
||||||
{
|
{
|
||||||
struct player_control *pc = arg;
|
struct player_control *pc = arg;
|
||||||
struct decoder_control dc;
|
|
||||||
|
|
||||||
dc_init(&dc, pc);
|
struct decoder_control *dc = dc_new(pc);
|
||||||
decoder_thread_start(&dc);
|
decoder_thread_start(dc);
|
||||||
|
|
||||||
player_buffer = music_buffer_new(pc->buffer_chunks);
|
player_buffer = music_buffer_new(pc->buffer_chunks);
|
||||||
|
|
||||||
|
@ -1037,7 +1036,7 @@ player_task(gpointer arg)
|
||||||
case PLAYER_COMMAND_QUEUE:
|
case PLAYER_COMMAND_QUEUE:
|
||||||
assert(pc->next_song != NULL);
|
assert(pc->next_song != NULL);
|
||||||
|
|
||||||
do_play(pc, &dc);
|
do_play(pc, dc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PLAYER_COMMAND_STOP:
|
case PLAYER_COMMAND_STOP:
|
||||||
|
@ -1081,8 +1080,8 @@ player_task(gpointer arg)
|
||||||
case PLAYER_COMMAND_EXIT:
|
case PLAYER_COMMAND_EXIT:
|
||||||
player_unlock(pc);
|
player_unlock(pc);
|
||||||
|
|
||||||
dc_quit(&dc);
|
dc_quit(dc);
|
||||||
dc_deinit(&dc);
|
dc_free(dc);
|
||||||
audio_output_all_close();
|
audio_output_all_close();
|
||||||
music_buffer_free(player_buffer);
|
music_buffer_free(player_buffer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue