Commit 32fd264f authored by Avuton Olrich's avatar Avuton Olrich

[CLEANUP] Fix indentation to be like the rest of

the repository git-svn-id: https://svn.musicpd.org/mpd/trunk@4348 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 3ad41fdd
...@@ -45,7 +45,7 @@ typedef struct { ...@@ -45,7 +45,7 @@ typedef struct {
unsigned long stream_decode_type; unsigned long stream_decode_type;
unsigned long sample_rate; unsigned long sample_rate;
unsigned long bit_rate; unsigned long bit_rate;
unsigned long raw[64/sizeof(unsigned long)]; unsigned long raw[64 / sizeof(unsigned long)];
} aud_status_t; } aud_status_t;
#define MVP_SET_AUD_STOP _IOW('a',1,int) #define MVP_SET_AUD_STOP _IOW('a',1,int)
...@@ -69,58 +69,63 @@ typedef struct { ...@@ -69,58 +69,63 @@ typedef struct {
#define MVP_SET_AUD_DAC_CLK _IOW('a',27,int) #define MVP_SET_AUD_DAC_CLK _IOW('a',27,int)
#define MVP_GET_AUD_REGS _IOW('a',28,aud_ctl_regs_t*) #define MVP_GET_AUD_REGS _IOW('a',28,aud_ctl_regs_t*)
typedef struct _MvpData { typedef struct _MvpData {
int fd; int fd;
} MvpData; } MvpData;
static int pcmfrequencies[][3] = { static int pcmfrequencies[][3] = {
{9 ,8000 ,32000}, {9, 8000, 32000},
{10,11025,44100}, {10, 11025, 44100},
{11,12000,48000}, {11, 12000, 48000},
{1 ,16000,32000}, {1, 16000, 32000},
{2 ,22050,44100}, {2, 22050, 44100},
{3 ,24000,48000}, {3, 24000, 48000},
{5 ,32000,32000}, {5, 32000, 32000},
{0 ,44100,44100}, {0, 44100, 44100},
{7 ,48000,48000}, {7, 48000, 48000},
{13,64000,32000}, {13, 64000, 32000},
{14,88200,44100}, {14, 88200, 44100},
{15,96000,48000}}; {15, 96000, 48000}
};
static int numfrequencies = sizeof(pcmfrequencies)/12;
static int numfrequencies = sizeof(pcmfrequencies) / 12;
static int mvp_testDefault() {
static int mvp_testDefault()
{
int fd; int fd;
fd = open("/dev/adec_pcm", O_WRONLY); fd = open("/dev/adec_pcm", O_WRONLY);
if(fd) { if (fd) {
close(fd); close(fd);
return 0; return 0;
} }
WARNING("Error opening PCM device \"/dev/adec_pcm\": %s\n", WARNING("Error opening PCM device \"/dev/adec_pcm\": %s\n",
strerror(errno)); strerror(errno));
return -1; return -1;
} }
static int mvp_initDriver(AudioOutput * audioOutput, ConfigParam * param) { static int mvp_initDriver(AudioOutput * audioOutput, ConfigParam * param)
MvpData * md = malloc(sizeof(MvpData)); {
md->fd = -1; MvpData *md = malloc(sizeof(MvpData));
md->fd = -1;
audioOutput->data = md; audioOutput->data = md;
return 0; return 0;
} }
static void mvp_finishDriver(AudioOutput * audioOutput) { static void mvp_finishDriver(AudioOutput * audioOutput)
MvpData *md = audioOutput->data; {
free(md); MvpData *md = audioOutput->data;
free(md);
} }
static int mvp_setPcmParams(MvpData *md, unsigned long rate, int channels, int big_endian, int bits){ static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
int iloop; int big_endian, int bits)
{
int iloop;
int mix[5]; int mix[5];
if (channels == 1) if (channels == 1)
...@@ -138,7 +143,7 @@ static int mvp_setPcmParams(MvpData *md, unsigned long rate, int channels, int b ...@@ -138,7 +143,7 @@ static int mvp_setPcmParams(MvpData *md, unsigned long rate, int channels, int b
else else
return -1; return -1;
mix[3] = 0; /* stream type? */ mix[3] = 0; /* stream type? */
if (big_endian == 1) if (big_endian == 1)
mix[4] = 1; mix[4] = 1;
...@@ -150,135 +155,134 @@ static int mvp_setPcmParams(MvpData *md, unsigned long rate, int channels, int b ...@@ -150,135 +155,134 @@ static int mvp_setPcmParams(MvpData *md, unsigned long rate, int channels, int b
/* /*
* if there is an exact match for the frequency, use it. * if there is an exact match for the frequency, use it.
*/ */
for(iloop = 0;iloop<numfrequencies;iloop++) for (iloop = 0; iloop < numfrequencies; iloop++) {
{ if (rate == pcmfrequencies[iloop][1]) {
if(rate == pcmfrequencies[iloop][1])
{
mix[2] = pcmfrequencies[iloop][0]; mix[2] = pcmfrequencies[iloop][0];
break; break;
} }
} }
if (iloop >= numfrequencies) { if (iloop >= numfrequencies) {
ERROR("Can not find suitable output frequency for %ld\n", ERROR("Can not find suitable output frequency for %ld\n", rate);
rate);
return -1; return -1;
} }
if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0){ if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0) {
ERROR("Can not set audio format\n"); ERROR("Can not set audio format\n");
return -1; return -1;
} }
if (ioctl(md->fd, MVP_SET_AUD_SYNC, 2) != 0){ if (ioctl(md->fd, MVP_SET_AUD_SYNC, 2) != 0) {
ERROR("Can not set audio sync\n"); ERROR("Can not set audio sync\n");
return -1; return -1;
} }
if (ioctl(md->fd, MVP_SET_AUD_PLAY, 0) < 0){ if (ioctl(md->fd, MVP_SET_AUD_PLAY, 0) < 0) {
ERROR("Can not set audio play mode\n"); ERROR("Can not set audio play mode\n");
return -1; return -1;
} }
return 0; return 0;
} }
static int mvp_openDevice(AudioOutput * audioOutput)
static int mvp_openDevice(AudioOutput * audioOutput)
{ {
int ret = -1; int ret = -1;
long long int stc = 0; long long int stc = 0;
MvpData * md = audioOutput->data; MvpData *md = audioOutput->data;
AudioFormat * audioFormat = &audioOutput->outAudioFormat; AudioFormat *audioFormat = &audioOutput->outAudioFormat;
int mix[5] = { 0, 2, 7, 1, 0 }; int mix[5] = { 0, 2, 7, 1, 0 };
if ((md->fd=open("/dev/adec_pcm", if ((md->fd = open("/dev/adec_pcm", O_RDWR | O_NONBLOCK)) < 0) {
O_RDWR|O_NONBLOCK)) < 0){ ERROR("Error opening /dev/adec_pcm: %s\n", strerror(errno));
ERROR("Error opening /dev/adec_pcm: %s\n", strerror(errno)); return -1;
return -1; }
} if (ioctl(md->fd, MVP_SET_AUD_SRC, 1) < 0) {
if (ioctl(md->fd, MVP_SET_AUD_SRC, 1) < 0){ ERROR("Error setting audio source: %s\n", strerror(errno));
ERROR("Error setting audio source: %s\n", strerror(errno)); return -1;
return -1; }
} if (ioctl(md->fd, MVP_SET_AUD_STREAMTYPE, 0) < 0) {
if (ioctl(md->fd, MVP_SET_AUD_STREAMTYPE, 0) < 0){ ERROR("Error setting audio streamtype: %s\n", strerror(errno));
ERROR("Error setting audio streamtype: %s\n", strerror(errno)); return -1;
return -1; }
} if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0) {
if (ioctl(md->fd, MVP_SET_AUD_FORMAT, &mix) < 0){ ERROR("Error setting audio format: %s\n", strerror(errno));
ERROR("Error setting audio format: %s\n", strerror(errno)); return -1;
return -1; }
} ioctl(md->fd, MVP_SET_AUD_STC, &stc);
ioctl(md->fd, MVP_SET_AUD_STC, &stc); if (ioctl(md->fd, MVP_SET_AUD_BYPASS, 1) < 0) {
if (ioctl(md->fd, MVP_SET_AUD_BYPASS, 1) < 0){ ERROR("Error setting audio streamtype: %s\n", strerror(errno));
ERROR("Error setting audio streamtype: %s\n", strerror(errno)); return -1;
return -1; }
}
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
mvp_setPcmParams(md, audioFormat->sampleRate, audioFormat->channels, 0, audioFormat->bits); mvp_setPcmParams(md, audioFormat->sampleRate, audioFormat->channels, 0,
audioFormat->bits);
#else #else
mvp_setPcmParams(md, audioFormat->sampleRate, audioFormat->channels, 1, audioFormat->bits); mvp_setPcmParams(md, audioFormat->sampleRate, audioFormat->channels, 1,
audioFormat->bits);
#endif #endif
audioOutput->open = 1; audioOutput->open = 1;
return 0; return 0;
} }
static void mvp_closeDevice(AudioOutput * audioOutput) { static void mvp_closeDevice(AudioOutput * audioOutput)
MvpData * md = audioOutput->data; {
if(md->fd >= 0) close(md->fd); MvpData *md = audioOutput->data;
if (md->fd >= 0)
close(md->fd);
md->fd = -1; md->fd = -1;
audioOutput->open = 0; audioOutput->open = 0;
} }
static void mvp_dropBufferedAudio(AudioOutput * audioOutput) { static void mvp_dropBufferedAudio(AudioOutput * audioOutput)
MvpData * md = audioOutput->data; {
if(md->fd >=0){ MvpData *md = audioOutput->data;
ioctl(md->fd, MVP_SET_AUD_RESET, 0x11); if (md->fd >= 0) {
close(md->fd); ioctl(md->fd, MVP_SET_AUD_RESET, 0x11);
md->fd = -1; close(md->fd);
audioOutput->open = 0; md->fd = -1;
} audioOutput->open = 0;
}
} }
static int mvp_playAudio(AudioOutput * audioOutput, char * playChunk, static int mvp_playAudio(AudioOutput * audioOutput, char *playChunk, int size)
int size)
{ {
MvpData * md = audioOutput->data; MvpData *md = audioOutput->data;
int ret; int ret;
/* reopen the device since it was closed by dropBufferedAudio */ /* reopen the device since it was closed by dropBufferedAudio */
if(md->fd < 0) mvp_openDevice(audioOutput); if (md->fd < 0)
mvp_openDevice(audioOutput);
while (size > 0) {
ret = write(md->fd, playChunk, size); while (size > 0) {
if(ret<0) { ret = write(md->fd, playChunk, size);
if(errno == EINTR) continue; if (ret < 0) {
ERROR("closing mvp PCM device due to write error: " if (errno == EINTR)
"%s\n", strerror(errno)); continue;
mvp_closeDevice(audioOutput); ERROR("closing mvp PCM device due to write error: "
return -1; "%s\n", strerror(errno));
} mvp_closeDevice(audioOutput);
playChunk += ret; return -1;
size -= ret; }
} playChunk += ret;
return 0; size -= ret;
}
return 0;
} }
AudioOutputPlugin mvpPlugin = AudioOutputPlugin mvpPlugin = {
{ "mvp",
"mvp", mvp_testDefault,
mvp_testDefault, mvp_initDriver,
mvp_initDriver, mvp_finishDriver,
mvp_finishDriver, mvp_openDevice,
mvp_openDevice, mvp_playAudio,
mvp_playAudio, mvp_dropBufferedAudio,
mvp_dropBufferedAudio, mvp_closeDevice,
mvp_closeDevice, NULL, /* sendMetadataFunc */
NULL, /* sendMetadataFunc */
}; };
#else /* HAVE_MVP */ #else /* HAVE_MVP */
DISABLED_AUDIO_OUTPUT_PLUGIN(mvpPlugin) DISABLED_AUDIO_OUTPUT_PLUGIN(mvpPlugin)
#endif /* HAVE_MVP */
#endif /* HAVE_MVP */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment