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
#define AUDIO_H
#include "mpd_types.h"
#include <stdio.h>
#include <ao/ao.h>
#define AUDIO_AO_DRIVER_DEFAULT "default"
typedef struct _AudioFormat {
int channels;
int sampleRate;
int bits;
mpd_sint8 channels;
mpd_uint32 sampleRate;
mpd_sint8 bits;
} AudioFormat;
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;
AFfilehandle af_fp;
int bits;
af_fp = afOpenFile(dc->file,"r", NULL);
if(af_fp == AF_NULL_FILEHANDLE) {
@ -59,8 +60,9 @@ int audiofile_decode(Buffer * cb, AudioFormat * af, DecoderControl * dc)
return -1;
}
afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &af->bits);
af->sampleRate = (int)afGetRate(af_fp, AF_DEFAULT_TRACK);
afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
af->bits = bits;
af->sampleRate = afGetRate(af_fp, AF_DEFAULT_TRACK);
af->channels = afGetChannels(af_fp,AF_DEFAULT_TRACK);
frame_count = afGetFrameCount(af_fp,AF_DEFAULT_TRACK);

View File

@ -29,6 +29,7 @@
#include "list.h"
#include "conf.h"
#include "permission.h"
#include "audio.h"
#include <stdlib.h>
#include <string.h>
@ -81,6 +82,8 @@
#define COMMAND_STATUS_TIME "time"
#define COMMAND_STATUS_BITRATE "bitrate"
#define COMMAND_STATUS_ERROR "error"
#define COMMAND_STATUS_CROSSFADE "xfade"
#define COMMAND_STATUS_AUDIO "audio"
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:%i\n",COMMAND_STATUS_TIME,getPlayerElapsedTime(),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) {
@ -512,11 +517,6 @@ int handleCrossfade(FILE * fp, unsigned int * permission, int argArrayLength,
int time;
char * test;
if(argArrayLength==1) {
myfprintf(fp,"crossfade: %i\n",(int)(getPlayerCrossFade()));
return 0;
}
time = strtol(argArray[1],&test,10);
if(*test!='\0' || time<0) {
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_SETVOL ,PERMISSION_CONTROL, 1, 1,handleSetVol);
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);
}

View File

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

View File

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