aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/audiofile_plugin.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-04-13 01:16:03 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-13 01:16:03 +0000
commitdec6b1612e953c6029d963ff55d2b4a669b60f43 (patch)
treea1138cb07f67c821ee5000618302d21367ab2245 /src/inputPlugins/audiofile_plugin.c
parent98acfa8ac5bac09ca49a7c21938b5a5801e01ca5 (diff)
downloadmpd-dec6b1612e953c6029d963ff55d2b4a669b60f43.tar.gz
mpd-dec6b1612e953c6029d963ff55d2b4a669b60f43.tar.xz
mpd-dec6b1612e953c6029d963ff55d2b4a669b60f43.zip
Stop passing our single DecoderControl object everywhere
This at least makes the argument list to a lot of our plugin functions shorter and removes a good amount of line nois^W^Wcode, hopefully making things easier to read and follow. git-svn-id: https://svn.musicpd.org/mpd/trunk@7353 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputPlugins/audiofile_plugin.c')
-rw-r--r--src/inputPlugins/audiofile_plugin.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index 33ea54df9..4510ba46a 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -45,7 +45,7 @@ static int getAudiofileTotalTime(char *file)
return total_time;
}
-static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
+static int audiofile_decode(OutputBuffer * cb, char *path)
{
int fs, frame_count;
AFfilehandle af_fp;
@@ -67,41 +67,41 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
afSetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK,
AF_SAMPFMT_TWOSCOMP, 16);
afGetVirtualSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
- dc->audioFormat.bits = (mpd_uint8)bits;
- dc->audioFormat.sampleRate =
+ dc.audioFormat.bits = (mpd_uint8)bits;
+ dc.audioFormat.sampleRate =
(unsigned int)afGetRate(af_fp, AF_DEFAULT_TRACK);
- dc->audioFormat.channels =
+ dc.audioFormat.channels =
(mpd_uint8)afGetVirtualChannels(af_fp, AF_DEFAULT_TRACK);
- getOutputAudioFormat(&(dc->audioFormat), &(cb->audioFormat));
+ getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat));
frame_count = afGetFrameCount(af_fp, AF_DEFAULT_TRACK);
- dc->totalTime =
- ((float)frame_count / (float)dc->audioFormat.sampleRate);
+ dc.totalTime =
+ ((float)frame_count / (float)dc.audioFormat.sampleRate);
- bitRate = (mpd_uint16)(st.st_size * 8.0 / dc->totalTime / 1000.0 + 0.5);
+ bitRate = (mpd_uint16)(st.st_size * 8.0 / dc.totalTime / 1000.0 + 0.5);
- if (dc->audioFormat.bits != 8 && dc->audioFormat.bits != 16) {
+ if (dc.audioFormat.bits != 8 && dc.audioFormat.bits != 16) {
ERROR("Only 8 and 16-bit files are supported. %s is %i-bit\n",
- path, dc->audioFormat.bits);
+ path, dc.audioFormat.bits);
afCloseFile(af_fp);
return -1;
}
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
- dc->state = DECODE_STATE_DECODE;
+ dc.state = DECODE_STATE_DECODE;
{
int ret, eof = 0, current = 0;
char chunk[CHUNK_SIZE];
while (!eof) {
- if (dc->seek) {
+ if (dc.seek) {
clearOutputBuffer(cb);
- current = dc->seekWhere *
- dc->audioFormat.sampleRate;
+ current = dc.seekWhere *
+ dc.audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
- dc->seek = 0;
+ dc.seek = 0;
decoder_wakeup_player();
}
@@ -114,15 +114,14 @@ static int audiofile_decode(OutputBuffer * cb, DecoderControl * dc, char *path)
current += ret;
sendDataToOutputBuffer(cb,
NULL,
- dc,
1,
chunk,
ret * fs,
(float)current /
- (float)dc->audioFormat.
+ (float)dc.audioFormat.
sampleRate, bitRate,
NULL);
- if (dc->stop)
+ if (dc.stop)
break;
}
}