2004-02-24 00:41:20 +01:00
|
|
|
/* the Music Player Daemon (MPD)
|
|
|
|
* (c)2003-2004 by Warren Dukes (shank@mercury.chem.pitt.edu)
|
|
|
|
* 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 "path.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "tables.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>
|
|
|
|
|
2004-04-12 20:51:16 +02:00
|
|
|
volatile int player_pid = 0;
|
2004-04-13 18:46:11 +02:00
|
|
|
|
|
|
|
void clearPlayerPid() {
|
|
|
|
player_pid = 0;
|
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
void resetPlayer() {
|
2004-02-27 23:25:06 +01:00
|
|
|
int pid;
|
|
|
|
|
2004-04-13 18:46:11 +02:00
|
|
|
clearPlayerPid();
|
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;
|
2004-02-27 23:25:06 +01:00
|
|
|
/* kill decode process if it got left running */
|
|
|
|
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) {
|
|
|
|
if(player_pid==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();
|
|
|
|
}
|
|
|
|
else if(pid==getPlayerData()->playerControl.decode_pid && player_pid<=0)
|
|
|
|
{
|
|
|
|
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() {
|
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);
|
|
|
|
struct sigaction sa;
|
2004-04-11 20:27:12 +02:00
|
|
|
|
2004-04-13 18:46:11 +02:00
|
|
|
clearUpdatePid();
|
|
|
|
|
2004-04-11 20:27:12 +02:00
|
|
|
unblockSignals();
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
sa.sa_flags = 0;
|
|
|
|
sigemptyset(&sa.sa_mask);
|
|
|
|
|
2004-04-12 01:07:43 +02:00
|
|
|
finishSigHandlers();
|
2004-02-24 00:41:20 +01:00
|
|
|
sa.sa_handler = decodeSigHandler;
|
2004-04-13 18:46:11 +02:00
|
|
|
while(sigaction(SIGCHLD,&sa,NULL)<0 && errno==EINTR);
|
|
|
|
while(sigaction(SIGTERM,&sa,NULL)<0 && errno==EINTR);
|
|
|
|
while(sigaction(SIGINT,&sa,NULL)<0 && errno==EINTR);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-04-13 18:46:11 +02:00
|
|
|
while(close(listenSocket)<0 && errno==EINTR);
|
2004-02-24 00:41:20 +01:00
|
|
|
freeAllInterfaces();
|
|
|
|
closeMp3Directory();
|
2004-03-11 01:16:49 +01:00
|
|
|
finishPlaylist();
|
2004-02-24 00:41:20 +01:00
|
|
|
closeTables();
|
|
|
|
finishPaths();
|
|
|
|
finishPermissions();
|
|
|
|
finishCommands();
|
|
|
|
finishVolume();
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
if(pc->play) decode();
|
|
|
|
else if(pc->stop) pc->stop = 0;
|
|
|
|
else if(pc->pause) pc->pause = 0;
|
|
|
|
else if(pc->closeAudio) {
|
|
|
|
finishAudio();
|
|
|
|
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;
|
|
|
|
}
|
2004-04-15 07:07:04 +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");
|
|
|
|
player_pid = 0;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2004-04-11 20:27:12 +02:00
|
|
|
unblockSignals();
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-03-23 02:12:30 +01:00
|
|
|
int playerGetDecodeType(char * utf8file) {
|
2004-04-01 00:32:44 +02:00
|
|
|
if(!isFile(utf8file,NULL));
|
2004-03-23 02:12:30 +01:00
|
|
|
#ifdef HAVE_MAD
|
2004-04-01 00:32:44 +02:00
|
|
|
else if(hasMp3Suffix(utf8file)) return DECODE_TYPE_MP3;
|
2004-03-23 02:12:30 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_OGG
|
2004-04-01 00:32:44 +02:00
|
|
|
else if(hasOggSuffix(utf8file)) return DECODE_TYPE_OGG;
|
2004-03-23 02:12:30 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FLAC
|
2004-04-01 00:32:44 +02:00
|
|
|
else if(hasFlacSuffix(utf8file)) return DECODE_TYPE_FLAC;
|
2004-03-23 02:12:30 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_AUDIOFILE
|
2004-04-01 00:32:44 +02:00
|
|
|
else if(hasWaveSuffix(utf8file)) return DECODE_TYPE_AUDIOFILE;
|
2004-03-23 02:12:30 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_FAAD
|
2004-04-01 00:32:44 +02:00
|
|
|
else if(hasAacSuffix(utf8file)) return DECODE_TYPE_AAC;
|
|
|
|
else if(hasMp4Suffix(utf8file)) return DECODE_TYPE_MP4;
|
2004-03-23 02:12:30 +01:00
|
|
|
#endif
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
int playerPlay(FILE * fp, char * utf8file) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
2004-03-23 02:12:30 +01:00
|
|
|
int decodeType;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
if(stat(rmp2amp(utf8ToFsCharset(utf8file)),&st)<0) {
|
2004-02-25 19:46:41 +01:00
|
|
|
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
|
2004-03-27 03:52:59 +01:00
|
|
|
pc->erroredFile[MAXPATHLEN] = '\0';
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->error = PLAYER_ERROR_FILENOTFOUND;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2004-03-23 02:12:30 +01:00
|
|
|
|
|
|
|
decodeType = playerGetDecodeType(utf8file);
|
|
|
|
if(decodeType < 0) {
|
2004-02-25 19:46:41 +01:00
|
|
|
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
|
2004-03-27 03:52:59 +01:00
|
|
|
pc->erroredFile[MAXPATHLEN] = '\0';
|
2004-02-24 00:41:20 +01:00
|
|
|
pc->error = PLAYER_ERROR_UNKTYPE;
|
|
|
|
return 0;
|
|
|
|
}
|
2004-03-23 02:12:30 +01:00
|
|
|
pc->decodeType = decodeType;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-02-25 19:29:39 +01:00
|
|
|
strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
|
2004-03-27 03:52:59 +01:00
|
|
|
pc->file[MAXPATHLEN] = '\0';
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
pc->play = 1;
|
|
|
|
if(player_pid==0 && playerInit()<0) {
|
|
|
|
pc->play = 0;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-04-01 05:48:51 +02:00
|
|
|
while(player_pid>0 && pc->play) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int playerStop(FILE * fp) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
if(player_pid>0 && pc->state!=PLAYER_STATE_STOP) {
|
|
|
|
pc->stop = 1;
|
2004-04-01 05:48:51 +02:00
|
|
|
while(player_pid>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;
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
playerStop(stderr);
|
|
|
|
playerCloseAudio(stderr);
|
|
|
|
if(player_pid>0 && pc->closeAudio) sleep(1);
|
|
|
|
|
|
|
|
pid = player_pid;
|
|
|
|
if(pid>0) kill(pid,SIGTERM);
|
|
|
|
}
|
|
|
|
|
|
|
|
int playerPause(FILE * fp) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
if(player_pid>0 && pc->state!=PLAYER_STATE_STOP) {
|
|
|
|
pc->pause = 1;
|
2004-04-01 05:48:51 +02:00
|
|
|
while(player_pid>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);
|
|
|
|
|
|
|
|
if(player_pid<=0) return 0;
|
|
|
|
|
|
|
|
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() {
|
|
|
|
static char error[2*MAXPATHLEN];
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
switch(pc->error) {
|
|
|
|
case PLAYER_ERROR_FILENOTFOUND:
|
|
|
|
sprintf(error,"file \"%s\" does not exist or is inaccesible",
|
|
|
|
pc->erroredFile);
|
|
|
|
return error;
|
|
|
|
case PLAYER_ERROR_FILE:
|
|
|
|
sprintf(error,"problems decoding \"%s\"",pc->erroredFile);
|
|
|
|
return error;
|
|
|
|
case PLAYER_ERROR_AUDIO:
|
|
|
|
sprintf(error,"problems opening audio device");
|
|
|
|
return error;
|
|
|
|
case PLAYER_ERROR_SYSTEM:
|
|
|
|
sprintf(error,"system error occured");
|
|
|
|
return error;
|
|
|
|
case PLAYER_ERROR_UNKTYPE:
|
|
|
|
sprintf(error,"file type of \"%s\" is unknown",pc->erroredFile);
|
|
|
|
return error;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void playerCloseAudio() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
if(player_pid>0) {
|
|
|
|
if(playerStop(stderr)<0) return;
|
|
|
|
pc->closeAudio = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int queueSong(char * utf8file) {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
2004-03-23 02:12:30 +01:00
|
|
|
int decodeType;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
if(pc->queueState==PLAYER_QUEUE_BLANK) {
|
2004-02-25 19:29:39 +01:00
|
|
|
strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
|
2004-03-27 03:52:59 +01:00
|
|
|
pc->file[MAXPATHLEN] = '\0';
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2004-03-23 02:12:30 +01:00
|
|
|
decodeType = playerGetDecodeType(utf8file);
|
|
|
|
if(decodeType < 0) return -1;
|
|
|
|
pc->decodeType = decodeType;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if(player_pid>0 && pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
|
|
|
|
{
|
|
|
|
pc->lockQueue = 1;
|
2004-04-01 05:48:51 +02:00
|
|
|
while(player_pid>0 && pc->lockQueue) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void playerQueueUnlock() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
if(player_pid>0 && pc->queueLockState==PLAYER_QUEUE_LOCKED)
|
|
|
|
{
|
|
|
|
pc->unlockQueue = 1;
|
2004-04-01 05:48:51 +02:00
|
|
|
while(player_pid>0 && pc->unlockQueue) my_usleep(1000);
|
2004-02-24 00:41:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-02-25 19:29:39 +01:00
|
|
|
int playerSeek(FILE * fp, char * utf8file, float time) {
|
2004-02-24 00:41:20 +01:00
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
2004-02-25 19:29:39 +01:00
|
|
|
char * file;
|
2004-03-23 02:12:30 +01:00
|
|
|
int decodeType;
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
if(pc->state==PLAYER_STATE_STOP) {
|
|
|
|
myfprintf(fp,"%s player not currently playing\n",
|
|
|
|
COMMAND_RESPOND_ERROR);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-02-25 19:29:39 +01:00
|
|
|
file = rmp2amp(utf8ToFsCharset(utf8file));
|
2004-03-23 02:12:30 +01:00
|
|
|
if(strcmp(pc->file,file)!=0) {
|
|
|
|
decodeType = playerGetDecodeType(utf8file);
|
|
|
|
if(decodeType < 0) {
|
2004-04-13 21:08:38 +02:00
|
|
|
myfprintf(fp,"%s unknown file type: %s\n",
|
2004-03-23 02:12:30 +01:00
|
|
|
COMMAND_RESPOND_ERROR, utf8file);
|
2004-04-13 21:27:22 +02:00
|
|
|
ERROR("playerSeek: unknown file type: %s\n", utf8file);
|
2004-03-23 02:12:30 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
pc->decodeType = decodeType;
|
|
|
|
|
|
|
|
strncpy(pc->file,file,MAXPATHLEN);
|
2004-03-27 03:52:59 +01:00
|
|
|
pc->file[MAXPATHLEN] = '\0';
|
2004-03-23 02:12:30 +01:00
|
|
|
}
|
2004-02-24 00:41:20 +01:00
|
|
|
|
|
|
|
if(pc->error==PLAYER_ERROR_NOERROR) {
|
|
|
|
pc->seekWhere = time;
|
|
|
|
pc->seek = 1;
|
2004-04-01 05:48:51 +02:00
|
|
|
while(player_pid>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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getPlayerSoftwareVolume() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
return pc->softwareVolume;
|
|
|
|
}
|
|
|
|
|
|
|
|
double getPlayerTotalPlayTime() {
|
|
|
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
|
|
|
|
|
|
|
if(pc->state==PLAYER_STATE_STOP) {
|
|
|
|
return pc->totalPlayTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
return pc->totalPlayTime+pc->elapsedTime-pc->beginTime;
|
|
|
|
}
|
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-04-14 16:53:41 +02:00
|
|
|
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
|