player: no CamelCase
Renamed variables and internal functions. Most of the player_control.h API remains in CamelCase for now.
This commit is contained in:
@ -34,8 +34,8 @@ void pc_init(unsigned int buffered_before_play)
|
|||||||
pc.command = PLAYER_COMMAND_NONE;
|
pc.command = PLAYER_COMMAND_NONE;
|
||||||
pc.error = PLAYER_ERROR_NOERROR;
|
pc.error = PLAYER_ERROR_NOERROR;
|
||||||
pc.state = PLAYER_STATE_STOP;
|
pc.state = PLAYER_STATE_STOP;
|
||||||
pc.crossFade = 0;
|
pc.cross_fade_seconds = 0;
|
||||||
pc.softwareVolume = 1000;
|
pc.software_volume = 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pc_deinit(void)
|
void pc_deinit(void)
|
||||||
@ -112,17 +112,17 @@ void playerSetPause(int pause_flag)
|
|||||||
|
|
||||||
int getPlayerElapsedTime(void)
|
int getPlayerElapsedTime(void)
|
||||||
{
|
{
|
||||||
return (int)(pc.elapsedTime + 0.5);
|
return (int)(pc.elapsed_time + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long getPlayerBitRate(void)
|
unsigned long getPlayerBitRate(void)
|
||||||
{
|
{
|
||||||
return pc.bitRate;
|
return pc.bit_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPlayerTotalTime(void)
|
int getPlayerTotalTime(void)
|
||||||
{
|
{
|
||||||
return (int)(pc.totalTime + 0.5);
|
return (int)(pc.total_time + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum player_state getPlayerState(void)
|
enum player_state getPlayerState(void)
|
||||||
@ -192,7 +192,7 @@ playerSeek(struct song *song, float seek_time)
|
|||||||
pc.next_song = song;
|
pc.next_song = song;
|
||||||
|
|
||||||
if (pc.error == PLAYER_ERROR_NOERROR) {
|
if (pc.error == PLAYER_ERROR_NOERROR) {
|
||||||
pc.seekWhere = seek_time;
|
pc.seek_where = seek_time;
|
||||||
player_command(PLAYER_COMMAND_SEEK);
|
player_command(PLAYER_COMMAND_SEEK);
|
||||||
|
|
||||||
idle_add(IDLE_PLAYER);
|
idle_add(IDLE_PLAYER);
|
||||||
@ -203,14 +203,14 @@ playerSeek(struct song *song, float seek_time)
|
|||||||
|
|
||||||
float getPlayerCrossFade(void)
|
float getPlayerCrossFade(void)
|
||||||
{
|
{
|
||||||
return pc.crossFade;
|
return pc.cross_fade_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPlayerCrossFade(float crossFadeInSeconds)
|
void setPlayerCrossFade(float crossFadeInSeconds)
|
||||||
{
|
{
|
||||||
if (crossFadeInSeconds < 0)
|
if (crossFadeInSeconds < 0)
|
||||||
crossFadeInSeconds = 0;
|
crossFadeInSeconds = 0;
|
||||||
pc.crossFade = crossFadeInSeconds;
|
pc.cross_fade_seconds = crossFadeInSeconds;
|
||||||
|
|
||||||
idle_add(IDLE_OPTIONS);
|
idle_add(IDLE_OPTIONS);
|
||||||
}
|
}
|
||||||
@ -218,12 +218,12 @@ void setPlayerCrossFade(float crossFadeInSeconds)
|
|||||||
void setPlayerSoftwareVolume(int volume)
|
void setPlayerSoftwareVolume(int volume)
|
||||||
{
|
{
|
||||||
volume = (volume > 1000) ? 1000 : (volume < 0 ? 0 : volume);
|
volume = (volume > 1000) ? 1000 : (volume < 0 ? 0 : volume);
|
||||||
pc.softwareVolume = volume;
|
pc.software_volume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
double getPlayerTotalPlayTime(void)
|
double getPlayerTotalPlayTime(void)
|
||||||
{
|
{
|
||||||
return pc.totalPlayTime;
|
return pc.total_play_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this actually creates a dupe of the current metadata */
|
/* this actually creates a dupe of the current metadata */
|
||||||
|
@ -64,16 +64,16 @@ struct player_control {
|
|||||||
volatile enum player_command command;
|
volatile enum player_command command;
|
||||||
volatile enum player_state state;
|
volatile enum player_state state;
|
||||||
volatile int8_t error;
|
volatile int8_t error;
|
||||||
volatile uint16_t bitRate;
|
volatile uint16_t bit_rate;
|
||||||
struct audio_format audio_format;
|
struct audio_format audio_format;
|
||||||
volatile float totalTime;
|
volatile float total_time;
|
||||||
volatile float elapsedTime;
|
volatile float elapsed_time;
|
||||||
struct song *volatile next_song;
|
struct song *volatile next_song;
|
||||||
struct song *errored_song;
|
struct song *errored_song;
|
||||||
volatile double seekWhere;
|
volatile double seek_where;
|
||||||
volatile float crossFade;
|
volatile float cross_fade_seconds;
|
||||||
volatile uint16_t softwareVolume;
|
volatile uint16_t software_volume;
|
||||||
volatile double totalPlayTime;
|
volatile double total_play_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct player_control pc;
|
extern struct player_control pc;
|
||||||
|
@ -82,14 +82,14 @@ static void player_command_finished(void)
|
|||||||
wakeup_main_task();
|
wakeup_main_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quitDecode(void)
|
static void player_stop_decoder(void)
|
||||||
{
|
{
|
||||||
dc_stop(&pc.notify);
|
dc_stop(&pc.notify);
|
||||||
pc.state = PLAYER_STATE_STOP;
|
pc.state = PLAYER_STATE_STOP;
|
||||||
wakeup_main_task();
|
wakeup_main_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int waitOnDecode(struct player *player)
|
static int player_wait_for_decoder(struct player *player)
|
||||||
{
|
{
|
||||||
dc_command_wait(&pc.notify);
|
dc_command_wait(&pc.notify);
|
||||||
|
|
||||||
@ -100,9 +100,9 @@ static int waitOnDecode(struct player *player)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.totalTime = pc.next_song->tag != NULL
|
pc.total_time = pc.next_song->tag != NULL
|
||||||
? pc.next_song->tag->time : 0;
|
? pc.next_song->tag->time : 0;
|
||||||
pc.bitRate = 0;
|
pc.bit_rate = 0;
|
||||||
audio_format_clear(&pc.audio_format);
|
audio_format_clear(&pc.audio_format);
|
||||||
|
|
||||||
player->song = pc.next_song;
|
player->song = pc.next_song;
|
||||||
@ -113,7 +113,7 @@ static int waitOnDecode(struct player *player)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool decodeSeek(struct player *player)
|
static bool player_seek_decoder(struct player *player)
|
||||||
{
|
{
|
||||||
double where;
|
double where;
|
||||||
bool ret;
|
bool ret;
|
||||||
@ -123,25 +123,25 @@ static bool decodeSeek(struct player *player)
|
|||||||
player->next_song_chunk = -1;
|
player->next_song_chunk = -1;
|
||||||
music_pipe_clear();
|
music_pipe_clear();
|
||||||
dc_start_async(pc.next_song);
|
dc_start_async(pc.next_song);
|
||||||
waitOnDecode(player);
|
player_wait_for_decoder(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
where = pc.seekWhere;
|
where = pc.seek_where;
|
||||||
if (where > pc.totalTime)
|
if (where > pc.total_time)
|
||||||
where = pc.totalTime - 0.1;
|
where = pc.total_time - 0.1;
|
||||||
if (where < 0.0)
|
if (where < 0.0)
|
||||||
where = 0.0;
|
where = 0.0;
|
||||||
|
|
||||||
ret = dc_seek(&pc.notify, where);
|
ret = dc_seek(&pc.notify, where);
|
||||||
if (ret)
|
if (ret)
|
||||||
pc.elapsedTime = where;
|
pc.elapsed_time = where;
|
||||||
|
|
||||||
player_command_finished();
|
player_command_finished();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void processDecodeInput(struct player *player)
|
static void player_process_command(struct player *player)
|
||||||
{
|
{
|
||||||
switch (pc.command) {
|
switch (pc.command) {
|
||||||
case PLAYER_COMMAND_NONE:
|
case PLAYER_COMMAND_NONE:
|
||||||
@ -181,7 +181,7 @@ static void processDecodeInput(struct player *player)
|
|||||||
|
|
||||||
case PLAYER_COMMAND_SEEK:
|
case PLAYER_COMMAND_SEEK:
|
||||||
dropBufferedAudio();
|
dropBufferedAudio();
|
||||||
if (decodeSeek(player)) {
|
if (player_seek_decoder(player)) {
|
||||||
player->xfade = XFADE_UNKNOWN;
|
player->xfade = XFADE_UNKNOWN;
|
||||||
|
|
||||||
/* abort buffering when the user has requested
|
/* abort buffering when the user has requested
|
||||||
@ -214,11 +214,11 @@ static void processDecodeInput(struct player *player)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
playChunk(struct song *song, struct music_chunk *chunk,
|
play_chunk(struct song *song, struct music_chunk *chunk,
|
||||||
const struct audio_format *format, double sizeToTime)
|
const struct audio_format *format, double sizeToTime)
|
||||||
{
|
{
|
||||||
pc.elapsedTime = chunk->times;
|
pc.elapsed_time = chunk->times;
|
||||||
pc.bitRate = chunk->bit_rate;
|
pc.bit_rate = chunk->bit_rate;
|
||||||
|
|
||||||
if (chunk->tag != NULL) {
|
if (chunk->tag != NULL) {
|
||||||
sendMetadataToAudioDevice(chunk->tag);
|
sendMetadataToAudioDevice(chunk->tag);
|
||||||
@ -240,12 +240,12 @@ playChunk(struct song *song, struct music_chunk *chunk,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pcm_volume(chunk->data, chunk->length,
|
pcm_volume(chunk->data, chunk->length,
|
||||||
format, pc.softwareVolume);
|
format, pc.software_volume);
|
||||||
|
|
||||||
if (!playAudio(chunk->data, chunk->length))
|
if (!playAudio(chunk->data, chunk->length))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pc.totalPlayTime += sizeToTime * chunk->length;
|
pc.total_play_time += sizeToTime * chunk->length;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,18 +272,18 @@ static void do_play(void)
|
|||||||
music_pipe_set_lazy(false);
|
music_pipe_set_lazy(false);
|
||||||
|
|
||||||
dc_start(&pc.notify, pc.next_song);
|
dc_start(&pc.notify, pc.next_song);
|
||||||
if (waitOnDecode(&player) < 0) {
|
if (player_wait_for_decoder(&player) < 0) {
|
||||||
quitDecode();
|
player_stop_decoder();
|
||||||
player_command_finished();
|
player_command_finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pc.elapsedTime = 0;
|
pc.elapsed_time = 0;
|
||||||
pc.state = PLAYER_STATE_PLAY;
|
pc.state = PLAYER_STATE_PLAY;
|
||||||
player_command_finished();
|
player_command_finished();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
processDecodeInput(&player);
|
player_process_command(&player);
|
||||||
if (pc.command == PLAYER_COMMAND_STOP ||
|
if (pc.command == PLAYER_COMMAND_STOP ||
|
||||||
pc.command == PLAYER_COMMAND_EXIT ||
|
pc.command == PLAYER_COMMAND_EXIT ||
|
||||||
pc.command == PLAYER_COMMAND_CLOSE_AUDIO) {
|
pc.command == PLAYER_COMMAND_CLOSE_AUDIO) {
|
||||||
@ -329,7 +329,7 @@ static void do_play(void)
|
|||||||
if (player.paused)
|
if (player.paused)
|
||||||
closeAudioDevice();
|
closeAudioDevice();
|
||||||
|
|
||||||
pc.totalTime = dc.total_time;
|
pc.total_time = dc.total_time;
|
||||||
pc.audio_format = dc.in_audio_format;
|
pc.audio_format = dc.in_audio_format;
|
||||||
play_audio_format = dc.out_audio_format;
|
play_audio_format = dc.out_audio_format;
|
||||||
sizeToTime = audioFormatSizeToTime(&dc.out_audio_format);
|
sizeToTime = audioFormatSizeToTime(&dc.out_audio_format);
|
||||||
@ -367,7 +367,7 @@ static void do_play(void)
|
|||||||
calculate how many chunks will be required
|
calculate how many chunks will be required
|
||||||
for it */
|
for it */
|
||||||
crossFadeChunks =
|
crossFadeChunks =
|
||||||
cross_fade_calc(pc.crossFade, dc.total_time,
|
cross_fade_calc(pc.cross_fade_seconds, dc.total_time,
|
||||||
&dc.out_audio_format,
|
&dc.out_audio_format,
|
||||||
music_pipe_size() -
|
music_pipe_size() -
|
||||||
pc.buffered_before_play);
|
pc.buffered_before_play);
|
||||||
@ -426,8 +426,8 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* play the current chunk */
|
/* play the current chunk */
|
||||||
if (playChunk(player.song, beginChunk,
|
if (play_chunk(player.song, beginChunk,
|
||||||
&play_audio_format, sizeToTime) < 0)
|
&play_audio_format, sizeToTime) < 0)
|
||||||
break;
|
break;
|
||||||
music_pipe_shift();
|
music_pipe_shift();
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ static void do_play(void)
|
|||||||
player.xfade = XFADE_UNKNOWN;
|
player.xfade = XFADE_UNKNOWN;
|
||||||
|
|
||||||
player.next_song_chunk = -1;
|
player.next_song_chunk = -1;
|
||||||
if (waitOnDecode(&player) < 0)
|
if (player_wait_for_decoder(&player) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wakeup_main_task();
|
wakeup_main_task();
|
||||||
@ -469,7 +469,7 @@ static void do_play(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quitDecode();
|
player_stop_decoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * player_task(mpd_unused void *arg)
|
static void * player_task(mpd_unused void *arg)
|
||||||
|
Reference in New Issue
Block a user