add xfade and audio to status, remove crossfade no args options

git-svn-id: https://svn.musicpd.org/mpd/trunk@75 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-02-27 01:35:23 +00:00
parent ce1d377d69
commit 9b1c550597
6 changed files with 62 additions and 25 deletions

View File

@ -19,15 +19,17 @@
#ifndef AUDIO_H #ifndef AUDIO_H
#define AUDIO_H #define AUDIO_H
#include "mpd_types.h"
#include <stdio.h> #include <stdio.h>
#include <ao/ao.h> #include <ao/ao.h>
#define AUDIO_AO_DRIVER_DEFAULT "default" #define AUDIO_AO_DRIVER_DEFAULT "default"
typedef struct _AudioFormat { typedef struct _AudioFormat {
int channels; mpd_sint8 channels;
int sampleRate; mpd_uint32 sampleRate;
int bits; mpd_sint8 bits;
} AudioFormat; } AudioFormat;
extern int audio_ao_driver_id; extern int audio_ao_driver_id;

View File

@ -52,6 +52,7 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
{ {
int fs, frame_count; int fs, frame_count;
AFfilehandle af_fp; AFfilehandle af_fp;
int bits;
af_fp = afOpenFile(dc->file,"r", NULL); af_fp = afOpenFile(dc->file,"r", NULL);
if(af_fp == AF_NULL_FILEHANDLE) { if(af_fp == AF_NULL_FILEHANDLE) {
@ -59,8 +60,9 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
return -1; return -1;
} }
afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &af->bits); afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
af->sampleRate = (int)afGetRate(af_fp, AF_DEFAULT_TRACK); af->bits = bits;
af->sampleRate = afGetRate(af_fp, AF_DEFAULT_TRACK);
af->channels = afGetChannels(af_fp,AF_DEFAULT_TRACK); af->channels = afGetChannels(af_fp,AF_DEFAULT_TRACK);
frame_count = afGetFrameCount(af_fp,AF_DEFAULT_TRACK); frame_count = afGetFrameCount(af_fp,AF_DEFAULT_TRACK);

View File

@ -29,6 +29,7 @@
#include "list.h" #include "list.h"
#include "conf.h" #include "conf.h"
#include "permission.h" #include "permission.h"
#include "audio.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -81,6 +82,8 @@
#define COMMAND_STATUS_TIME "time" #define COMMAND_STATUS_TIME "time"
#define COMMAND_STATUS_BITRATE "bitrate" #define COMMAND_STATUS_BITRATE "bitrate"
#define COMMAND_STATUS_ERROR "error" #define COMMAND_STATUS_ERROR "error"
#define COMMAND_STATUS_CROSSFADE "xfade"
#define COMMAND_STATUS_AUDIO "audio"
typedef int (* CommandHandlerFunction)(FILE *, unsigned int *, int, char **); typedef int (* CommandHandlerFunction)(FILE *, unsigned int *, int, char **);
@ -186,6 +189,8 @@ int commandStatus(FILE * fp, unsigned int * permission, int argArrayLength,
myfprintf(fp,"%s: %i\n",COMMAND_STATUS_SONG,getPlaylistCurrentSong()); myfprintf(fp,"%s: %i\n",COMMAND_STATUS_SONG,getPlaylistCurrentSong());
myfprintf(fp,"%s: %i:%i\n",COMMAND_STATUS_TIME,getPlayerElapsedTime(),getPlayerTotalTime()); myfprintf(fp,"%s: %i:%i\n",COMMAND_STATUS_TIME,getPlayerElapsedTime(),getPlayerTotalTime());
myfprintf(fp,"%s: %li\n",COMMAND_STATUS_BITRATE,getPlayerBitRate(),getPlayerTotalTime()); myfprintf(fp,"%s: %li\n",COMMAND_STATUS_BITRATE,getPlayerBitRate(),getPlayerTotalTime());
myfprintf(fp,"%s: %i\n",COMMAND_STATUS_CROSSFADE,(int)getPlayerCrossFade());
myfprintf(fp,"%s: %u:%i:%i\n",COMMAND_STATUS_AUDIO,getPlayerSampleRate(),getPlayerBits(),getPlayerChannels());
} }
if(getPlayerError()!=PLAYER_ERROR_NOERROR) { if(getPlayerError()!=PLAYER_ERROR_NOERROR) {
@ -512,11 +517,6 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength,
int time; int time;
char * test; char * test;
if(argArrayLength==1) {
myfprintf(fp,"crossfade: %i\n",(int)(getPlayerCrossFade()));
return 0;
}
time = strtol(argArray[1],&test,10); time = strtol(argArray[1],&test,10);
if(*test!='\0' || time<0) { if(*test!='\0' || time<0) {
myfprintf(fp,"%s \"%s\" is not a integer >= 0\n", myfprintf(fp,"%s \"%s\" is not a integer >= 0\n",
@ -567,7 +567,7 @@ void initCommands() {
addCommand(COMMAND_PING ,0, 0, 0,handlePing); addCommand(COMMAND_PING ,0, 0, 0,handlePing);
addCommand(COMMAND_SETVOL ,PERMISSION_CONTROL, 1, 1,handleSetVol); addCommand(COMMAND_SETVOL ,PERMISSION_CONTROL, 1, 1,handleSetVol);
addCommand(COMMAND_PASSWORD ,0, 1, 1,handlePassword); addCommand(COMMAND_PASSWORD ,0, 1, 1,handlePassword);
addCommand(COMMAND_CROSSFADE ,PERMISSION_CONTROL, 0, 1,handleCrossfade); addCommand(COMMAND_CROSSFADE ,PERMISSION_CONTROL, 1, 1,handleCrossfade);
sortList(commandList); sortList(commandList);
} }

View File

@ -17,6 +17,7 @@
*/ */
#include "decode.h" #include "decode.h"
#include "player.h" #include "player.h"
#include "playerData.h" #include "playerData.h"
#include "utils.h" #include "utils.h"
@ -123,6 +124,9 @@ int waitOnDecode(PlayerControl * pc, AudioFormat * af, DecoderControl * dc,
pc->elapsedTime = 0; pc->elapsedTime = 0;
pc->bitRate = 0; pc->bitRate = 0;
pc->sampleRate = af->sampleRate;
pc->bits = af->bits;
pc->channels = af->channels;
pc->totalTime = cb->totalTime; pc->totalTime = cb->totalTime;
return 0; return 0;

View File

@ -414,3 +414,21 @@ double getPlayerTotalPlayTime() {
return pc->totalPlayTime+pc->elapsedTime-pc->beginTime; return pc->totalPlayTime+pc->elapsedTime-pc->beginTime;
} }
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;
}

View File

@ -19,6 +19,8 @@
#ifndef PLAYER_H #ifndef PLAYER_H
#define PLAYER_H #define PLAYER_H
#include "mpd_types.h"
#include <stdio.h> #include <stdio.h>
#include <sys/param.h> #include <sys/param.h>
@ -47,27 +49,30 @@
#define PLAYER_QUEUE_LOCKED 1 #define PLAYER_QUEUE_LOCKED 1
typedef struct _PlayerControl { typedef struct _PlayerControl {
int decodeType; mpd_sint8 decodeType;
int stop; mpd_sint8 stop;
int play; mpd_sint8 play;
int pause; mpd_sint8 pause;
int state; mpd_sint8 state;
int closeAudio; mpd_sint8 closeAudio;
int error; mpd_sint8 error;
unsigned long bitRate; mpd_uint16 bitRate;
mpd_sint8 bits;
mpd_sint8 channels;
mpd_uint32 sampleRate;
float beginTime; float beginTime;
float totalTime; float totalTime;
float elapsedTime; float elapsedTime;
char file[MAXPATHLEN+1]; char file[MAXPATHLEN+1];
char erroredFile[MAXPATHLEN+1]; char erroredFile[MAXPATHLEN+1];
int queueState; mpd_sint8 queueState;
int queueLockState; mpd_sint8 queueLockState;
int lockQueue; mpd_sint8 lockQueue;
int unlockQueue; mpd_sint8 unlockQueue;
int seek; mpd_sint8 seek;
double seekWhere; double seekWhere;
float crossFade; float crossFade;
int softwareVolume; mpd_sint8 softwareVolume;
double totalPlayTime; double totalPlayTime;
} PlayerControl; } PlayerControl;
@ -125,4 +130,10 @@ void setPlayerSoftwareVolume(int volume);
double getPlayerTotalPlayTime(); double getPlayerTotalPlayTime();
unsigned int getPlayerSampleRate();
int getPlayerBits();
int getPlayerChannels();
#endif #endif