aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/player.c51
-rw-r--r--src/player.h8
-rw-r--r--src/playlist.c16
3 files changed, 43 insertions, 32 deletions
diff --git a/src/player.c b/src/player.c
index aa3f34362..82f3101cd 100644
--- a/src/player.c
+++ b/src/player.c
@@ -186,7 +186,7 @@ int playerGetSuffix(char * utf8file) {
return -1;
}
-int playerPlay(FILE * fp, char * utf8file) {
+int playerPlay(FILE * fp, Song * song) {
PlayerControl * pc = &(getPlayerData()->playerControl);
int decodeType;
@@ -204,7 +204,7 @@ int playerPlay(FILE * fp, char * utf8file) {
}
}*/
- decodeType = playerGetDecodeType(utf8file);
+ decodeType = playerGetDecodeType(song->utf8url);
if(decodeType < 0) {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
pc->erroredFile[MAXPATHLEN] = '\0';
@@ -212,12 +212,15 @@ int playerPlay(FILE * fp, char * utf8file) {
return 0;
}
pc->decodeType = decodeType;
- pc->fileSuffix = playerGetSuffix(utf8file);
+ pc->fileSuffix = playerGetSuffix(song->utf8url);
+ if(song->tag) pc->fileTime = song->tag->time;
+ else pc->fileTime = 0;
- if(isRemoteUrl(utf8file)) {
- strncpy(pc->file,utf8file,MAXPATHLEN);
+ if(isRemoteUrl(song->utf8url)) {
+ strncpy(pc->file, song->utf8url, MAXPATHLEN);
}
- else strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
+ else strncpy(pc->file, rmp2amp(utf8ToFsCharset(song->utf8url)),
+ MAXPATHLEN);
pc->file[MAXPATHLEN] = '\0';
pc->play = 1;
@@ -247,9 +250,9 @@ int playerStop(FILE * fp) {
void playerKill() {
int pid;
- PlayerControl * pc = &(getPlayerData()->playerControl);
+ /*PlayerControl * pc = &(getPlayerData()->playerControl);
- /*playerStop(stderr);
+ playerStop(stderr);
playerCloseAudio(stderr);
if(player_pid>0 && pc->closeAudio) sleep(1);*/
@@ -357,21 +360,24 @@ void playerCloseAudio() {
}
}
-int queueSong(char * utf8file) {
+int queueSong(Song * song) {
PlayerControl * pc = &(getPlayerData()->playerControl);
int decodeType;
if(pc->queueState==PLAYER_QUEUE_BLANK) {
- if(isRemoteUrl(utf8file)) {
- strncpy(pc->file,utf8file,MAXPATHLEN);
+ if(isRemoteUrl(song->utf8url)) {
+ strncpy(pc->file, song->utf8url, MAXPATHLEN);
}
- else strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
+ else strncpy(pc->file, rmp2amp(utf8ToFsCharset(song->utf8url)),
+ MAXPATHLEN);
pc->file[MAXPATHLEN] = '\0';
- decodeType = playerGetDecodeType(utf8file);
+ decodeType = playerGetDecodeType(song->utf8url);
if(decodeType < 0) return -1;
pc->decodeType = decodeType;
- pc->fileSuffix = playerGetSuffix(utf8file);
+ pc->fileSuffix = playerGetSuffix(song->utf8url);
+ if(song->tag) pc->fileTime = song->tag->time;
+ else pc->fileTime = 0;
pc->queueState = PLAYER_QUEUE_FULL;
return 0;
@@ -412,7 +418,7 @@ void playerQueueUnlock() {
}
}
-int playerSeek(FILE * fp, char * utf8file, float time) {
+int playerSeek(FILE * fp, Song * song, float time) {
PlayerControl * pc = &(getPlayerData()->playerControl);
char * file;
int decodeType;
@@ -423,18 +429,21 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
return -1;
}
- if(isRemoteUrl(utf8file)) file = utf8file;
- else file = rmp2amp(utf8ToFsCharset(utf8file));
+ if(isRemoteUrl(song->utf8url)) file = song->utf8url;
+ else file = rmp2amp(utf8ToFsCharset(song->utf8url));
if(strcmp(pc->file,file)!=0) {
- decodeType = playerGetDecodeType(utf8file);
+ decodeType = playerGetDecodeType(song->utf8url);
if(decodeType < 0) {
myfprintf(fp,"%s unknown file type: %s\n",
- COMMAND_RESPOND_ERROR, utf8file);
- ERROR("playerSeek: unknown file type: %s\n", utf8file);
+ COMMAND_RESPOND_ERROR, song->utf8url);
+ ERROR("playerSeek: unknown file type: %s\n",
+ song->utf8url);
return -1;
}
pc->decodeType = decodeType;
- pc->fileSuffix = playerGetSuffix(utf8file);
+ pc->fileSuffix = playerGetSuffix(song->utf8url);
+ if(song->tag) pc->fileTime = song->tag->time;
+ else pc->fileTime = 0;
strncpy(pc->file,file,MAXPATHLEN);
pc->file[MAXPATHLEN] = '\0';
diff --git a/src/player.h b/src/player.h
index a47b2c356..a0b5515c1 100644
--- a/src/player.h
+++ b/src/player.h
@@ -22,6 +22,7 @@
#include "../config.h"
#include "mpd_types.h"
+#include "song.h"
#include <stdio.h>
#include <sys/param.h>
@@ -66,6 +67,7 @@ typedef struct _PlayerControl {
volatile float beginTime;
volatile float totalTime;
volatile float elapsedTime;
+ volatile float fileTime;
char file[MAXPATHLEN+1];
char erroredFile[MAXPATHLEN+1];
volatile mpd_sint8 queueState;
@@ -85,7 +87,7 @@ void clearPlayerPid();
void player_sigChldHandler(int pid, int status);
-int playerPlay(FILE * fp, char * utf8file);
+int playerPlay(FILE * fp, Song * song);
int playerSetPause(FILE * fp, int pause);
@@ -115,7 +117,7 @@ int getPlayerError();
int playerInit();
-int queueSong(char * utf8file);
+int queueSong(Song * song);
int getPlayerQueueState();
@@ -125,7 +127,7 @@ void playerQueueLock();
void playerQueueUnlock();
-int playerSeek(FILE * fp, char * utf8file, float time);
+int playerSeek(FILE * fp, Song * song, float time);
void setPlayerCrossFade(float crossFadeInSeconds);
diff --git a/src/playlist.c b/src/playlist.c
index a705b3160..ce7ac77df 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -386,8 +386,9 @@ void queueNextSongInPlaylist() {
playlist.queued,
playlist.songs[playlist.order[
playlist.queued]]->utf8url);
- if(queueSong(playlist.songs[playlist.order[
- playlist.queued]]->utf8url)<0) {
+ if(queueSong(playlist.songs[playlist.order[playlist.queued]]) <
+ 0)
+ {
playlist.queued = -1;
playlist_queueError = 1;
}
@@ -401,8 +402,9 @@ void queueNextSongInPlaylist() {
playlist.queued,
playlist.songs[playlist.order[
playlist.queued]]->utf8url);
- if(queueSong(playlist.songs[playlist.order[
- playlist.queued]]->utf8url)<0) {
+ if(queueSong(playlist.songs[playlist.order[playlist.queued]]) <
+ 0)
+ {
playlist.queued = -1;
playlist_queueError = 1;
}
@@ -660,9 +662,7 @@ int playPlaylistOrderNumber(FILE * fp, int orderNum) {
DEBUG("playlist: play %i:\"%s\"\n",orderNum,
(playlist.songs[playlist.order[orderNum]])->utf8url);
- if(playerPlay(fp,(playlist.songs[playlist.order[orderNum]])->
- utf8url)<0)
- {
+ if(playerPlay(fp,(playlist.songs[playlist.order[orderNum]])) < 0) {
stopPlaylist(fp);
return -1;
}
@@ -1220,6 +1220,6 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
if(playPlaylistOrderNumber(fp,i)<0) return -1;
}
- return playerSeek(fp,playlist.songs[playlist.order[i]]->utf8url,time);
+ return playerSeek(fp, playlist.songs[playlist.order[i]], time);
}
/* vim:set shiftwidth=4 tabstop=8 expandtab: */