diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-01-03 07:22:08 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-01-03 07:22:08 +0000 |
commit | 7de5f9cef1dee812c4b312832635538c78b20d9d (patch) | |
tree | ddf26a65b7667432f2ae47ce56e57874b175da69 | |
parent | 00e0224996bcb76ba0f7896393f36ff01ed1882b (diff) | |
download | mpd-7de5f9cef1dee812c4b312832635538c78b20d9d.tar.gz mpd-7de5f9cef1dee812c4b312832635538c78b20d9d.tar.xz mpd-7de5f9cef1dee812c4b312832635538c78b20d9d.zip |
player.c: introduce set_current_song to avoid needless repetition
git-svn-id: https://svn.musicpd.org/mpd/trunk@7126 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r-- | src/player.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/player.c b/src/player.c index ef66229bc..b01753de2 100644 --- a/src/player.c +++ b/src/player.c @@ -208,6 +208,15 @@ int playerWait(int fd) return 0; } +static void set_current_song(Song *song) +{ + PlayerControl *pc = &(getPlayerData()->playerControl); + + pc->fileTime = song->tag ? song->tag->time : 0; + copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk)); + get_song_url(pc->utf8url, song); +} + int playerPlay(int fd, Song * song) { PlayerControl *pc = &(getPlayerData()->playerControl); @@ -215,14 +224,7 @@ int playerPlay(int fd, Song * song) if (playerStop(fd) < 0) return -1; - if (song->tag) - pc->fileTime = song->tag->time; - else - pc->fileTime = 0; - - copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk)); - - get_song_url(pc->utf8url, song); + set_current_song(song); pc->play = 1; if (playerInit() < 0) { @@ -395,15 +397,7 @@ int queueSong(Song * song) PlayerControl *pc = &(getPlayerData()->playerControl); if (pc->queueState == PLAYER_QUEUE_BLANK) { - get_song_url(pc->utf8url, song); - - if (song->tag) - pc->fileTime = song->tag->time; - else - pc->fileTime = 0; - - copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk)); - + set_current_song(song); pc->queueState = PLAYER_QUEUE_FULL; return 0; } @@ -462,16 +456,8 @@ int playerSeek(int fd, Song * song, float time) return -1; } - if (strcmp(pc->utf8url, get_song_url(path_max_tmp, song)) != 0) { - if (song->tag) - pc->fileTime = song->tag->time; - else - pc->fileTime = 0; - - copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk)); - - strcpy(pc->utf8url, path_max_tmp); - } + if (strcmp(pc->utf8url, get_song_url(path_max_tmp, song)) != 0) + set_current_song(song); if (pc->error == PLAYER_ERROR_NOERROR) { resetPlayerMetadata(); |