PlayerControl: add constructor and destructor
This commit is contained in:
parent
81f3d893d9
commit
2a9d933a81
@ -306,7 +306,8 @@ initialize_decoder_and_player(void)
|
|||||||
if (buffered_before_play > buffered_chunks)
|
if (buffered_before_play > buffered_chunks)
|
||||||
buffered_before_play = buffered_chunks;
|
buffered_before_play = buffered_chunks;
|
||||||
|
|
||||||
global_player_control = pc_new(buffered_chunks, buffered_before_play);
|
global_player_control = new player_control(buffered_chunks,
|
||||||
|
buffered_before_play);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -538,7 +539,7 @@ int mpd_main(int argc, char *argv[])
|
|||||||
volume_finish();
|
volume_finish();
|
||||||
mapper_finish();
|
mapper_finish();
|
||||||
path_global_finish();
|
path_global_finish();
|
||||||
pc_free(global_player_control);
|
delete global_player_control;
|
||||||
command_finish();
|
command_finish();
|
||||||
update_global_finish();
|
update_global_finish();
|
||||||
decoder_plugin_deinit_all();
|
decoder_plugin_deinit_all();
|
||||||
|
@ -35,36 +35,28 @@ extern "C" {
|
|||||||
static void
|
static void
|
||||||
pc_enqueue_song_locked(struct player_control *pc, struct song *song);
|
pc_enqueue_song_locked(struct player_control *pc, struct song *song);
|
||||||
|
|
||||||
struct player_control *
|
player_control::player_control(unsigned _buffer_chunks,
|
||||||
pc_new(unsigned buffer_chunks, unsigned int buffered_before_play)
|
unsigned _buffered_before_play)
|
||||||
|
:buffer_chunks(_buffer_chunks),
|
||||||
|
buffered_before_play(_buffered_before_play),
|
||||||
|
mutex(g_mutex_new()),
|
||||||
|
cond(g_cond_new()),
|
||||||
|
command(PLAYER_COMMAND_NONE),
|
||||||
|
state(PLAYER_STATE_STOP),
|
||||||
|
error_type(PLAYER_ERROR_NONE),
|
||||||
|
cross_fade_seconds(0),
|
||||||
|
mixramp_db(0),
|
||||||
|
mixramp_delay_seconds(nanf(""))
|
||||||
{
|
{
|
||||||
struct player_control *pc = g_new0(struct player_control, 1);
|
|
||||||
|
|
||||||
pc->buffer_chunks = buffer_chunks;
|
|
||||||
pc->buffered_before_play = buffered_before_play;
|
|
||||||
|
|
||||||
pc->mutex = g_mutex_new();
|
|
||||||
pc->cond = g_cond_new();
|
|
||||||
|
|
||||||
pc->command = PLAYER_COMMAND_NONE;
|
|
||||||
pc->error_type = PLAYER_ERROR_NONE;
|
|
||||||
pc->state = PLAYER_STATE_STOP;
|
|
||||||
pc->cross_fade_seconds = 0;
|
|
||||||
pc->mixramp_db = 0;
|
|
||||||
pc->mixramp_delay_seconds = nanf("");
|
|
||||||
|
|
||||||
return pc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
player_control::~player_control()
|
||||||
pc_free(struct player_control *pc)
|
|
||||||
{
|
{
|
||||||
if (pc->next_song != NULL)
|
if (next_song != nullptr)
|
||||||
song_free(pc->next_song);
|
song_free(next_song);
|
||||||
|
|
||||||
g_cond_free(pc->cond);
|
g_cond_free(cond);
|
||||||
g_mutex_free(pc->mutex);
|
g_mutex_free(mutex);
|
||||||
g_free(pc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -146,14 +146,12 @@ struct player_control {
|
|||||||
* time.
|
* time.
|
||||||
*/
|
*/
|
||||||
bool border_pause;
|
bool border_pause;
|
||||||
|
|
||||||
|
player_control(unsigned buffer_chunks,
|
||||||
|
unsigned buffered_before_play);
|
||||||
|
~player_control();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct player_control *
|
|
||||||
pc_new(unsigned buffer_chunks, unsigned buffered_before_play);
|
|
||||||
|
|
||||||
void
|
|
||||||
pc_free(struct player_control *pc);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Locks the #player_control object.
|
* Locks the #player_control object.
|
||||||
*/
|
*/
|
||||||
|
@ -98,6 +98,10 @@ find_named_config_block(const char *block, const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player_control::player_control(gcc_unused unsigned _buffer_chunks,
|
||||||
|
gcc_unused unsigned _buffered_before_play) {}
|
||||||
|
player_control::~player_control() {}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
load_audio_output(const char *name)
|
load_audio_output(const char *name)
|
||||||
{
|
{
|
||||||
@ -110,7 +114,7 @@ load_audio_output(const char *name)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct player_control dummy_player_control;
|
static struct player_control dummy_player_control(32, 4);
|
||||||
|
|
||||||
struct audio_output *ao =
|
struct audio_output *ao =
|
||||||
audio_output_new(param, &dummy_player_control, &error);
|
audio_output_new(param, &dummy_player_control, &error);
|
||||||
|
Loading…
Reference in New Issue
Block a user