aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/command.c16
-rw-r--r--src/main.c2
-rw-r--r--src/player_control.c48
-rw-r--r--src/player_control.h39
-rw-r--r--src/playlist.c10
-rw-r--r--src/playlist_control.c8
-rw-r--r--src/playlist_edit.c4
-rw-r--r--src/playlist_state.c12
-rw-r--r--src/stats.c2
9 files changed, 79 insertions, 62 deletions
diff --git a/src/command.c b/src/command.c
index 9cd6d0e38..3866d039c 100644
--- a/src/command.c
+++ b/src/command.c
@@ -440,11 +440,11 @@ handle_pause(struct client *client,
bool pause_flag;
if (!check_bool(client, &pause_flag, argv[1]))
return COMMAND_RETURN_ERROR;
- playerSetPause(pause_flag);
- return COMMAND_RETURN_OK;
- }
- playerPause();
+ pc_set_pause(pause_flag);
+ } else
+ pc_pause();
+
return COMMAND_RETURN_OK;
}
@@ -489,7 +489,7 @@ handle_status(struct client *client,
playlist_get_consume(&g_playlist),
playlist_get_version(&g_playlist),
playlist_get_length(&g_playlist),
- (int)(getPlayerCrossFade() + 0.5),
+ (int)(pc_get_cross_fade() + 0.5),
state);
song = playlist_get_current_song(&g_playlist);
@@ -521,7 +521,7 @@ handle_status(struct client *client,
updateJobId);
}
- error = getPlayerErrorStr();
+ error = pc_get_error_message();
if (error != NULL) {
client_printf(client,
COMMAND_STATUS_ERROR ": %s\n",
@@ -1212,7 +1212,7 @@ static enum command_return
handle_clearerror(G_GNUC_UNUSED struct client *client,
G_GNUC_UNUSED int argc, G_GNUC_UNUSED char *argv[])
{
- clearPlayerError();
+ pc_clear_error();
return COMMAND_RETURN_OK;
}
@@ -1403,7 +1403,7 @@ handle_crossfade(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
if (!check_unsigned(client, &xfade_time, argv[1]))
return COMMAND_RETURN_ERROR;
- setPlayerCrossFade(xfade_time);
+ pc_set_cross_fade(xfade_time);
return COMMAND_RETURN_OK;
}
diff --git a/src/main.c b/src/main.c
index bb0d09eaf..d721bfe00 100644
--- a/src/main.c
+++ b/src/main.c
@@ -386,7 +386,7 @@ int main(int argc, char *argv[])
mpd_inotify_finish();
state_file_finish();
- playerKill();
+ pc_kill();
finishZeroconf();
client_manager_deinit();
listen_global_finish();
diff --git a/src/player_control.c b/src/player_control.c
index 26b7e517a..f20049484 100644
--- a/src/player_control.c
+++ b/src/player_control.c
@@ -68,7 +68,7 @@ static void player_command(enum player_command cmd)
}
void
-playerPlay(struct song *song)
+pc_play(struct song *song)
{
assert(song != NULL);
@@ -86,14 +86,16 @@ void pc_cancel(void)
player_command(PLAYER_COMMAND_CANCEL);
}
-void playerWait(void)
+void
+pc_stop(void)
{
player_command(PLAYER_COMMAND_CLOSE_AUDIO);
idle_add(IDLE_PLAYER);
}
-void playerKill(void)
+void
+pc_kill(void)
{
assert(pc.thread != NULL);
@@ -104,7 +106,8 @@ void playerKill(void)
idle_add(IDLE_PLAYER);
}
-void playerPause(void)
+void
+pc_pause(void)
{
if (pc.state != PLAYER_STATE_STOP) {
player_command(PLAYER_COMMAND_PAUSE);
@@ -112,7 +115,8 @@ void playerPause(void)
}
}
-void playerSetPause(int pause_flag)
+void
+pc_set_pause(bool pause_flag)
{
switch (pc.state) {
case PLAYER_STATE_STOP:
@@ -120,11 +124,12 @@ void playerSetPause(int pause_flag)
case PLAYER_STATE_PLAY:
if (pause_flag)
- playerPause();
+ pc_pause();
break;
+
case PLAYER_STATE_PAUSE:
if (!pause_flag)
- playerPause();
+ pc_pause();
break;
}
}
@@ -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;
}
-void clearPlayerError(void)
+void
+pc_clear_error(void)
{
pc.error = PLAYER_ERROR_NOERROR;
pc.errored_song = NULL;
}
-enum player_error getPlayerError(void)
+enum player_error
+pc_get_error(void)
{
return pc.error;
}
@@ -164,7 +172,8 @@ pc_errored_song_uri(void)
return song_get_uri(pc.errored_song);
}
-char *getPlayerErrorStr(void)
+char *
+pc_get_error_message(void)
{
char *error;
char *uri;
@@ -203,7 +212,7 @@ char *getPlayerErrorStr(void)
}
void
-queueSong(struct song *song)
+pc_enqueue_song(struct song *song)
{
assert(song != NULL);
assert(pc.next_song == NULL);
@@ -231,21 +240,24 @@ pc_seek(struct song *song, float seek_time)
return true;
}
-float getPlayerCrossFade(void)
+float
+pc_get_cross_fade(void)
{
return pc.cross_fade_seconds;
}
-void setPlayerCrossFade(float crossFadeInSeconds)
+void
+pc_set_cross_fade(float cross_fade_seconds)
{
- if (crossFadeInSeconds < 0)
- crossFadeInSeconds = 0;
- pc.cross_fade_seconds = crossFadeInSeconds;
+ if (cross_fade_seconds < 0)
+ cross_fade_seconds = 0;
+ pc.cross_fade_seconds = cross_fade_seconds;
idle_add(IDLE_OPTIONS);
}
-double getPlayerTotalPlayTime(void)
+double
+pc_get_total_play_time(void)
{
return pc.total_play_time;
}
diff --git a/src/player_control.h b/src/player_control.h
index e6b19ee68..a18120ca1 100644
--- a/src/player_control.h
+++ b/src/player_control.h
@@ -107,39 +107,47 @@ void
pc_song_deleted(const struct song *song);
void
-playerPlay(struct song *song);
+pc_play(struct song *song);
/**
* see PLAYER_COMMAND_CANCEL
*/
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
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
* playback, NULL if no error occurred. The caller has to free the
* 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
-queueSong(struct song *song);
+pc_enqueue_song(struct song *song);
/**
* Makes the player thread seek the specified song to a position.
@@ -150,12 +158,13 @@ queueSong(struct song *song);
bool
pc_seek(struct song *song, float seek_time);
-void setPlayerCrossFade(float crossFadeInSeconds);
-
-float getPlayerCrossFade(void);
+void
+pc_set_cross_fade(float cross_fade_seconds);
-double getPlayerTotalPlayTime(void);
+float
+pc_get_cross_fade(void);
-void playerInit(void);
+double
+pc_get_total_play_time(void);
#endif
diff --git a/src/playlist.c b/src/playlist.c
index 62a723d34..6ca9d014b 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -88,7 +88,7 @@ playlist_queue_song_order(struct playlist *playlist, unsigned order)
g_debug("queue song %i:\"%s\"", playlist->queued, uri);
g_free(uri);
- queueSong(song);
+ pc_enqueue_song(song);
}
/**
@@ -190,7 +190,7 @@ playlist_play_order(struct playlist *playlist, int orderNum)
g_debug("play %i:\"%s\"", orderNum, uri);
g_free(uri);
- playerPlay(song);
+ pc_play(song);
playlist->current = orderNum;
}
@@ -209,7 +209,7 @@ playlist_sync(struct playlist *playlist)
playing anymore; ignore the event */
return;
- if (getPlayerState() == PLAYER_STATE_STOP)
+ if (pc_get_state() == PLAYER_STATE_STOP)
/* the player thread has stopped: check if playback
should be restarted with the next song. That can
happen if the playlist isn't filling the queue fast
@@ -237,9 +237,9 @@ playlist_resume_playback(struct playlist *playlist)
enum player_error error;
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)
playlist->error_count = 0;
else
diff --git a/src/playlist_control.c b/src/playlist_control.c
index 16f4d5738..66e7934dc 100644
--- a/src/playlist_control.c
+++ b/src/playlist_control.c
@@ -38,7 +38,7 @@ void playlist_stop(struct playlist *playlist)
assert(playlist->current >= 0);
g_debug("stop");
- playerWait();
+ pc_stop();
playlist->queued = -1;
playlist->playing = false;
@@ -64,7 +64,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song)
{
unsigned i = song;
- clearPlayerError();
+ pc_clear_error();
if (song == -1) {
/* play any song ("current" song, or the first song */
@@ -75,7 +75,7 @@ enum playlist_result playlist_play(struct playlist *playlist, int song)
if (playlist->playing) {
/* already playing: unpause playback, just in
case it was paused, and return */
- playerSetPause(0);
+ pc_set_pause(false);
return PLAYLIST_RESULT_SUCCESS;
}
@@ -217,7 +217,7 @@ playlist_seek_song(struct playlist *playlist, unsigned song, float seek_time)
else
i = song;
- clearPlayerError();
+ pc_clear_error();
playlist->stop_on_error = true;
playlist->error_count = 0;
diff --git a/src/playlist_edit.c b/src/playlist_edit.c
index 473305f17..8052f8470 100644
--- a/src/playlist_edit.c
+++ b/src/playlist_edit.c
@@ -219,11 +219,11 @@ playlist_delete_internal(struct playlist *playlist, unsigned song,
songOrder = queue_position_to_order(&playlist->queue, song);
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 */
- playerWait();
+ pc_stop();
playlist->playing = false;
/* see which song is going to be played instead */
diff --git a/src/playlist_state.c b/src/playlist_state.c
index 16b75efae..d97fb1369 100644
--- a/src/playlist_state.c
+++ b/src/playlist_state.c
@@ -88,7 +88,7 @@ playlist_state_save(FILE *fp, const struct playlist *playlist)
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CONSUME,
playlist->queue.consume);
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);
queue_save(fp, &playlist->queue);
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
@@ -166,11 +166,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
} else
playlist_set_consume(playlist, false);
} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_CROSSFADE)) {
- setPlayerCrossFade(atoi
- (&
- (buffer
- [strlen
- (PLAYLIST_STATE_FILE_CROSSFADE)])));
+ pc_set_cross_fade(atoi(buffer + strlen(PLAYLIST_STATE_FILE_CROSSFADE)));
} else if (g_str_has_prefix(buffer, PLAYLIST_STATE_FILE_RANDOM)) {
random_mode =
strcmp(buffer + strlen(PLAYLIST_STATE_FILE_RANDOM),
@@ -199,7 +195,7 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist)
playlist_seek_song(playlist, current, seek_time);
if (state == PLAYER_STATE_PAUSE)
- playerPause();
+ pc_pause();
}
return true;
@@ -220,7 +216,7 @@ playlist_state_get_hash(const struct playlist *playlist)
? (queue_order_to_position(&playlist->queue,
playlist->current) << 16)
: 0) ^
- ((int)getPlayerCrossFade() << 20) ^
+ ((int)pc_get_cross_fade() << 20) ^
(player_status.state << 24) ^
(playlist->queue.random << 27) ^
(playlist->queue.repeat << 28) ^
diff --git a/src/stats.c b/src/stats.c
index 01f6761f3..70e790b83 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -113,7 +113,7 @@ int stats_print(struct client *client)
stats.album_count,
stats.song_count,
(long)g_timer_elapsed(stats.timer, NULL),
- (long)(getPlayerTotalPlayTime() + 0.5),
+ (long)(pc_get_total_play_time() + 0.5),
stats.song_duration,
db_get_mtime());
return 0;