just a we bit of changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@1075 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
3cb9923714
commit
bf9e2afbf9
51
src/player.c
51
src/player.c
@ -186,7 +186,7 @@ int playerGetSuffix(char * utf8file) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerPlay(FILE * fp, char * utf8file) {
|
int playerPlay(FILE * fp, Song * song) {
|
||||||
PlayerControl * pc = &(getPlayerData()->playerControl);
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||||
int decodeType;
|
int decodeType;
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ int playerPlay(FILE * fp, char * utf8file) {
|
|||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
decodeType = playerGetDecodeType(utf8file);
|
decodeType = playerGetDecodeType(song->utf8url);
|
||||||
if(decodeType < 0) {
|
if(decodeType < 0) {
|
||||||
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
|
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
|
||||||
pc->erroredFile[MAXPATHLEN] = '\0';
|
pc->erroredFile[MAXPATHLEN] = '\0';
|
||||||
@ -212,12 +212,15 @@ int playerPlay(FILE * fp, char * utf8file) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pc->decodeType = decodeType;
|
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)) {
|
if(isRemoteUrl(song->utf8url)) {
|
||||||
strncpy(pc->file,utf8file,MAXPATHLEN);
|
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->file[MAXPATHLEN] = '\0';
|
||||||
|
|
||||||
pc->play = 1;
|
pc->play = 1;
|
||||||
@ -247,9 +250,9 @@ int playerStop(FILE * fp) {
|
|||||||
|
|
||||||
void playerKill() {
|
void playerKill() {
|
||||||
int pid;
|
int pid;
|
||||||
PlayerControl * pc = &(getPlayerData()->playerControl);
|
/*PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||||
|
|
||||||
/*playerStop(stderr);
|
playerStop(stderr);
|
||||||
playerCloseAudio(stderr);
|
playerCloseAudio(stderr);
|
||||||
if(player_pid>0 && pc->closeAudio) sleep(1);*/
|
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);
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||||
int decodeType;
|
int decodeType;
|
||||||
|
|
||||||
if(pc->queueState==PLAYER_QUEUE_BLANK) {
|
if(pc->queueState==PLAYER_QUEUE_BLANK) {
|
||||||
if(isRemoteUrl(utf8file)) {
|
if(isRemoteUrl(song->utf8url)) {
|
||||||
strncpy(pc->file,utf8file,MAXPATHLEN);
|
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->file[MAXPATHLEN] = '\0';
|
||||||
|
|
||||||
decodeType = playerGetDecodeType(utf8file);
|
decodeType = playerGetDecodeType(song->utf8url);
|
||||||
if(decodeType < 0) return -1;
|
if(decodeType < 0) return -1;
|
||||||
pc->decodeType = decodeType;
|
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;
|
pc->queueState = PLAYER_QUEUE_FULL;
|
||||||
return 0;
|
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);
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||||
char * file;
|
char * file;
|
||||||
int decodeType;
|
int decodeType;
|
||||||
@ -423,18 +429,21 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isRemoteUrl(utf8file)) file = utf8file;
|
if(isRemoteUrl(song->utf8url)) file = song->utf8url;
|
||||||
else file = rmp2amp(utf8ToFsCharset(utf8file));
|
else file = rmp2amp(utf8ToFsCharset(song->utf8url));
|
||||||
if(strcmp(pc->file,file)!=0) {
|
if(strcmp(pc->file,file)!=0) {
|
||||||
decodeType = playerGetDecodeType(utf8file);
|
decodeType = playerGetDecodeType(song->utf8url);
|
||||||
if(decodeType < 0) {
|
if(decodeType < 0) {
|
||||||
myfprintf(fp,"%s unknown file type: %s\n",
|
myfprintf(fp,"%s unknown file type: %s\n",
|
||||||
COMMAND_RESPOND_ERROR, utf8file);
|
COMMAND_RESPOND_ERROR, song->utf8url);
|
||||||
ERROR("playerSeek: unknown file type: %s\n", utf8file);
|
ERROR("playerSeek: unknown file type: %s\n",
|
||||||
|
song->utf8url);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pc->decodeType = decodeType;
|
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);
|
strncpy(pc->file,file,MAXPATHLEN);
|
||||||
pc->file[MAXPATHLEN] = '\0';
|
pc->file[MAXPATHLEN] = '\0';
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
#include "mpd_types.h"
|
#include "mpd_types.h"
|
||||||
|
#include "song.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -66,6 +67,7 @@ typedef struct _PlayerControl {
|
|||||||
volatile float beginTime;
|
volatile float beginTime;
|
||||||
volatile float totalTime;
|
volatile float totalTime;
|
||||||
volatile float elapsedTime;
|
volatile float elapsedTime;
|
||||||
|
volatile float fileTime;
|
||||||
char file[MAXPATHLEN+1];
|
char file[MAXPATHLEN+1];
|
||||||
char erroredFile[MAXPATHLEN+1];
|
char erroredFile[MAXPATHLEN+1];
|
||||||
volatile mpd_sint8 queueState;
|
volatile mpd_sint8 queueState;
|
||||||
@ -85,7 +87,7 @@ void clearPlayerPid();
|
|||||||
|
|
||||||
void player_sigChldHandler(int pid, int status);
|
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);
|
int playerSetPause(FILE * fp, int pause);
|
||||||
|
|
||||||
@ -115,7 +117,7 @@ int getPlayerError();
|
|||||||
|
|
||||||
int playerInit();
|
int playerInit();
|
||||||
|
|
||||||
int queueSong(char * utf8file);
|
int queueSong(Song * song);
|
||||||
|
|
||||||
int getPlayerQueueState();
|
int getPlayerQueueState();
|
||||||
|
|
||||||
@ -125,7 +127,7 @@ void playerQueueLock();
|
|||||||
|
|
||||||
void playerQueueUnlock();
|
void playerQueueUnlock();
|
||||||
|
|
||||||
int playerSeek(FILE * fp, char * utf8file, float time);
|
int playerSeek(FILE * fp, Song * song, float time);
|
||||||
|
|
||||||
void setPlayerCrossFade(float crossFadeInSeconds);
|
void setPlayerCrossFade(float crossFadeInSeconds);
|
||||||
|
|
||||||
|
@ -386,8 +386,9 @@ void queueNextSongInPlaylist() {
|
|||||||
playlist.queued,
|
playlist.queued,
|
||||||
playlist.songs[playlist.order[
|
playlist.songs[playlist.order[
|
||||||
playlist.queued]]->utf8url);
|
playlist.queued]]->utf8url);
|
||||||
if(queueSong(playlist.songs[playlist.order[
|
if(queueSong(playlist.songs[playlist.order[playlist.queued]]) <
|
||||||
playlist.queued]]->utf8url)<0) {
|
0)
|
||||||
|
{
|
||||||
playlist.queued = -1;
|
playlist.queued = -1;
|
||||||
playlist_queueError = 1;
|
playlist_queueError = 1;
|
||||||
}
|
}
|
||||||
@ -401,8 +402,9 @@ void queueNextSongInPlaylist() {
|
|||||||
playlist.queued,
|
playlist.queued,
|
||||||
playlist.songs[playlist.order[
|
playlist.songs[playlist.order[
|
||||||
playlist.queued]]->utf8url);
|
playlist.queued]]->utf8url);
|
||||||
if(queueSong(playlist.songs[playlist.order[
|
if(queueSong(playlist.songs[playlist.order[playlist.queued]]) <
|
||||||
playlist.queued]]->utf8url)<0) {
|
0)
|
||||||
|
{
|
||||||
playlist.queued = -1;
|
playlist.queued = -1;
|
||||||
playlist_queueError = 1;
|
playlist_queueError = 1;
|
||||||
}
|
}
|
||||||
@ -660,9 +662,7 @@ int playPlaylistOrderNumber(FILE * fp, int orderNum) {
|
|||||||
DEBUG("playlist: play %i:\"%s\"\n",orderNum,
|
DEBUG("playlist: play %i:\"%s\"\n",orderNum,
|
||||||
(playlist.songs[playlist.order[orderNum]])->utf8url);
|
(playlist.songs[playlist.order[orderNum]])->utf8url);
|
||||||
|
|
||||||
if(playerPlay(fp,(playlist.songs[playlist.order[orderNum]])->
|
if(playerPlay(fp,(playlist.songs[playlist.order[orderNum]])) < 0) {
|
||||||
utf8url)<0)
|
|
||||||
{
|
|
||||||
stopPlaylist(fp);
|
stopPlaylist(fp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1220,6 +1220,6 @@ int seekSongInPlaylist(FILE * fp, int song, float time) {
|
|||||||
if(playPlaylistOrderNumber(fp,i)<0) return -1;
|
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: */
|
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
|
||||||
|
Loading…
Reference in New Issue
Block a user