We should avoid having protocol specific code in player.c.  Just
return success or failure, and let the caller send the error code to
the MPD client.
---

 src/player.c   |    8 ++------
 src/player.h   |    2 +-
 src/playlist.c |    8 ++++++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/player.c b/src/player.c
index 8803cdf..8687e54 100644
--- a/src/player.c
+++ b/src/player.c
@@ -19,7 +19,6 @@
 #include "player.h"
 #include "player_thread.h"
 #include "path.h"
-#include "command.h"
 #include "ack.h"
 #include "os_compat.h"
 #include "main_notify.h"
@@ -197,15 +196,12 @@ void playerQueueUnlock(void)
        assert(pc.queueLockState == PLAYER_QUEUE_UNLOCKED);
 }
 
-int playerSeek(int fd, Song * song, float seek_time)
+int playerSeek(Song * song, float seek_time)
 {
        assert(song != NULL);
 
-       if (pc.state == PLAYER_STATE_STOP) {
-               commandError(fd, ACK_ERROR_PLAYER_SYNC,
-                            "player not currently playing");
+       if (pc.state == PLAYER_STATE_STOP)
                return -1;
-       }
 
        if (pc.next_song != song)
                set_current_song(song);
diff --git a/src/player.h b/src/player.h
index a030c02..fcdbb00 100644
--- a/src/player.h
+++ b/src/player.h
@@ -139,7 +139,7 @@ void playerQueueLock(void);
 
 void playerQueueUnlock(void);
 
-int playerSeek(int fd, Song * song, float seek_time);
+int playerSeek(Song * song, float seek_time);
 
 void setPlayerCrossFade(float crossFadeInSeconds);
 
diff --git a/src/playlist.c b/src/playlist.c
index 8ffd566..4560b85 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1354,7 +1354,7 @@ int getPlaylistLength(void)
 
 int seekSongInPlaylist(int fd, int song, float seek_time)
 {
-       int i;
+       int i, ret;
 
        if (song < 0 || song >= playlist.length) {
                commandError(fd, ACK_ERROR_NO_EXIST,
@@ -1381,7 +1381,11 @@ int seekSongInPlaylist(int fd, int song, float seek_time)
                playPlaylistOrderNumber(i);
        }
 
-       return playerSeek(fd, playlist.songs[playlist.order[i]], seek_time);
+       ret = playerSeek(playlist.songs[playlist.order[i]], seek_time);
+       if (ret < 0)
+               commandError(fd, ACK_ERROR_PLAYER_SYNC,
+                            "player not currently playing");
+       return ret;
 }
 
 int seekSongInPlaylistById(int fd, int id, float seek_time)



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to