From dec6b1612e953c6029d963ff55d2b4a669b60f43 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 Apr 2008 01:16:03 +0000 Subject: 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 --- src/inputPlugins/audiofile_plugin.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/inputPlugins/audiofile_plugin.c') 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; } } -- cgit v1.2.3