aboutsummaryrefslogtreecommitdiffstats
path: root/src/player.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-03-23 01:12:30 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-03-23 01:12:30 +0000
commit0783a2bde14af02c99c7c9fc137b3944bbee14c0 (patch)
tree9f8a58754aee9505d9dc644ce044515d23b27ea3 /src/player.c
parent4b4438853c3ae05392964eadd8962cb50eae7987 (diff)
downloadmpd-0783a2bde14af02c99c7c9fc137b3944bbee14c0.tar.gz
mpd-0783a2bde14af02c99c7c9fc137b3944bbee14c0.tar.xz
mpd-0783a2bde14af02c99c7c9fc137b3944bbee14c0.zip
fix a bug, due to not resetting decodeType in playerSeek when the file to
seek isn't the same as the current playing file git-svn-id: https://svn.musicpd.org/mpd/trunk@409 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c92
1 files changed, 43 insertions, 49 deletions
diff --git a/src/player.c b/src/player.c
index 81b78ca39..ea7d3723b 100644
--- a/src/player.c
+++ b/src/player.c
@@ -149,9 +149,31 @@ int playerInit() {
return 0;
}
+int playerGetDecodeType(char * utf8file) {
+ if(0);
+#ifdef HAVE_MAD
+ if(isMp3(utf8file,NULL)) return DECODE_TYPE_MP3;
+#endif
+#ifdef HAVE_OGG
+ if(isOgg(utf8file,NULL)) return DECODE_TYPE_OGG;
+#endif
+#ifdef HAVE_FLAC
+ if(isFlac(utf8file,NULL)) return DECODE_TYPE_FLAC;
+#endif
+#ifdef HAVE_AUDIOFILE
+ if(isWave(utf8file,NULL)) return DECODE_TYPE_AUDIOFILE;
+#endif
+#ifdef HAVE_FAAD
+ if(isAac(utf8file,NULL)) return DECODE_TYPE_AAC;
+ if(isMp4(utf8file,NULL)) return DECODE_TYPE_MP4;
+#endif
+ return -1;
+}
+
int playerPlay(FILE * fp, char * utf8file) {
PlayerControl * pc = &(getPlayerData()->playerControl);
if(fp==NULL) fp = stderr;
+ int decodeType;
if(playerStop(fp)<0) return -1;
@@ -163,29 +185,14 @@ int playerPlay(FILE * fp, char * utf8file) {
return 0;
}
}
-
- if(0);
-#ifdef HAVE_MAD
- else if(isMp3(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP3;
-#endif
-#ifdef HAVE_OGG
- else if(isOgg(utf8file,NULL)) pc->decodeType = DECODE_TYPE_OGG;
-#endif
-#ifdef HAVE_FLAC
- else if(isFlac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_FLAC;
-#endif
-#ifdef HAVE_AUDIOFILE
- else if(isWave(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AUDIOFILE;
-#endif
-#ifdef HAVE_FAAD
- else if(isAac(utf8file,NULL)) pc->decodeType = DECODE_TYPE_AAC;
- else if(isMp4(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP4;
-#endif
- else {
+
+ decodeType = playerGetDecodeType(utf8file);
+ if(decodeType < 0) {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->error = PLAYER_ERROR_UNKTYPE;
return 0;
}
+ pc->decodeType = decodeType;
strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
@@ -315,36 +322,15 @@ void playerCloseAudio() {
int queueSong(char * utf8file) {
PlayerControl * pc = &(getPlayerData()->playerControl);
+ int decodeType;
if(pc->queueState==PLAYER_QUEUE_BLANK) {
strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
- if(0);
-#ifdef HAVE_MAD
- else if(isMp3(utf8file,NULL)) pc->decodeType = DECODE_TYPE_MP3;
-#endif
-#ifdef HAVE_OGG
- else if(isOgg(utf8file,NULL)) pc->decodeType = DECODE_TYPE_OGG;
-#endif
-#ifdef HAVE_FLAC
- else if(isFlac(utf8file,NULL)) {
- pc->decodeType = DECODE_TYPE_FLAC;
- }
-#endif
-#ifdef HAVE_AUDIOFILE
- else if(isWave(utf8file,NULL)) {
- pc->decodeType = DECODE_TYPE_AUDIOFILE;
- }
-#endif
-#ifdef HAVE_AUDIOFILE
- else if(isAac(utf8file,NULL)) {
- pc->decodeType = DECODE_TYPE_AAC;
- }
- else if(isMp4(utf8file,NULL)) {
- pc->decodeType = DECODE_TYPE_MP4;
- }
-#endif
- else return -1;
+ decodeType = playerGetDecodeType(utf8file);
+ if(decodeType < 0) return -1;
+ pc->decodeType = decodeType;
+
pc->queueState = PLAYER_QUEUE_FULL;
return 0;
}
@@ -387,6 +373,7 @@ void playerQueueUnlock() {
int playerSeek(FILE * fp, char * utf8file, float time) {
PlayerControl * pc = &(getPlayerData()->playerControl);
char * file;
+ int decodeType;
if(pc->state==PLAYER_STATE_STOP) {
myfprintf(fp,"%s player not currently playing\n",
@@ -395,10 +382,17 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
}
file = rmp2amp(utf8ToFsCharset(utf8file));
- if(strcmp(pc->file,file)!=0) strncpy(pc->file,file,MAXPATHLEN);
- /*if(playerStop(fp)<0) return -1;
- if(playerPlay(stderr,file)<0) return -1;*/
- /*}*/
+ if(strcmp(pc->file,file)!=0) {
+ decodeType = playerGetDecodeType(utf8file);
+ if(decodeType < 0) {
+ printf("%s unknown file type: %s\n",
+ COMMAND_RESPOND_ERROR, utf8file);
+ return -1;
+ }
+ pc->decodeType = decodeType;
+
+ strncpy(pc->file,file,MAXPATHLEN);
+ }
if(pc->error==PLAYER_ERROR_NOERROR) {
pc->seekWhere = time;