Commit e5857cb7 authored by Max Kellermann's avatar Max Kellermann

player_control: no CamelCase

parent 2ec89c63
...@@ -440,11 +440,11 @@ handle_pause(struct client *client, ...@@ -440,11 +440,11 @@ handle_pause(struct client *client,
bool pause_flag; bool pause_flag;
if (!check_bool(client, &pause_flag, argv[1])) if (!check_bool(client, &pause_flag, argv[1]))
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
playerSetPause(pause_flag);
return COMMAND_RETURN_OK;
}
playerPause(); pc_set_pause(pause_flag);
} else
pc_pause();
return COMMAND_RETURN_OK; return COMMAND_RETURN_OK;
} }
...@@ -489,7 +489,7 @@ handle_status(struct client *client, ...@@ -489,7 +489,7 @@ handle_status(struct client *client,
playlist_get_consume(&g_playlist), playlist_get_consume(&g_playlist),
playlist_get_version(&g_playlist), playlist_get_version(&g_playlist),
playlist_get_length(&g_playlist), playlist_get_length(&g_playlist),
(int)(getPlayerCrossFade() + 0.5), (int)(pc_get_cross_fade() + 0.5),
state); state);
song = playlist_get_current_song(&g_playlist); song = playlist_get_current_song(&g_playlist);
...@@ -521,7 +521,7 @@ handle_status(struct client *client, ...@@ -521,7 +521,7 @@ handle_status(struct client *client,
updateJobId); updateJobId);
} }
error = getPlayerErrorStr(); error = pc_get_error_message();
if (error != NULL) { if (error != NULL) {
client_printf(client, client_printf(client,
COMMAND_STATUS_ERROR ": %s\n", COMMAND_STATUS_ERROR ": %s\n",
...@@ -1212,7 +1212,7 @@ static enum command_return ...@@ -1212,7 +1212,7 @@ static enum command_return
handle_clearerror(G_GNUC_UNUSED struct client *client, handle_clearerror(G_GNUC_UNUSED struct client *client,
G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[]) G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
{ {
clearPlayerError(); pc_clear_error();
return COMMAND_RETURN_OK; return COMMAND_RETURN_OK;
} }
...@@ -1403,7 +1403,7 @@ handle_crossfade(struct client *client, G_GNUC_UNUSED int argc, char *argv[]) ...@@ -1403,7 +1403,7 @@ handle_crossfade(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if (!check_unsigned(client, &xfade_time, argv[1])) if (!check_unsigned(client, &xfade_time, argv[1]))
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
setPlayerCrossFade(xfade_time); pc_set_cross_fade(xfade_time);
return COMMAND_RETURN_OK; return COMMAND_RETURN_OK;
} }
......
...@@ -386,7 +386,7 @@ int main(int argc, char *argv[]) ...@@ -386,7 +386,7 @@ int main(int argc, char *argv[])
mpd_inotify_finish(); mpd_inotify_finish();
state_file_finish(); state_file_finish();
playerKill(); pc_kill();
finishZeroconf(); finishZeroconf();
client_manager_deinit(); client_manager_deinit();
listen_global_finish(); listen_global_finish();
......
...@@ -68,7 +68,7 @@ static void player_command(enum player_command cmd) ...@@ -68,7 +68,7 @@ static void player_command(enum player_command cmd)
} }
void void
playerPlay(struct song *song) pc_play(struct song *song)
{ {
assert(song != NULL); assert(song != NULL);
...@@ -86,14 +86,16 @@ void pc_cancel(void) ...@@ -86,14 +86,16 @@ void pc_cancel(void)
player_command(PLAYER_COMMAND_CANCEL); player_command(PLAYER_COMMAND_CANCEL);
} }
void playerWait(void) void
pc_stop(void)
{ {
player_command(PLAYER_COMMAND_CLOSE_AUDIO); player_command(PLAYER_COMMAND_CLOSE_AUDIO);
idle_add(IDLE_PLAYER); idle_add(IDLE_PLAYER);
} }
void playerKill(void) void
pc_kill(void)
{ {
assert(pc.thread != NULL); assert(pc.thread != NULL);
...@@ -104,7 +106,8 @@ void playerKill(void) ...@@ -104,7 +106,8 @@ void playerKill(void)
idle_add(IDLE_PLAYER); idle_add(IDLE_PLAYER);
} }
void playerPause(void) void
pc_pause(void)
{ {
if (pc.state != PLAYER_STATE_STOP) { if (pc.state != PLAYER_STATE_STOP) {
player_command(PLAYER_COMMAND_PAUSE); player_command(PLAYER_COMMAND_PAUSE);
...@@ -112,7 +115,8 @@ void playerPause(void) ...@@ -112,7 +115,8 @@ void playerPause(void)
} }
} }
void playerSetPause(int pause_flag) void
pc_set_pause(bool pause_flag)
{ {
switch (pc.state) { switch (pc.state) {
case PLAYER_STATE_STOP: case PLAYER_STATE_STOP:
...@@ -120,11 +124,12 @@ void playerSetPause(int pause_flag) ...@@ -120,11 +124,12 @@ void playerSetPause(int pause_flag)
case PLAYER_STATE_PLAY: case PLAYER_STATE_PLAY:
if (pause_flag) if (pause_flag)
playerPause(); pc_pause();
break; break;
case PLAYER_STATE_PAUSE: case PLAYER_STATE_PAUSE:
if (!pause_flag) if (!pause_flag)
playerPause(); pc_pause();
break; break;
} }
} }
...@@ -142,18 +147,21 @@ pc_get_status(struct player_status *status) ...@@ -142,18 +147,21 @@ pc_get_status(struct player_status *status)
} }
} }
enum player_state getPlayerState(void) enum player_state
pc_get_state(void)
{ {
return pc.state; return pc.state;
} }
void clearPlayerError(void) void
pc_clear_error(void)
{ {
pc.error = PLAYER_ERROR_NOERROR; pc.error = PLAYER_ERROR_NOERROR;
pc.errored_song = NULL; pc.errored_song = NULL;
} }
enum player_error getPlayerError(void) enum player_error
pc_get_error(void)
{ {
return pc.error; return pc.error;
} }
...@@ -164,7 +172,8 @@ pc_errored_song_uri(void) ...@@ -164,7 +172,8 @@ pc_errored_song_uri(void)
return song_get_uri(pc.errored_song); return song_get_uri(pc.errored_song);
} }
char *getPlayerErrorStr(void) char *
pc_get_error_message(void)
{ {
char *error; char *error;
char *uri; char *uri;
...@@ -203,7 +212,7 @@ char *getPlayerErrorStr(void) ...@@ -203,7 +212,7 @@ char *getPlayerErrorStr(void)
} }
void void
queueSong(struct song *song) pc_enqueue_song(struct song *song)
{ {
assert(song != NULL); assert(song != NULL);
assert(pc.next_song == NULL); assert(pc.next_song == NULL);
...@@ -231,21 +240,24 @@ pc_seek(struct song *song, float seek_time) ...@@ -231,21 +240,24 @@ pc_seek(struct song *song, float seek_time)
return true; return true;
} }
float getPlayerCrossFade(void) float
pc_get_cross_fade(void)
{ {
return pc.cross_fade_seconds; return pc.cross_fade_seconds;
} }
void setPlayerCrossFade(float crossFadeInSeconds) void
pc_set_cross_fade(float cross_fade_seconds)
{ {
if (crossFadeInSeconds < 0) if (cross_fade_seconds < 0)
crossFadeInSeconds = 0; cross_fade_seconds = 0;
pc.cross_fade_seconds = crossFadeInSeconds; pc.cross_fade_seconds = cross_fade_seconds;
idle_add(IDLE_OPTIONS); idle_add(IDLE_OPTIONS);
} }
double getPlayerTotalPlayTime(void) double
pc_get_total_play_time(void)
{ {
return pc.total_play_time; return pc.total_play_time;
} }
...@@ -107,39 +107,47 @@ void ...@@ -107,39 +107,47 @@ void
pc_song_deleted(const struct song *song); pc_song_deleted(const struct song *song);
void void
playerPlay(struct song *song); pc_play(struct song *song);
/** /**
* see PLAYER_COMMAND_CANCEL * see PLAYER_COMMAND_CANCEL
*/ */
void pc_cancel(void); void pc_cancel(void);
void playerSetPause(int pause_flag); void
pc_set_pause(bool pause_flag);
void playerPause(void); void
pc_pause(void);
void playerKill(void); void
pc_kill(void);
void void
pc_get_status(struct player_status *status); pc_get_status(struct player_status *status);
enum player_state getPlayerState(void); enum player_state
pc_get_state(void);
void clearPlayerError(void); void
pc_clear_error(void);
/** /**
* Returns the human-readable message describing the last error during * Returns the human-readable message describing the last error during
* playback, NULL if no error occurred. The caller has to free the * playback, NULL if no error occurred. The caller has to free the
* returned string. * returned string.
*/ */
char *getPlayerErrorStr(void); char *
pc_get_error_message(void);
enum player_error getPlayerError(void); enum player_error
pc_get_error(void);
void playerWait(void); void
pc_stop(void);
void void
queueSong(struct song *song); pc_enqueue_song(struct song *song);
/** /**
* Makes the player thread seek the specified song to a position. * Makes the player thread seek the specified song to a position.
...@@ -150,12 +158,13 @@ queueSong(struct song *song); ...@@ -150,12 +158,13 @@ queueSong(struct song *song);
bool bool
pc_seek(struct song *song, float seek_time); pc_seek(struct song *song, float seek_time);
void setPlayerCrossFade(float crossFadeInSeconds); void
pc_set_cross_fade(float cross_fade_seconds);
float getPlayerCrossFade(void);
double getPlayerTotalPlayTime(void); float
pc_get_cross_fade(void);
void playerInit(void); double
pc_get_total_play_time(void);
#endif #endif
...@@ -88,7 +88,7 @@ playlist_queue_song_order(struct playlist *playlist, unsigned order) ...@@ -88,7 +88,7 @@ playlist_queue_song_order(struct playlist *playlist, unsigned order)
g_debug("queue song %i:\"%s\"", playlist->queued, uri); g_debug("queue song %i:\"%s\"", playlist->queued, uri);
g_free(uri); g_free(uri);
queueSong(song); pc_enqueue_song(song);
} }
/** /**
...@@ -190,7 +190,7 @@ playlist_play_order(struct playlist *playlist, int orderNum) ...@@ -190,7 +190,7 @@ playlist_play_order(struct playlist *playlist, int orderNum)
g_debug("play %i:\"%s\"", orderNum, uri); g_debug("play %i:\"%s\"", orderNum, uri);
g_free(uri); g_free(uri);
playerPlay(song); pc_play(song);
playlist->current = orderNum; playlist->current = orderNum;
} }
...@@ -209,7 +209,7 @@ playlist_sync(struct playlist *playlist) ...@@ -209,7 +209,7 @@ playlist_sync(struct playlist *playlist)
playing anymore; ignore the event */ playing anymore; ignore the event */
return; return;
if (getPlayerState() == PLAYER_STATE_STOP) if (pc_get_state() == PLAYER_STATE_STOP)
/* the player thread has stopped: check if playback /* the player thread has stopped: check if playback
should be restarted with the next song. That can should be restarted with the next song. That can
happen if the playlist isn't filling the queue fast happen if the playlist isn't filling the queue fast
...@@ -237,9 +237,9 @@ playlist_resume_playback(struct playlist *playlist) ...@@ -237,9 +237,9 @@ playlist_resume_playback(struct playlist *playlist)
enum player_error error; enum player_error error;
assert(playlist->playing); assert(playlist->playing);
assert(getPlayerState() == PLAYER_STATE_STOP); assert(pc_get_state() == PLAYER_STATE_STOP);
error = getPlayerError(); error = pc_get_error();
if (error == PLAYER_ERROR_NOERROR) if (error == PLAYER_ERROR_NOERROR)
playlist->error_count = 0; playlist->error_count = 0;
else else
......
...@@ -38,7 +38,7 @@ void playlist_stop(struct playlist *playlist) ...@@ -38,7 +38,7 @@ void playlist_stop(struct playlist *playlist)
assert(playlist->current >= 0); assert(playlist->current >= 0);
g_debug("stop"); g_debug("stop");
playerWait(); pc_stop();
playlist->queued = -1; playlist->queued = -1;
playlist->playing = false; playlist->playing = false;
...@@ -64,7 +64,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song) ...@@ -64,7 +64,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song)
{ {
unsigned i = song; unsigned i = song;
clearPlayerError(); pc_clear_error();
if (song == -1) { if (song == -1) {
/* play any song ("current" song, or the first song */ /* play any song ("current" song, or the first song */
...@@ -75,7 +75,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song) ...@@ -75,7 +75,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song)
if (playlist->playing) { if (playlist->playing) {
/* already playing: unpause playback, just in /* already playing: unpause playback, just in
case it was paused, and return */ case it was paused, and return */
playerSetPause(0); pc_set_pause(false);
return PLAYLIST_RESULT_SUCCESS; return PLAYLIST_RESULT_SUCCESS;
} }
...@@ -217,7 +217,7 @@ playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time) ...@@ -217,7 +217,7 @@ playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time)
else else
i = song; i = song;
clearPlayerError(); pc_clear_error();
playlist->stop_on_error = true; playlist->stop_on_error = true;
playlist->error_count = 0; playlist->error_count = 0;
......
...@@ -219,11 +219,11 @@ playlist_delete_internal(struct playlist *playlist, unsigned song, ...@@ -219,11 +219,11 @@ playlist_delete_internal(struct playlist *playlist, unsigned song,
songOrder = queue_position_to_order(&playlist->queue, song); songOrder = queue_position_to_order(&playlist->queue, song);
if (playlist->playing && playlist->current == (int)songOrder) { if (playlist->playing && playlist->current == (int)songOrder) {
bool paused = getPlayerState() == PLAYER_STATE_PAUSE; bool paused = pc_get_state() == PLAYER_STATE_PAUSE;
/* the current song is going to be deleted: stop the player */ /* the current song is going to be deleted: stop the player */
playerWait(); pc_stop();
playlist->playing = false; playlist->playing = false;
/* see which song is going to be played instead */ /* see which song is going to be played instead */
......
...@@ -88,7 +88,7 @@ playlist_state_save(FILE *fp, const struct playlist *playlist) ...@@ -88,7 +88,7 @@ playlist_state_save(FILE *fp, const struct playlist *playlist)
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CONSUME, fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CONSUME,
playlist->queue.consume); playlist->queue.consume);
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE, fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
(int)(getPlayerCrossFade())); (int)(pc_get_cross_fade()));
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN); fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
queue_save(fp, &playlist->queue); queue_save(fp, &playlist->queue);
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END); fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
...@@ -166,11 +166,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist) ...@@ -166,11 +166,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
} else } else
playlist_set_consume(playlist, false); playlist_set_consume(playlist, false);
} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CROSSFADE)) { } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CROSSFADE)) {
setPlayerCrossFade(atoi pc_set_cross_fade(atoi(buffer + strlen(PLAYLIST_STATE_FILE_CROSSFADE)));
(&
(buffer
[strlen
(PLAYLIST_STATE_FILE_CROSSFADE)])));
} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_RANDOM)) { } else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_RANDOM)) {
random_mode = random_mode =
strcmp(buffer + strlen(PLAYLIST_STATE_FILE_RANDOM), strcmp(buffer + strlen(PLAYLIST_STATE_FILE_RANDOM),
...@@ -199,7 +195,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist) ...@@ -199,7 +195,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
playlist_seek_song(playlist, current, seek_time); playlist_seek_song(playlist, current, seek_time);
if (state == PLAYER_STATE_PAUSE) if (state == PLAYER_STATE_PAUSE)
playerPause(); pc_pause();
} }
return true; return true;
...@@ -220,7 +216,7 @@ playlist_state_get_hash(const struct playlist *playlist) ...@@ -220,7 +216,7 @@ playlist_state_get_hash(const struct playlist *playlist)
? (queue_order_to_position(&playlist->queue, ? (queue_order_to_position(&playlist->queue,
playlist->current) << 16) playlist->current) << 16)
: 0) ^ : 0) ^
((int)getPlayerCrossFade() << 20) ^ ((int)pc_get_cross_fade() << 20) ^
(player_status.state << 24) ^ (player_status.state << 24) ^
(playlist->queue.random << 27) ^ (playlist->queue.random << 27) ^
(playlist->queue.repeat << 28) ^ (playlist->queue.repeat << 28) ^
......
...@@ -113,7 +113,7 @@ int stats_print(struct client *client) ...@@ -113,7 +113,7 @@ int stats_print(struct client *client)
stats.album_count, stats.album_count,
stats.song_count, stats.song_count,
(long)g_timer_elapsed(stats.timer, NULL), (long)g_timer_elapsed(stats.timer, NULL),
(long)(getPlayerTotalPlayTime() + 0.5), (long)(pc_get_total_play_time() + 0.5),
stats.song_duration, stats.song_duration,
db_get_mtime()); db_get_mtime());
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment