player: no "fd" and no return value
Most player*() functions do not actually use the file descriptor, and always return 0 (success). Eliminate them to get a leaner interface.
This commit is contained in:
parent
6df980a996
commit
3db333b5a4
@ -292,9 +292,12 @@ static int handlePause(int fd, mpd_unused int *permission,
|
|||||||
int pause_flag;
|
int pause_flag;
|
||||||
if (check_int(fd, &pause_flag, argv[1], check_boolean, argv[1]) < 0)
|
if (check_int(fd, &pause_flag, argv[1], check_boolean, argv[1]) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
return playerSetPause(fd, pause_flag);
|
playerSetPause(pause_flag);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return playerPause(fd);
|
|
||||||
|
playerPause();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int commandStatus(mpd_unused int fd, mpd_unused int *permission,
|
static int commandStatus(mpd_unused int fd, mpd_unused int *permission,
|
||||||
|
37
src/player.c
37
src/player.c
@ -27,14 +27,10 @@
|
|||||||
|
|
||||||
static void playerCloseAudio(void);
|
static void playerCloseAudio(void);
|
||||||
|
|
||||||
int playerWait(int fd)
|
void playerWait(void)
|
||||||
{
|
{
|
||||||
if (playerStop(fd) < 0)
|
playerStop();
|
||||||
return -1;
|
|
||||||
|
|
||||||
playerCloseAudio();
|
playerCloseAudio();
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_current_song(Song *song)
|
static void set_current_song(Song *song)
|
||||||
@ -63,42 +59,35 @@ void player_command_finished()
|
|||||||
wakeup_main_task();
|
wakeup_main_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerPlay(int fd, Song * song)
|
void playerPlay(Song * song)
|
||||||
{
|
{
|
||||||
if (playerStop(fd) < 0)
|
playerStop();
|
||||||
return -1;
|
|
||||||
|
|
||||||
set_current_song(song);
|
set_current_song(song);
|
||||||
player_command(PLAYER_COMMAND_PLAY);
|
player_command(PLAYER_COMMAND_PLAY);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerStop(mpd_unused int fd)
|
void playerStop(void)
|
||||||
{
|
{
|
||||||
if (pc.state != PLAYER_STATE_STOP)
|
if (pc.state != PLAYER_STATE_STOP)
|
||||||
player_command(PLAYER_COMMAND_STOP);
|
player_command(PLAYER_COMMAND_STOP);
|
||||||
|
|
||||||
pc.queueState = PLAYER_QUEUE_BLANK;
|
pc.queueState = PLAYER_QUEUE_BLANK;
|
||||||
playerQueueUnlock();
|
playerQueueUnlock();
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void playerKill(void) /* deprecated */
|
void playerKill(void) /* deprecated */
|
||||||
{
|
{
|
||||||
playerPause(STDERR_FILENO);
|
playerPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerPause(mpd_unused int fd)
|
void playerPause(void)
|
||||||
{
|
{
|
||||||
if (pc.state != PLAYER_STATE_STOP)
|
if (pc.state != PLAYER_STATE_STOP)
|
||||||
player_command(PLAYER_COMMAND_PAUSE);
|
player_command(PLAYER_COMMAND_PAUSE);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerSetPause(int fd, int pause_flag)
|
void playerSetPause(int pause_flag)
|
||||||
{
|
{
|
||||||
switch (pc.state) {
|
switch (pc.state) {
|
||||||
case PLAYER_STATE_STOP:
|
case PLAYER_STATE_STOP:
|
||||||
@ -106,15 +95,13 @@ int playerSetPause(int fd, int pause_flag)
|
|||||||
|
|
||||||
case PLAYER_STATE_PLAY:
|
case PLAYER_STATE_PLAY:
|
||||||
if (pause_flag)
|
if (pause_flag)
|
||||||
playerPause(fd);
|
playerPause();
|
||||||
break;
|
break;
|
||||||
case PLAYER_STATE_PAUSE:
|
case PLAYER_STATE_PAUSE:
|
||||||
if (!pause_flag)
|
if (!pause_flag)
|
||||||
playerPause(fd);
|
playerPause();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPlayerElapsedTime(void)
|
int getPlayerElapsedTime(void)
|
||||||
@ -180,9 +167,7 @@ char *getPlayerErrorStr(void)
|
|||||||
|
|
||||||
static void playerCloseAudio(void)
|
static void playerCloseAudio(void)
|
||||||
{
|
{
|
||||||
if (playerStop(STDERR_FILENO) < 0)
|
playerStop();
|
||||||
return;
|
|
||||||
|
|
||||||
player_command(PLAYER_COMMAND_CLOSE_AUDIO);
|
player_command(PLAYER_COMMAND_CLOSE_AUDIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
src/player.h
10
src/player.h
@ -85,13 +85,13 @@ typedef struct _PlayerControl {
|
|||||||
|
|
||||||
void player_command_finished(void);
|
void player_command_finished(void);
|
||||||
|
|
||||||
int playerPlay(int fd, Song * song);
|
void playerPlay(Song * song);
|
||||||
|
|
||||||
int playerSetPause(int fd, int pause_flag);
|
void playerSetPause(int pause_flag);
|
||||||
|
|
||||||
int playerPause(int fd);
|
void playerPause(void);
|
||||||
|
|
||||||
int playerStop(int fd);
|
void playerStop(void);
|
||||||
|
|
||||||
void playerKill(void);
|
void playerKill(void);
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ char *getPlayerErrorStr(void);
|
|||||||
|
|
||||||
int getPlayerError(void);
|
int getPlayerError(void);
|
||||||
|
|
||||||
int playerWait(int fd);
|
void playerWait(void);
|
||||||
|
|
||||||
int queueSong(Song * song);
|
int queueSong(Song * song);
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
|
|||||||
playlist.length - 1, 0);
|
playlist.length - 1, 0);
|
||||||
}
|
}
|
||||||
if (state == PLAYER_STATE_PAUSE) {
|
if (state == PLAYER_STATE_PAUSE) {
|
||||||
playerPause(STDERR_FILENO);
|
playerPause();
|
||||||
}
|
}
|
||||||
if (state != PLAYER_STATE_STOP) {
|
if (state != PLAYER_STATE_STOP) {
|
||||||
seekSongInPlaylist(STDERR_FILENO,
|
seekSongInPlaylist(STDERR_FILENO,
|
||||||
@ -790,7 +790,7 @@ int deleteFromPlaylist(int fd, int song)
|
|||||||
&& playlist.current == songOrder) {
|
&& playlist.current == songOrder) {
|
||||||
/*if(playlist.current>=playlist.length) return playerStop(fd);
|
/*if(playlist.current>=playlist.length) return playerStop(fd);
|
||||||
else return playPlaylistOrderNumber(fd,playlist.current); */
|
else return playPlaylistOrderNumber(fd,playlist.current); */
|
||||||
playerWait(STDERR_FILENO);
|
playerWait();
|
||||||
playlist_noGoToNext = 1;
|
playlist_noGoToNext = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -828,11 +828,10 @@ void deleteASongFromPlaylist(Song * song)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int stopPlaylist(int fd)
|
int stopPlaylist(mpd_unused int fd)
|
||||||
{
|
{
|
||||||
DEBUG("playlist: stop\n");
|
DEBUG("playlist: stop\n");
|
||||||
if (playerWait(fd) < 0)
|
playerWait();
|
||||||
return -1;
|
|
||||||
playlist.queued = -1;
|
playlist.queued = -1;
|
||||||
playlist_state = PLAYLIST_STATE_STOP;
|
playlist_state = PLAYLIST_STATE_STOP;
|
||||||
playlist_noGoToNext = 0;
|
playlist_noGoToNext = 0;
|
||||||
@ -841,12 +840,11 @@ int stopPlaylist(int fd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int playPlaylistOrderNumber(int fd, int orderNum)
|
static int playPlaylistOrderNumber(mpd_unused int fd, int orderNum)
|
||||||
{
|
{
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
|
|
||||||
if (playerStop(fd) < 0)
|
playerStop();
|
||||||
return -1;
|
|
||||||
|
|
||||||
playlist_state = PLAYLIST_STATE_PLAY;
|
playlist_state = PLAYLIST_STATE_PLAY;
|
||||||
playlist_noGoToNext = 0;
|
playlist_noGoToNext = 0;
|
||||||
@ -857,11 +855,7 @@ static int playPlaylistOrderNumber(int fd, int orderNum)
|
|||||||
get_song_url(path_max_tmp,
|
get_song_url(path_max_tmp,
|
||||||
playlist.songs[playlist.order[orderNum]]));
|
playlist.songs[playlist.order[orderNum]]));
|
||||||
|
|
||||||
if (playerPlay(fd, (playlist.songs[playlist.order[orderNum]])) < 0) {
|
playerPlay(playlist.songs[playlist.order[orderNum]]);
|
||||||
stopPlaylist(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
playlist.current = orderNum;
|
playlist.current = orderNum;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -878,7 +872,8 @@ int playPlaylist(int fd, int song, int stopOnError)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
if (playlist_state == PLAYLIST_STATE_PLAY) {
|
||||||
return playerSetPause(fd, 0);
|
playerSetPause(0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
if (playlist.current >= 0 && playlist.current < playlist.length) {
|
if (playlist.current >= 0 && playlist.current < playlist.length) {
|
||||||
i = playlist.current;
|
i = playlist.current;
|
||||||
|
Loading…
Reference in New Issue
Block a user