summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/audio.h8
-rw-r--r--src/audiofile_decode.c6
-rw-r--r--src/command.c12
-rw-r--r--src/decode.c4
-rw-r--r--src/player.c18
-rw-r--r--src/player.h39
6 files changed, 62 insertions, 25 deletions
diff --git a/src/audio.h b/src/audio.h
index 9bdc29705..60cee26f3 100644
--- a/src/audio.h
+++ b/src/audio.h
@@ -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;
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c
index 19f4623d1..c6c04dafd 100644
--- a/src/audiofile_decode.c
+++ b/src/audiofile_decode.c
@@ -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);
diff --git a/src/command.c b/src/command.c
index 9d0fca603..6b26cc918 100644
--- a/src/command.c
+++ b/src/command.c
@@ -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);
}
diff --git a/src/decode.c b/src/decode.c
index f9e07db62..3ad93626c 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -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;
diff --git a/src/player.c b/src/player.c
index 3b3bf250c..6bc671002 100644
--- a/src/player.c
+++ b/src/player.c
@@ -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;
+}
diff --git a/src/player.h b/src/player.h
index 43c136e3a..a50b799c8 100644
--- a/src/player.h
+++ b/src/player.h
@@ -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