2004-02-24 00:41:20 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
2006-07-14 21:37:45 +02:00
|
|
|
* (c)2003-2006 by Warren Dukes (warren.dukes@gmail.com)
|
2004-02-24 00:41:20 +01:00
|
|
|
* This project's homepage is: http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "player.h"
|
|
|
|
#include "decode.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "interface.h"
|
|
|
|
#include "playlist.h"
|
|
|
|
#include "ls.h"
|
|
|
|
#include "listen.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "directory.h"
|
|
|
|
#include "volume.h"
|
|
|
|
#include "playerData.h"
|
|
|
|
#include "permission.h"
|
2004-04-11 20:27:12 +02:00
|
|
|
#include "sig_handlers.h"
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
extern int masterPid;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-06-01 01:29:35 +02:00
|
|
|
static void resetPlayerMetadata() {
|
2006-07-14 22:34:46 +02:00
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
2004-06-01 01:29:35 +02:00
|
|
|
|
2006-07-14 22:34:46 +02:00
|
|
|
if(pc->metadataState == PLAYER_METADATA_STATE_READ) {
|
|
|
|
pc->metadataState = PLAYER_METADATA_STATE_WRITE;
|
|
|
|
}
|
2004-06-01 01:29:35 +02:00
|
|
|
}
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
void resetPlayer() {
|
2004-02-27 23:25:06 +01:00
|
|
|
int pid;
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
setPlayerPid(0);
|
2004-02-24 00:41:20 +01:00
|
|
|
getPlayerData()->playerControl.stop = 0;
|
|
|
|
getPlayerData()->playerControl.play = 0;
|
|
|
|
getPlayerData()->playerControl.pause = 0;
|
|
|
|
getPlayerData()->playerControl.lockQueue = 0;
|
|
|
|
getPlayerData()->playerControl.unlockQueue = 0;
|
|
|
|
getPlayerData()->playerControl.state = PLAYER_STATE_STOP;
|
|
|
|
getPlayerData()->playerControl.queueState = PLAYER_QUEUE_UNLOCKED;
|
|
|
|
getPlayerData()->playerControl.seek = 0;
|
2006-07-14 22:34:46 +02:00
|
|
|
getPlayerData()->playerControl.metadataState =
|
|
|
|
PLAYER_METADATA_STATE_WRITE;
|
2004-02-27 23:25:06 +01:00
|
|
|
pid = getPlayerData()->playerControl.decode_pid;
|
|
|
|
if(pid>0) kill(pid,SIGTERM);
|
|
|
|
getPlayerData()->playerControl.decode_pid = 0;
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2004-04-11 03:53:25 +02:00
|
|
|
void player_sigChldHandler(int pid, int status) {
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()==pid) {
|
2004-04-12 01:07:43 +02:00
|
|
|
DEBUG("SIGCHLD caused by player process\n");
|
|
|
|
if(WIFSIGNALED(status) && WTERMSIG(status)!=SIGTERM &&
|
|
|
|
WTERMSIG(status)!=SIGINT)
|
|
|
|
{
|
|
|
|
ERROR("player process died from signal: %i\n",
|
2004-04-11 03:53:25 +02:00
|
|
|
WTERMSIG(status));
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
2004-04-11 03:53:25 +02:00
|
|
|
resetPlayer();
|
|
|
|
}
|
2005-11-16 15:43:04 +01:00
|
|
|
else if(pid==getPlayerData()->playerControl.decode_pid && getPlayerPid()<=0)
|
2004-04-11 03:53:25 +02:00
|
|
|
{
|
|
|
|
if(WIFSIGNALED(status) && WTERMSIG(status)!=SIGTERM) {
|
|
|
|
ERROR("(caught by master parent) "
|
|
|
|
"decode process died from a "
|
|
|
|
"non-TERM signal: %i\n",
|
|
|
|
WTERMSIG(status));
|
2004-02-27 23:25:06 +01:00
|
|
|
}
|
2004-04-11 03:53:25 +02:00
|
|
|
getPlayerData()->playerControl.decode_pid = 0;
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int playerInit() {
|
2005-11-16 15:43:04 +01:00
|
|
|
kill(masterPid, SIGUSR2);
|
2005-11-19 11:52:47 +01:00
|
|
|
/* we need to wait for the signal to take effect: */
|
|
|
|
while (getPlayerPid()==0) my_usleep(10000);
|
2005-11-16 15:43:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-07-14 22:40:25 +02:00
|
|
|
int playerInitReal() {
|
2005-11-16 15:43:04 +01:00
|
|
|
int player_pid;
|
2004-04-11 20:27:12 +02:00
|
|
|
blockSignals();
|
2004-02-24 00:41:20 +01:00
|
|
|
player_pid = fork();
|
|
|
|
if(player_pid==0) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
2004-04-11 20:27:12 +02:00
|
|
|
|
|
|
|
unblockSignals();
|
|
|
|
|
2004-11-03 15:29:37 +01:00
|
|
|
setSigHandlersForDecoder();
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
while(1) {
|
|
|
|
if(pc->play) decode();
|
|
|
|
else if(pc->stop) pc->stop = 0;
|
|
|
|
else if(pc->pause) pc->pause = 0;
|
|
|
|
else if(pc->closeAudio) {
|
2004-05-10 04:20:15 +02:00
|
|
|
closeAudioDevice();
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->closeAudio = 0;
|
|
|
|
kill(getppid(),SIGUSR1);
|
|
|
|
}
|
|
|
|
else if(pc->lockQueue) {
|
|
|
|
pc->queueLockState = PLAYER_QUEUE_LOCKED;
|
|
|
|
pc->lockQueue = 0;
|
|
|
|
}
|
|
|
|
else if(pc->unlockQueue) {
|
|
|
|
pc->queueLockState = PLAYER_QUEUE_UNLOCKED;
|
|
|
|
pc->unlockQueue = 0;
|
|
|
|
}
|
2006-07-14 22:34:46 +02:00
|
|
|
else if(pc->cycleLogFiles) {
|
|
|
|
myfprintfCloseAndOpenLogFile();
|
|
|
|
pc->cycleLogFiles = 0;
|
|
|
|
}
|
2004-04-01 05:48:51 +02:00
|
|
|
else my_usleep(10000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2004-04-03 01:34:16 +02:00
|
|
|
exit(EXIT_SUCCESS);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
else if(player_pid<0) {
|
2004-04-11 20:27:12 +02:00
|
|
|
unblockSignals();
|
2004-02-24 00:41:20 +01:00
|
|
|
ERROR("player Problems fork()'ing\n");
|
2005-11-16 15:43:04 +01:00
|
|
|
setPlayerPid(0);
|
2004-02-24 00:41:20 +01:00
|
|
|
player_pid = 0;
|
|
|
|
return -1;
|
|
|
|
}
|
2005-11-16 15:43:04 +01:00
|
|
|
else
|
|
|
|
setPlayerPid(player_pid);
|
|
|
|
|
2004-04-11 20:27:12 +02:00
|
|
|
unblockSignals();
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-05-19 02:34:26 +02:00
|
|
|
int playerPlay(FILE * fp, Song * song) {
|
2004-02-24 00:41:20 +01:00
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2004-03-23 04:02:49 +01:00
|
|
|
if(fp==NULL) fp = stderr;
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
if(playerStop(fp)<0) return -1;
|
|
|
|
|
2006-07-14 22:34:46 +02:00
|
|
|
if(song->tag) pc->fileTime = song->tag->time;
|
|
|
|
else pc->fileTime = 0;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-10-25 22:09:03 +02:00
|
|
|
copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk));
|
|
|
|
|
2006-07-14 22:34:46 +02:00
|
|
|
strncpy(pc->utf8url, getSongUrl(song), MAXPATHLEN);
|
2004-05-31 13:42:46 +02:00
|
|
|
pc->utf8url[MAXPATHLEN] = '\0';
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
pc->play = 1;
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()==0 && playerInit()<0) {
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->play = 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-06-01 01:29:35 +02:00
|
|
|
resetPlayerMetadata();
|
2005-11-16 15:43:04 +01:00
|
|
|
while(getPlayerPid()>0 && pc->play) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int playerStop(FILE * fp) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()>0 && pc->state!=PLAYER_STATE_STOP) {
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->stop = 1;
|
2005-11-16 15:43:04 +01:00
|
|
|
while(getPlayerPid()>0 && pc->stop) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pc->queueState = PLAYER_QUEUE_BLANK;
|
|
|
|
playerQueueUnlock();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void playerKill() {
|
|
|
|
int pid;
|
2004-05-19 02:34:26 +02:00
|
|
|
/*PlayerControl * pc = &(getPlayerData()->playerControl);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-05-19 02:34:26 +02:00
|
|
|
playerStop(stderr);
|
2004-02-24 00:41:20 +01:00
|
|
|
playerCloseAudio(stderr);
|
2004-05-18 21:32:05 +02:00
|
|
|
if(player_pid>0 && pc->closeAudio) sleep(1);*/
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
pid = getPlayerPid();
|
2004-02-24 00:41:20 +01:00
|
|
|
if(pid>0) kill(pid,SIGTERM);
|
|
|
|
}
|
|
|
|
|
|
|
|
int playerPause(FILE * fp) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()>0 && pc->state!=PLAYER_STATE_STOP) {
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->pause = 1;
|
2005-11-16 15:43:04 +01:00
|
|
|
while(getPlayerPid()>0 && pc->pause) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
2004-02-25 01:08:48 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int playerSetPause(FILE * fp, int pause) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()<=0) return 0;
|
2004-02-25 01:08:48 +01:00
|
|
|
|
|
|
|
switch(pc->state) {
|
|
|
|
case PLAYER_STATE_PLAY:
|
|
|
|
if(pause) playerPause(fp);
|
|
|
|
break;
|
|
|
|
case PLAYER_STATE_PAUSE:
|
|
|
|
if(!pause) playerPause(fp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerElapsedTime() {
|
|
|
|
return (int)(getPlayerData()->playerControl.elapsedTime+0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long getPlayerBitRate() {
|
|
|
|
return getPlayerData()->playerControl.bitRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerTotalTime() {
|
|
|
|
return (int)(getPlayerData()->playerControl.totalTime+0.5);
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerState() {
|
|
|
|
return getPlayerData()->playerControl.state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clearPlayerError() {
|
|
|
|
getPlayerData()->playerControl.error = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerError() {
|
|
|
|
return getPlayerData()->playerControl.error;
|
|
|
|
}
|
|
|
|
|
|
|
|
char * getPlayerErrorStr() {
|
2004-04-16 17:01:06 +02:00
|
|
|
static char * error = NULL;
|
|
|
|
int errorlen = MAXPATHLEN+1024;
|
2004-02-24 00:41:20 +01:00
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2004-04-16 17:01:06 +02:00
|
|
|
error = realloc(error,errorlen+1);
|
|
|
|
memset(error,0,errorlen+1);
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
switch(pc->error) {
|
|
|
|
case PLAYER_ERROR_FILENOTFOUND:
|
2004-04-16 17:01:06 +02:00
|
|
|
snprintf(error,errorlen,
|
|
|
|
"file \"%s\" does not exist or is inaccesible",
|
2004-05-31 13:42:46 +02:00
|
|
|
pc->erroredUrl);
|
2004-04-16 17:01:06 +02:00
|
|
|
break;
|
2004-02-24 00:41:20 +01:00
|
|
|
case PLAYER_ERROR_FILE:
|
2004-04-16 17:01:06 +02:00
|
|
|
snprintf(error,errorlen,"problems decoding \"%s\"",
|
2004-05-31 13:42:46 +02:00
|
|
|
pc->erroredUrl);
|
2004-04-16 17:01:06 +02:00
|
|
|
break;
|
2004-02-24 00:41:20 +01:00
|
|
|
case PLAYER_ERROR_AUDIO:
|
2004-04-16 17:01:06 +02:00
|
|
|
snprintf(error,errorlen,"problems opening audio device");
|
|
|
|
break;
|
2004-02-24 00:41:20 +01:00
|
|
|
case PLAYER_ERROR_SYSTEM:
|
2004-04-16 17:01:06 +02:00
|
|
|
snprintf(error,errorlen,"system error occured");
|
|
|
|
break;
|
2004-02-24 00:41:20 +01:00
|
|
|
case PLAYER_ERROR_UNKTYPE:
|
2004-04-16 17:01:06 +02:00
|
|
|
snprintf(error,errorlen,"file type of \"%s\" is unknown",
|
2004-05-31 13:42:46 +02:00
|
|
|
pc->erroredUrl);
|
2004-02-24 00:41:20 +01:00
|
|
|
default:
|
2004-04-16 17:01:06 +02:00
|
|
|
break;
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
2004-04-16 17:01:06 +02:00
|
|
|
|
|
|
|
errorlen = strlen(error);
|
|
|
|
error = realloc(error,errorlen+1);
|
|
|
|
|
|
|
|
if(errorlen) return error;
|
|
|
|
|
|
|
|
return NULL;
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void playerCloseAudio() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()>0) {
|
2004-02-24 00:41:20 +01:00
|
|
|
if(playerStop(stderr)<0) return;
|
|
|
|
pc->closeAudio = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-19 02:34:26 +02:00
|
|
|
int queueSong(Song * song) {
|
2004-02-24 00:41:20 +01:00
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
if(pc->queueState==PLAYER_QUEUE_BLANK) {
|
2004-11-11 03:36:25 +01:00
|
|
|
strncpy(pc->utf8url, getSongUrl(song), MAXPATHLEN);
|
2004-05-31 13:42:46 +02:00
|
|
|
pc->utf8url[MAXPATHLEN] = '\0';
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2006-07-14 22:34:46 +02:00
|
|
|
if(song->tag) pc->fileTime = song->tag->time;
|
|
|
|
else pc->fileTime = 0;
|
2004-03-23 02:12:30 +01:00
|
|
|
|
2004-10-25 22:09:03 +02:00
|
|
|
copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk));
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->queueState = PLAYER_QUEUE_FULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerQueueState() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
return pc->queueState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setQueueState(int queueState) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
pc->queueState = queueState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void playerQueueLock() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()>0 && pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
|
2004-02-24 00:41:20 +01:00
|
|
|
{
|
|
|
|
pc->lockQueue = 1;
|
2005-11-16 15:43:04 +01:00
|
|
|
while(getPlayerPid()>0 && pc->lockQueue) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void playerQueueUnlock() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2005-11-16 15:43:04 +01:00
|
|
|
if(getPlayerPid()>0 && pc->queueLockState==PLAYER_QUEUE_LOCKED)
|
2004-02-24 00:41:20 +01:00
|
|
|
{
|
|
|
|
pc->unlockQueue = 1;
|
2005-11-16 15:43:04 +01:00
|
|
|
while(getPlayerPid()>0 && pc->unlockQueue) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-19 02:34:26 +02:00
|
|
|
int playerSeek(FILE * fp, Song * song, float time) {
|
2004-02-24 00:41:20 +01:00
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
if(pc->state==PLAYER_STATE_STOP) {
|
2004-06-04 04:51:54 +02:00
|
|
|
commandError(fp, ACK_ERROR_PLAYER_SYNC,
|
2004-06-15 20:06:21 +02:00
|
|
|
"player not currently playing", NULL);
|
2004-02-24 00:41:20 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-11-11 03:36:25 +01:00
|
|
|
if(strcmp(pc->utf8url, getSongUrl(song))!=0) {
|
2004-05-19 02:34:26 +02:00
|
|
|
if(song->tag) pc->fileTime = song->tag->time;
|
|
|
|
else pc->fileTime = 0;
|
2004-03-23 02:12:30 +01:00
|
|
|
|
2004-10-25 22:09:03 +02:00
|
|
|
copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk));
|
|
|
|
|
2004-11-11 03:36:25 +01:00
|
|
|
strncpy(pc->utf8url, getSongUrl(song), MAXPATHLEN);
|
2004-05-31 13:42:46 +02:00
|
|
|
pc->utf8url[MAXPATHLEN] = '\0';
|
2004-03-23 02:12:30 +01:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
if(pc->error==PLAYER_ERROR_NOERROR) {
|
2004-06-01 01:29:35 +02:00
|
|
|
resetPlayerMetadata();
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->seekWhere = time;
|
|
|
|
pc->seek = 1;
|
2005-11-16 15:43:04 +01:00
|
|
|
while(getPlayerPid()>0 && pc->seek) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
float getPlayerCrossFade() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
return pc->crossFade;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPlayerCrossFade(float crossFadeInSeconds) {
|
2004-03-03 01:01:43 +01:00
|
|
|
PlayerControl * pc;
|
2004-02-24 00:41:20 +01:00
|
|
|
if(crossFadeInSeconds<0) crossFadeInSeconds = 0;
|
|
|
|
|
2004-03-03 01:01:43 +01:00
|
|
|
pc = &(getPlayerData()->playerControl);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
pc->crossFade = crossFadeInSeconds;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setPlayerSoftwareVolume(int volume) {
|
2004-03-03 01:01:43 +01:00
|
|
|
PlayerControl * pc;
|
2004-04-11 13:48:04 +02:00
|
|
|
volume = (volume>1000) ? 1000 : (volume<0 ? 0 : volume);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-03-03 01:01:43 +01:00
|
|
|
pc = &(getPlayerData()->playerControl);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
pc->softwareVolume = volume;
|
|
|
|
}
|
|
|
|
|
|
|
|
double getPlayerTotalPlayTime() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
2004-06-03 14:34:25 +02:00
|
|
|
return pc->totalPlayTime;
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
2004-02-27 02:35:23 +01:00
|
|
|
|
|
|
|
unsigned int getPlayerSampleRate() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
return pc->sampleRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerBits() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
return pc->bits;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerChannels() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
return pc->channels;
|
|
|
|
}
|
2004-04-15 07:07:04 +02:00
|
|
|
|
|
|
|
void playerCycleLogFiles() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
DecoderControl * dc = &(getPlayerData()->decoderControl);
|
|
|
|
|
|
|
|
pc->cycleLogFiles = 1;
|
|
|
|
dc->cycleLogFiles = 1;
|
|
|
|
}
|
|
|
|
|
2004-05-31 13:42:46 +02:00
|
|
|
/* this actually creates a dupe of the current metadata */
|
|
|
|
Song * playerCurrentDecodeSong() {
|
2006-07-14 22:34:46 +02:00
|
|
|
static Song * song = NULL;
|
|
|
|
static MetadataChunk * prev = NULL;
|
2004-06-07 16:16:10 +02:00
|
|
|
Song * ret = NULL;
|
2004-06-01 01:29:35 +02:00
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
2004-05-31 13:42:46 +02:00
|
|
|
|
2004-06-09 18:58:33 +02:00
|
|
|
if(pc->metadataState == PLAYER_METADATA_STATE_READ) {
|
|
|
|
DEBUG("playerCurrentDecodeSong: caught new metadata!\n");
|
2006-07-14 22:34:46 +02:00
|
|
|
if(prev) free(prev);
|
|
|
|
prev = malloc(sizeof(MetadataChunk));
|
2004-06-06 22:34:00 +02:00
|
|
|
memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk));
|
2004-05-31 16:30:54 +02:00
|
|
|
if(song) freeJustSong(song);
|
2006-07-14 22:34:46 +02:00
|
|
|
song = newNullSong();
|
|
|
|
song->url = strdup(pc->currentUrl);
|
2004-06-06 22:34:00 +02:00
|
|
|
song->tag = metadataChunkToMpdTagDup(prev);
|
2006-07-14 22:34:46 +02:00
|
|
|
ret = song;
|
|
|
|
resetPlayerMetadata();
|
|
|
|
}
|
2004-05-31 13:42:46 +02:00
|
|
|
|
2006-07-14 22:34:46 +02:00
|
|
|
return ret;
|
2004-05-31 13:42:46 +02:00
|
|
|
}
|