diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-04-13 01:16:03 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-04-13 01:16:03 +0000 |
commit | dec6b1612e953c6029d963ff55d2b4a669b60f43 (patch) | |
tree | a1138cb07f67c821ee5000618302d21367ab2245 /src/inputPlugins | |
parent | 98acfa8ac5bac09ca49a7c21938b5a5801e01ca5 (diff) | |
download | mpd-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')
-rw-r--r-- | src/inputPlugins/_flac_common.c | 17 | ||||
-rw-r--r-- | src/inputPlugins/_flac_common.h | 6 | ||||
-rw-r--r-- | src/inputPlugins/aac_plugin.c | 34 | ||||
-rw-r--r-- | src/inputPlugins/audiofile_plugin.c | 35 | ||||
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 43 | ||||
-rw-r--r-- | src/inputPlugins/mod_plugin.c | 28 | ||||
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 74 | ||||
-rw-r--r-- | src/inputPlugins/mp4_plugin.c | 41 | ||||
-rw-r--r-- | src/inputPlugins/mpc_plugin.c | 53 | ||||
-rw-r--r-- | src/inputPlugins/oggflac_plugin.c | 31 | ||||
-rw-r--r-- | src/inputPlugins/oggvorbis_plugin.c | 47 | ||||
-rw-r--r-- | src/inputPlugins/wavpack_plugin.c | 57 |
12 files changed, 222 insertions, 244 deletions
diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c index 3b351d3a7..a26163303 100644 --- a/src/inputPlugins/_flac_common.c +++ b/src/inputPlugins/_flac_common.c @@ -36,15 +36,13 @@ #include <FLAC/format.h> #include <FLAC/metadata.h> -void init_FlacData(FlacData * data, OutputBuffer * cb, - DecoderControl * dc, InputStream * inStream) +void init_FlacData(FlacData * data, OutputBuffer * cb, InputStream * inStream) { data->chunk_length = 0; data->time = 0; data->position = 0; data->bitRate = 0; data->cb = cb; - data->dc = dc; data->inStream = inStream; data->replayGainInfo = NULL; data->tag = NULL; @@ -165,16 +163,15 @@ MpdTag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block, void flac_metadata_common_cb(const FLAC__StreamMetadata * block, FlacData * data) { - DecoderControl *dc = data->dc; const FLAC__StreamMetadata_StreamInfo *si = &(block->data.stream_info); switch (block->type) { case FLAC__METADATA_TYPE_STREAMINFO: - dc->audioFormat.bits = (mpd_sint8)si->bits_per_sample; - dc->audioFormat.sampleRate = si->sample_rate; - dc->audioFormat.channels = (mpd_sint8)si->channels; - dc->totalTime = ((float)si->total_samples) / (si->sample_rate); - getOutputAudioFormat(&(dc->audioFormat), + dc.audioFormat.bits = (mpd_sint8)si->bits_per_sample; + dc.audioFormat.sampleRate = si->sample_rate; + dc.audioFormat.channels = (mpd_sint8)si->channels; + dc.totalTime = ((float)si->total_samples) / (si->sample_rate); + getOutputAudioFormat(&(dc.audioFormat), &(data->cb->audioFormat)); break; case FLAC__METADATA_TYPE_VORBIS_COMMENT: @@ -188,7 +185,7 @@ void flac_error_common_cb(const char *plugin, const FLAC__StreamDecoderErrorStatus status, FlacData * data) { - if (data->dc->stop) + if (dc.stop) return; switch (status) { diff --git a/src/inputPlugins/_flac_common.h b/src/inputPlugins/_flac_common.h index faeccf1ca..37b5fdaae 100644 --- a/src/inputPlugins/_flac_common.h +++ b/src/inputPlugins/_flac_common.h @@ -149,15 +149,13 @@ typedef struct { unsigned int bitRate; FLAC__uint64 position; OutputBuffer *cb; - DecoderControl *dc; InputStream *inStream; ReplayGainInfo *replayGainInfo; MpdTag *tag; } FlacData; /* initializes a given FlacData struct */ -void init_FlacData(FlacData * data, OutputBuffer * cb, - DecoderControl * dc, InputStream * inStream); +void init_FlacData(FlacData * data, OutputBuffer * cb, InputStream * inStream); void flac_metadata_common_cb(const FLAC__StreamMetadata * block, FlacData * data); void flac_error_common_cb(const char *plugin, @@ -171,7 +169,7 @@ MpdTag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block, static inline int flacSendChunk(FlacData * data) { if (sendDataToOutputBuffer(data->cb, data->inStream, - data->dc, 1, data->chunk, + 1, data->chunk, data->chunk_length, data->time, data->bitRate, data->replayGainInfo) == diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c index 2962b57c6..aeda10492 100644 --- a/src/inputPlugins/aac_plugin.c +++ b/src/inputPlugins/aac_plugin.c @@ -282,7 +282,7 @@ static int getAacTotalTime(char *file) return file_time; } -static int aac_decode(OutputBuffer * cb, DecoderControl * dc, char *path) +static int aac_decode(OutputBuffer * cb, char *path) { float file_time; float totalTime; @@ -339,9 +339,9 @@ static int aac_decode(OutputBuffer * cb, DecoderControl * dc, char *path) return -1; } - dc->audioFormat.bits = 16; + dc.audioFormat.bits = 16; - dc->totalTime = totalTime; + dc.totalTime = totalTime; file_time = 0.0; @@ -372,12 +372,12 @@ static int aac_decode(OutputBuffer * cb, DecoderControl * dc, char *path) sampleRate = frameInfo.samplerate; #endif - if (dc->state != DECODE_STATE_DECODE) { - dc->audioFormat.channels = frameInfo.channels; - dc->audioFormat.sampleRate = sampleRate; - getOutputAudioFormat(&(dc->audioFormat), + if (dc.state != DECODE_STATE_DECODE) { + dc.audioFormat.channels = frameInfo.channels; + dc.audioFormat.sampleRate = sampleRate; + getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat)); - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; } advanceAacBuffer(&b, frameInfo.bytesconsumed); @@ -395,14 +395,14 @@ static int aac_decode(OutputBuffer * cb, DecoderControl * dc, char *path) sampleBufferLen = sampleCount * 2; - sendDataToOutputBuffer(cb, NULL, dc, 0, sampleBuffer, + sendDataToOutputBuffer(cb, NULL, 0, sampleBuffer, sampleBufferLen, file_time, bitRate, NULL); - if (dc->seek) { - dc->seekError = 1; - dc->seek = 0; + if (dc.seek) { + dc.seekError = 1; + dc.seek = 0; decoder_wakeup_player(); - } else if (dc->stop) { + } else if (dc.stop) { eof = 1; break; } @@ -414,12 +414,12 @@ static int aac_decode(OutputBuffer * cb, DecoderControl * dc, char *path) if (b.buffer) free(b.buffer); - if (dc->state != DECODE_STATE_DECODE) + if (dc.state != DECODE_STATE_DECODE) return -1; - if (dc->seek) { - dc->seekError = 1; - dc->seek = 0; + if (dc.seek) { + dc.seekError = 1; + dc.seek = 0; decoder_wakeup_player(); } 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; } } diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index b5c18af75..f171ee457 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -41,15 +41,14 @@ static flac_read_status flacRead(const flac_decoder * flacDec, while (1) { r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes); - if (r == 0 && !inputStreamAtEOF(data->inStream) && - !data->dc->stop) + if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop) my_usleep(10000); else break; } *bytes = r; - if (r == 0 && !data->dc->stop) { + if (r == 0 && !dc.stop) { if (inputStreamAtEOF(data->inStream)) return flac_read_status_eof; else @@ -248,7 +247,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, FLAC__uint32 samples = frame->header.blocksize; unsigned int c_samp; const unsigned int num_channels = frame->header.channels; - const unsigned int bytes_per_sample = (data->dc->audioFormat.bits / 8); + const unsigned int bytes_per_sample = (dc.audioFormat.bits / 8); const unsigned int bytes_per_channel = bytes_per_sample * frame->header.channels; const unsigned int max_samples = FLAC_CHUNK_SIZE / bytes_per_channel; @@ -256,7 +255,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, float timeChange; FLAC__uint64 newPosition = 0; - assert(data->dc->audioFormat.bits > 0); + assert(dc.audioFormat.bits > 0); timeChange = ((float)samples) / frame->header.sample_rate; data->time += timeChange; @@ -292,7 +291,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } data->chunk_length = 0; - if (data->dc->seek) { + if (dc.seek) { return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } @@ -382,7 +381,7 @@ static MpdTag *flacTagDup(char *file) return ret; } -static int flac_decode_internal(OutputBuffer * cb, DecoderControl * dc, +static int flac_decode_internal(OutputBuffer * cb, InputStream * inStream, int is_ogg) { flac_decoder *flacDec; @@ -391,7 +390,7 @@ static int flac_decode_internal(OutputBuffer * cb, DecoderControl * dc, if (!(flacDec = flac_new())) return -1; - init_FlacData(&data, cb, dc, inStream); + init_FlacData(&data, cb, inStream); #if defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7 if(!FLAC__stream_decoder_set_metadata_respond(flacDec, FLAC__METADATA_TYPE_VORBIS_COMMENT)) @@ -421,33 +420,33 @@ static int flac_decode_internal(OutputBuffer * cb, DecoderControl * dc, } } - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; while (1) { if (!flac_process_single(flacDec)) break; if (flac_get_state(flacDec) == flac_decoder_eof) break; - if (dc->seek) { - FLAC__uint64 sampleToSeek = dc->seekWhere * - dc->audioFormat.sampleRate + 0.5; + if (dc.seek) { + FLAC__uint64 sampleToSeek = dc.seekWhere * + dc.audioFormat.sampleRate + 0.5; if (flac_seek_absolute(flacDec, sampleToSeek)) { clearOutputBuffer(cb); data.time = ((float)sampleToSeek) / - dc->audioFormat.sampleRate; + dc.audioFormat.sampleRate; data.position = 0; } else - dc->seekError = 1; - dc->seek = 0; + dc.seekError = 1; + dc.seek = 0; decoder_wakeup_player(); } } - if (!dc->stop) { + if (!dc.stop) { flacPrintErroredState(flac_get_state(flacDec)); flac_finish(flacDec); } /* send last little bit */ - if (data.chunk_length > 0 && !dc->stop) { + if (data.chunk_length > 0 && !dc.stop) { flacSendChunk(&data); flushOutputBuffer(data.cb); } @@ -466,10 +465,9 @@ fail: return 0; } -static int flac_decode(OutputBuffer * cb, DecoderControl * dc, - InputStream * inStream) +static int flac_decode(OutputBuffer * cb, InputStream * inStream) { - return flac_decode_internal(cb, dc, inStream, 0); + return flac_decode_internal(cb, inStream, 0); } #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 @@ -508,10 +506,9 @@ out: return ret; } -static int oggflac_decode(OutputBuffer * cb, DecoderControl * dc, - InputStream * inStream) +static int oggflac_decode(OutputBuffer * cb, InputStream * inStream) { - return flac_decode_internal(cb, dc, inStream, 1); + return flac_decode_internal(cb, inStream, 1); } static unsigned int oggflac_try_decode(InputStream * inStream) diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c index 25cedf04b..728f42d6f 100644 --- a/src/inputPlugins/mod_plugin.c +++ b/src/inputPlugins/mod_plugin.c @@ -163,7 +163,7 @@ static void mod_close(mod_Data * data) free(data); } -static int mod_decode(OutputBuffer * cb, DecoderControl * dc, char *path) +static int mod_decode(OutputBuffer * cb, char *path) { mod_Data *data; float total_time = 0.0; @@ -179,25 +179,25 @@ static int mod_decode(OutputBuffer * cb, DecoderControl * dc, char *path) return -1; } - dc->totalTime = 0; - dc->audioFormat.bits = 16; - dc->audioFormat.sampleRate = 44100; - dc->audioFormat.channels = 2; - getOutputAudioFormat(&(dc->audioFormat), &(cb->audioFormat)); + dc.totalTime = 0; + dc.audioFormat.bits = 16; + dc.audioFormat.sampleRate = 44100; + dc.audioFormat.channels = 2; + getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat)); secPerByte = - 1.0 / ((dc->audioFormat.bits * dc->audioFormat.channels / 8.0) * - (float)dc->audioFormat.sampleRate); + 1.0 / ((dc.audioFormat.bits * dc.audioFormat.channels / 8.0) * + (float)dc.audioFormat.sampleRate); - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; while (1) { - if (dc->seek) { - dc->seekError = 1; - dc->seek = 0; + if (dc.seek) { + dc.seekError = 1; + dc.seek = 0; decoder_wakeup_player(); } - if (dc->stop) + if (dc.stop) break; if (!Player_Active()) @@ -205,7 +205,7 @@ static int mod_decode(OutputBuffer * cb, DecoderControl * dc, char *path) ret = VC_WriteBytes(data->audio_buffer, MIKMOD_FRAME_SIZE); total_time += ret * secPerByte; - sendDataToOutputBuffer(cb, NULL, dc, 0, + sendDataToOutputBuffer(cb, NULL, 0, (char *)data->audio_buffer, ret, total_time, 0, NULL); } diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 875ec1482..ea33ad5ad 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -674,7 +674,7 @@ static int parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) return 1; } -static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc, +static int decodeFirstFrame(mp3DecodeData * data, MpdTag ** tag, ReplayGainInfo ** replayGainInfo) { struct xing xing; @@ -689,13 +689,13 @@ static int decodeFirstFrame(mp3DecodeData * data, DecoderControl * dc, while (1) { while ((ret = decodeNextFrameHeader(data, tag, replayGainInfo)) == DECODE_CONT && - (!dc || !dc->stop)); - if (ret == DECODE_BREAK || (dc && dc->stop)) return -1; + !dc.stop); + if (ret == DECODE_BREAK || dc.stop) return -1; if (ret == DECODE_SKIP) continue; while ((ret = decodeNextFrame(data)) == DECODE_CONT && - (!dc || !dc->stop)); - if (ret == DECODE_BREAK || (dc && dc->stop)) return -1; + !dc.stop); + if (ret == DECODE_BREAK || dc.stop) return -1; if (ret == DECODE_OK) break; } @@ -787,7 +787,7 @@ static int getMp3TotalTime(char *file) if (openInputStream(&inStream, file) < 0) return -1; initMp3DecodeData(&data, &inStream); - if (decodeFirstFrame(&data, NULL, NULL, NULL) < 0) + if (decodeFirstFrame(&data, NULL, NULL) < 0) ret = -1; else ret = data.totalTime + 0.5; @@ -798,12 +798,12 @@ static int getMp3TotalTime(char *file) } static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data, - DecoderControl * dc, MpdTag ** tag, + MpdTag ** tag, ReplayGainInfo ** replayGainInfo) { initMp3DecodeData(data, inStream); *tag = NULL; - if (decodeFirstFrame(data, dc, tag, replayGainInfo) < 0) { + if (decodeFirstFrame(data, tag, replayGainInfo) < 0) { mp3DecodeDataFinalize(data); if (tag && *tag) freeMpdTag(*tag); @@ -813,7 +813,7 @@ static int openMp3FromInputStream(InputStream * inStream, mp3DecodeData * data, return 0; } -static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, +static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, ReplayGainInfo ** replayGainInfo) { int samplesPerFrame; @@ -852,11 +852,11 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, data->muteFrame = 0; break; case MUTEFRAME_SEEK: - if (dc->seekWhere <= data->elapsedTime) { + if (dc.seekWhere <= data->elapsedTime) { data->outputPtr = data->outputBuffer; clearOutputBuffer(cb); data->muteFrame = 0; - dc->seek = 0; + dc.seek = 0; decoder_wakeup_player(); } break; @@ -931,7 +931,6 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, if (data->outputPtr >= data->outputBufferEnd) { ret = sendDataToOutputBuffer(cb, data->inStream, - dc, data->inStream->seekable, data->outputBuffer, data->outputPtr - data->outputBuffer, @@ -952,10 +951,10 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, data->decodedFirstFrame = 1; - if (dc->seek && data->inStream->seekable) { + if (dc.seek && data->inStream->seekable) { long j = 0; data->muteFrame = MUTEFRAME_SEEK; - while (j < data->highestFrame && dc->seekWhere > + while (j < data->highestFrame && dc.seekWhere > ((float)mad_timer_count(data->times[j], MAD_UNITS_MILLISECONDS)) / 1000) { @@ -969,14 +968,14 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, clearOutputBuffer(cb); data->currentFrame = j; } else - dc->seekError = 1; + dc.seekError = 1; data->muteFrame = 0; - dc->seek = 0; + dc.seek = 0; decoder_wakeup_player(); } - } else if (dc->seek && !data->inStream->seekable) { - dc->seek = 0; - dc->seekError = 1; + } else if (dc.seek && !data->inStream->seekable) { + dc.seek = 0; + dc.seekError = 1; decoder_wakeup_player(); } } @@ -986,22 +985,22 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, while ((ret = decodeNextFrameHeader(data, NULL, replayGainInfo)) == DECODE_CONT - && !dc->stop) ; - if (ret == DECODE_BREAK || dc->stop || dc->seek) + && !dc.stop) ; + if (ret == DECODE_BREAK || dc.stop || dc.seek) break; else if (ret == DECODE_SKIP) skip = 1; if (!data->muteFrame) { while ((ret = decodeNextFrame(data)) == DECODE_CONT && - !dc->stop && !dc->seek) ; - if (ret == DECODE_BREAK || dc->stop || dc->seek) + !dc.stop && !dc.seek) ; + if (ret == DECODE_BREAK || dc.stop || dc.seek) break; } if (!skip && ret == DECODE_OK) break; } - if (dc->stop) + if (dc.stop) return DECODE_BREAK; return ret; @@ -1015,16 +1014,15 @@ static void initAudioFormatFromMp3DecodeData(mp3DecodeData * data, af->channels = MAD_NCHANNELS(&(data->frame).header); } -static int mp3_decode(OutputBuffer * cb, DecoderControl * dc, - InputStream * inStream) +static int mp3_decode(OutputBuffer * cb, InputStream * inStream) { mp3DecodeData data; MpdTag *tag = NULL; ReplayGainInfo *replayGainInfo = NULL; - if (openMp3FromInputStream(inStream, &data, dc, &tag, &replayGainInfo) < + if (openMp3FromInputStream(inStream, &data, &tag, &replayGainInfo) < 0) { - if (!dc->stop) { + if (!dc.stop) { ERROR ("Input does not appear to be a mp3 bit stream.\n"); return -1; @@ -1032,10 +1030,10 @@ static int mp3_decode(OutputBuffer * cb, DecoderControl * dc, return 0; } - initAudioFormatFromMp3DecodeData(&data, &(dc->audioFormat)); - getOutputAudioFormat(&(dc->audioFormat), &(cb->audioFormat)); + initAudioFormatFromMp3DecodeData(&data, &(dc.audioFormat)); + getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat)); - dc->totalTime = data.totalTime; + dc.totalTime = data.totalTime; if (inStream->metaTitle) { if (tag) @@ -1062,12 +1060,12 @@ static int mp3_decode(OutputBuffer * cb, DecoderControl * dc, freeMpdTag(tag); } - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; - while (mp3Read(&data, cb, dc, &replayGainInfo) != DECODE_BREAK) ; - /* send last little bit if not dc->stop */ - if (!dc->stop && data.outputPtr != data.outputBuffer && data.flush) { - sendDataToOutputBuffer(cb, NULL, dc, + while (mp3Read(&data, cb, &replayGainInfo) != DECODE_BREAK) ; + /* send last little bit if not dc.stop */ + if (!dc.stop && data.outputPtr != data.outputBuffer && data.flush) { + sendDataToOutputBuffer(cb, NULL, data.inStream->seekable, data.outputBuffer, data.outputPtr - data.outputBuffer, @@ -1078,9 +1076,9 @@ static int mp3_decode(OutputBuffer * cb, DecoderControl * dc, if (replayGainInfo) freeReplayGainInfo(replayGainInfo); - if (dc->seek && data.muteFrame == MUTEFRAME_SEEK) { + if (dc.seek && data.muteFrame == MUTEFRAME_SEEK) { clearOutputBuffer(cb); - dc->seek = 0; + dc.seek = 0; decoder_wakeup_player(); } diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c index 1e755b95c..fb8c71020 100644 --- a/src/inputPlugins/mp4_plugin.c +++ b/src/inputPlugins/mp4_plugin.c @@ -84,8 +84,7 @@ static uint32_t mp4_inputStreamSeekCallback(void *inStream, uint64_t position) return seekInputStream((InputStream *) inStream, position, SEEK_SET); } -static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, - InputStream * inStream) +static int mp4_decode(OutputBuffer * cb, InputStream * inStream) { mp4ff_t *mp4fh; mp4ff_callback_t *mp4cb; @@ -146,7 +145,7 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, #endif faacDecSetConfiguration(decoder, config); - dc->audioFormat.bits = 16; + dc.audioFormat.bits = 16; mp4Buffer = NULL; mp4BufferSize = 0; @@ -161,8 +160,8 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, return -1; } - dc->audioFormat.sampleRate = sampleRate; - dc->audioFormat.channels = channels; + dc.audioFormat.sampleRate = sampleRate; + dc.audioFormat.channels = channels; file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track); scale = mp4ff_time_scale(mp4fh, track); @@ -176,7 +175,7 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, free(mp4cb); return -1; } - dc->totalTime = ((float)file_time) / scale; + dc.totalTime = ((float)file_time) / scale; numSamples = mp4ff_num_samples(mp4fh, track); @@ -185,13 +184,13 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, seekTable = xmalloc(sizeof(float) * numSamples); for (sampleId = 0; sampleId < numSamples && !eof; sampleId++) { - if (dc->seek) + if (dc.seek) seeking = 1; if (seeking && seekTableEnd > 1 && - seekTable[seekTableEnd] >= dc->seekWhere) { + seekTable[seekTableEnd] >= dc.seekWhere) { int i = 2; - while (seekTable[i] < dc->seekWhere) + while (seekTable[i] < dc.seekWhere) i++; sampleId = i - 1; file_time = seekTable[sampleId]; @@ -213,14 +212,14 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, dur -= offset; file_time += ((float)dur) / scale; - if (seeking && file_time > dc->seekWhere) + if (seeking && file_time > dc.seekWhere) seekPositionFound = 1; if (seeking && seekPositionFound) { seekPositionFound = 0; clearOutputBuffer(cb); seeking = 0; - dc->seek = 0; + dc.seek = 0; decoder_wakeup_player(); } @@ -248,16 +247,16 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, break; } - if (dc->state != DECODE_STATE_DECODE) { + if (dc.state != DECODE_STATE_DECODE) { channels = frameInfo.channels; #ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE scale = frameInfo.samplerate; #endif - dc->audioFormat.sampleRate = scale; - dc->audioFormat.channels = frameInfo.channels; - getOutputAudioFormat(&(dc->audioFormat), + dc.audioFormat.sampleRate = scale; + dc.audioFormat.channels = frameInfo.channels; + getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat)); - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; } if (channels * (unsigned long)(dur + offset) > frameInfo.samples) { @@ -278,10 +277,10 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, sampleBuffer += offset * channels * 2; - sendDataToOutputBuffer(cb, inStream, dc, 1, sampleBuffer, + sendDataToOutputBuffer(cb, inStream, 1, sampleBuffer, sampleBufferLen, file_time, bitRate, NULL); - if (dc->stop) { + if (dc.stop) { eof = 1; break; } @@ -292,12 +291,12 @@ static int mp4_decode(OutputBuffer * cb, DecoderControl * dc, mp4ff_close(mp4fh); free(mp4cb); - if (dc->state != DECODE_STATE_DECODE) + if (dc.state != DECODE_STATE_DECODE) return -1; - if (dc->seek && seeking) { + if (dc.seek && seeking) { clearOutputBuffer(cb); - dc->seek = 0; + dc.seek = 0; decoder_wakeup_player(); } flushOutputBuffer(cb); diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c index 9b6e862ff..867965688 100644 --- a/src/inputPlugins/mpc_plugin.c +++ b/src/inputPlugins/mpc_plugin.c @@ -33,7 +33,6 @@ typedef struct _MpcCallbackData { InputStream *inStream; - DecoderControl *dc; } MpcCallbackData; static mpc_int32_t mpc_read_cb(void *vdata, void *ptr, mpc_int32_t size) @@ -43,10 +42,9 @@ static mpc_int32_t mpc_read_cb(void *vdata, void *ptr, mpc_int32_t size) while (1) { ret = readFromInputStream(data->inStream, ptr, 1, size); - if (ret == 0 && !inputStreamAtEOF(data->inStream) && - (data->dc && !data->dc->stop)) { + if (ret == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop) my_usleep(10000); - } else + else break; } @@ -113,8 +111,7 @@ static inline mpd_sint16 convertSample(MPC_SAMPLE_FORMAT sample) return val; } -static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, - InputStream * inStream) +static int mpc_decode(OutputBuffer * cb, InputStream * inStream) { mpc_decoder decoder; mpc_reader reader; @@ -139,7 +136,6 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, ReplayGainInfo *replayGainInfo = NULL; data.inStream = inStream; - data.dc = dc; reader.read = mpc_read_cb; reader.seek = mpc_seek_cb; @@ -151,7 +147,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, mpc_streaminfo_init(&info); if ((ret = mpc_streaminfo_read(&info, &reader)) != ERROR_CODE_OK) { - if (!dc->stop) { + if (!dc.stop) { ERROR("Not a valid musepack stream\n"); return -1; } @@ -161,20 +157,20 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, mpc_decoder_setup(&decoder, &reader); if (!mpc_decoder_initialize(&decoder, &info)) { - if (!dc->stop) { + if (!dc.stop) { ERROR("Not a valid musepack stream\n"); return -1; } return 0; } - dc->totalTime = mpc_streaminfo_get_length(&info); + dc.totalTime = mpc_streaminfo_get_length(&info); - dc->audioFormat.bits = 16; - dc->audioFormat.channels = info.channels; - dc->audioFormat.sampleRate = info.sample_freq; + dc.audioFormat.bits = 16; + dc.audioFormat.channels = info.channels; + dc.audioFormat.sampleRate = info.sample_freq; - getOutputAudioFormat(&(dc->audioFormat), &(cb->audioFormat)); + getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat)); replayGainInfo = newReplayGainInfo(); replayGainInfo->albumGain = info.gain_album * 0.01; @@ -182,18 +178,18 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, replayGainInfo->trackGain = info.gain_title * 0.01; replayGainInfo->trackPeak = info.peak_title / 32767.0; - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; while (!eof) { - if (dc->seek) { - samplePos = dc->seekWhere * dc->audioFormat.sampleRate; + if (dc.seek) { + samplePos = dc.seekWhere * dc.audioFormat.sampleRate; if (mpc_decoder_seek_sample(&decoder, samplePos)) { clearOutputBuffer(cb); s16 = (mpd_sint16 *) chunk; chunkpos = 0; } else - dc->seekError = 1; - dc->seek = 0; + dc.seekError = 1; + dc.seek = 0; decoder_wakeup_player(); } @@ -202,7 +198,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, ret = mpc_decoder_decode(&decoder, sample_buffer, &vbrUpdateAcc, &vbrUpdateBits); - if (ret <= 0 || dc->stop) { + if (ret <= 0 || dc.stop) { eof = 1; break; } @@ -220,12 +216,12 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, if (chunkpos >= MPC_CHUNK_SIZE) { total_time = ((float)samplePos) / - dc->audioFormat.sampleRate; + dc.audioFormat.sampleRate; bitRate = vbrUpdateBits * - dc->audioFormat.sampleRate / 1152 / 1000; + dc.audioFormat.sampleRate / 1152 / 1000; - sendDataToOutputBuffer(cb, inStream, dc, + sendDataToOutputBuffer(cb, inStream, inStream->seekable, chunk, chunkpos, total_time, @@ -233,7 +229,7 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, chunkpos = 0; s16 = (mpd_sint16 *) chunk; - if (dc->stop) { + if (dc.stop) { eof = 1; break; } @@ -241,13 +237,13 @@ static int mpc_decode(OutputBuffer * cb, DecoderControl * dc, } } - if (!dc->stop && chunkpos > 0) { - total_time = ((float)samplePos) / dc->audioFormat.sampleRate; + if (!dc.stop && chunkpos > 0) { + total_time = ((float)samplePos) / dc.audioFormat.sampleRate; bitRate = - vbrUpdateBits * dc->audioFormat.sampleRate / 1152 / 1000; + vbrUpdateBits * dc.audioFormat.sampleRate / 1152 / 1000; - sendDataToOutputBuffer(cb, NULL, dc, inStream->seekable, + sendDataToOutputBuffer(cb, NULL, inStream->seekable, chunk, chunkpos, total_time, bitRate, replayGainInfo); } @@ -269,7 +265,6 @@ static float mpcGetTime(char *file) MpcCallbackData data; data.inStream = &inStream; - data.dc = NULL; reader.read = mpc_read_cb; reader.seek = mpc_seek_cb; diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index 6638362b6..070404e26 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -56,14 +56,14 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const while (1) { r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes); if (r == 0 && !inputStreamAtEOF(data->inStream) && - !data->dc->stop) + !dc.stop) my_usleep(10000); else break; } *bytes = r; - if (r == 0 && !inputStreamAtEOF(data->inStream) && !data->dc->stop) + if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop) return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; @@ -193,14 +193,14 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(const c_chan++) { u16 = buf[c_chan][c_samp]; uc = (unsigned char *)&u16; - for (i = 0; i < (data->dc->audioFormat.bits / 8); i++) { + for (i = 0; i < (dc.audioFormat.bits / 8); i++) { if (data->chunk_length >= FLAC_CHUNK_SIZE) { if (flacSendChunk(data) < 0) { return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } data->chunk_length = 0; - if (data->dc->seek) { + if (dc.seek) { return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } @@ -336,21 +336,20 @@ static unsigned int oggflac_try_decode(InputStream * inStream) return (ogg_stream_type_detect(inStream) == FLAC) ? 1 : 0; } -static int oggflac_decode(OutputBuffer * cb, DecoderControl * dc, - InputStream * inStream) +static int oggflac_decode(OutputBuffer * cb, InputStream * inStream) { OggFLAC__SeekableStreamDecoder *decoder = NULL; FlacData data; int ret = 0; - init_FlacData(&data, cb, dc, inStream); + init_FlacData(&data, cb, inStream); if (!(decoder = full_decoder_init_and_read_metadata(&data, 0))) { ret = -1; goto fail; } - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; while (1) { OggFLAC__seekable_stream_decoder_process_single(decoder); @@ -358,29 +357,29 @@ static int oggflac_decode(OutputBuffer * cb, DecoderControl * dc, OggFLAC__SEEKABLE_STREAM_DECODER_OK) { break; } - if (dc->seek) { - FLAC__uint64 sampleToSeek = dc->seekWhere * - dc->audioFormat.sampleRate + 0.5; + if (dc.seek) { + FLAC__uint64 sampleToSeek = dc.seekWhere * + dc.audioFormat.sampleRate + 0.5; if (OggFLAC__seekable_stream_decoder_seek_absolute (decoder, sampleToSeek)) { clearOutputBuffer(cb); data.time = ((float)sampleToSeek) / - dc->audioFormat.sampleRate; + dc.audioFormat.sampleRate; data.position = 0; } else - dc->seekError = 1; - dc->seek = 0; + dc.seekError = 1; + dc.seek = 0; decoder_wakeup_player(); } } - if (!dc->stop) { + if (!dc.stop) { oggflacPrintErroredState (OggFLAC__seekable_stream_decoder_get_state(decoder)); OggFLAC__seekable_stream_decoder_finish(decoder); } /* send last little bit */ - if (data.chunk_length > 0 && !dc->stop) { + if (data.chunk_length > 0 && !dc.stop) { flacSendChunk(&data); flushOutputBuffer(data.cb); } diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c index c79e7893c..afcef3e08 100644 --- a/src/inputPlugins/oggvorbis_plugin.c +++ b/src/inputPlugins/oggvorbis_plugin.c @@ -56,7 +56,6 @@ typedef struct _OggCallbackData { InputStream *inStream; - DecoderControl *dc; } OggCallbackData; static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata) @@ -67,7 +66,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata) while (1) { ret = readFromInputStream(data->inStream, ptr, size, nmemb); if (ret == 0 && !inputStreamAtEOF(data->inStream) && - !data->dc->stop) { + !dc.stop) { my_usleep(10000); } else break; @@ -81,7 +80,7 @@ static size_t ogg_read_cb(void *ptr, size_t size, size_t nmemb, void *vdata) static int ogg_seek_cb(void *vdata, ogg_int64_t offset, int whence) { const OggCallbackData *data = (const OggCallbackData *) vdata; - if(data->dc->stop) + if (dc.stop) return -1; return seekInputStream(data->inStream, offset, whence); } @@ -217,8 +216,7 @@ static void putOggCommentsIntoOutputBuffer(OutputBuffer * cb, char *streamName, } /* public */ -static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc, - InputStream * inStream) +static int oggvorbis_decode(OutputBuffer * cb, InputStream * inStream) { OggVorbis_File vf; ov_callbacks callbacks; @@ -236,14 +234,13 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc, const char *errorStr; data.inStream = inStream; - data.dc = dc; callbacks.read_func = ogg_read_cb; callbacks.seek_func = ogg_seek_cb; callbacks.close_func = ogg_close_cb; callbacks.tell_func = ogg_tell_cb; if ((ret = ov_open_callbacks(&data, &vf, NULL, 0, callbacks)) < 0) { - if (!dc->stop) { + if (!dc.stop) { switch (ret) { case OV_EREAD: errorStr = "read error"; @@ -270,19 +267,19 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc, } return 0; } - dc->totalTime = ov_time_total(&vf, -1); - if (dc->totalTime < 0) - dc->totalTime = 0; - dc->audioFormat.bits = 16; + dc.totalTime = ov_time_total(&vf, -1); + if (dc.totalTime < 0) + dc.totalTime = 0; + dc.audioFormat.bits = 16; while (1) { - if (dc->seek) { - if (0 == ov_time_seek_page(&vf, dc->seekWhere)) { + if (dc.seek) { + if (0 == ov_time_seek_page(&vf, dc.seekWhere)) { clearOutputBuffer(cb); chunkpos = 0; } else - dc->seekError = 1; - dc->seek = 0; + dc.seekError = 1; + dc.seek = 0; decoder_wakeup_player(); } ret = ov_read(&vf, chunk + chunkpos, @@ -291,12 +288,12 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc, if (current_section != prev_section) { /*printf("new song!\n"); */ vorbis_info *vi = ov_info(&vf, -1); - dc->audioFormat.channels = vi->channels; - dc->audioFormat.sampleRate = vi->rate; - if (dc->state == DECODE_STATE_START) { - getOutputAudioFormat(&(dc->audioFormat), + dc.audioFormat.channels = vi->channels; + dc.audioFormat.sampleRate = vi->rate; + if (dc.state == DECODE_STATE_START) { + getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat)); - dc->state = DECODE_STATE_DECODE; + dc.state = DECODE_STATE_DECODE; } comments = ov_comment(&vf, -1)->user_comments; putOggCommentsIntoOutputBuffer(cb, inStream->metaName, @@ -319,20 +316,20 @@ static int oggvorbis_decode(OutputBuffer * cb, DecoderControl * dc, if ((test = ov_bitrate_instant(&vf)) > 0) { bitRate = test / 1000; } - sendDataToOutputBuffer(cb, inStream, dc, + sendDataToOutputBuffer(cb, inStream, inStream->seekable, chunk, chunkpos, ov_pcm_tell(&vf) / - dc->audioFormat.sampleRate, + dc.audioFormat.sampleRate, bitRate, replayGainInfo); chunkpos = 0; - if (dc->stop) + if (dc.stop) break; } } - if (!dc->stop && chunkpos > 0) { - sendDataToOutputBuffer(cb, NULL, dc, inStream->seekable, + if (!dc.stop && chunkpos > 0) { + sendDataToOutputBuffer(cb, NULL, inStream->seekable, chunk, chunkpos, ov_time_tell(&vf), bitRate, replayGainInfo); diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c index c46cdeb75..bae5f6acb 100644 --- a/src/inputPlugins/wavpack_plugin.c +++ b/src/inputPlugins/wavpack_plugin.c @@ -128,7 +128,7 @@ static void format_samples_float(int Bps, void *buffer, uint32_t samcnt) * This does the main decoding thing. * Requires an already opened WavpackContext. */ -static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc, +static void wavpack_decode(OutputBuffer *cb, WavpackContext *wpc, int canseek, ReplayGainInfo *replayGainInfo) { @@ -140,12 +140,12 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc, int position, outsamplesize; int Bps; - dc->audioFormat.sampleRate = WavpackGetSampleRate(wpc); - dc->audioFormat.channels = WavpackGetReducedChannels(wpc); - dc->audioFormat.bits = WavpackGetBitsPerSample(wpc); + dc.audioFormat.sampleRate = WavpackGetSampleRate(wpc); + dc.audioFormat.channels = WavpackGetReducedChannels(wpc); + dc.audioFormat.bits = WavpackGetBitsPerSample(wpc); - if (dc->audioFormat.bits > 16) - dc->audioFormat.bits = 16; + if (dc.audioFormat.bits > 16) + dc.audioFormat.bits = 16; if ((WavpackGetMode(wpc) & MODE_FLOAT) == MODE_FLOAT) format_samples = format_samples_float; @@ -163,40 +163,40 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc, outsamplesize = Bps; if (outsamplesize > 2) outsamplesize = 2; - outsamplesize *= dc->audioFormat.channels; + outsamplesize *= dc.audioFormat.channels; - samplesreq = sizeof(chunk) / (4 * dc->audioFormat.channels); + samplesreq = sizeof(chunk) / (4 * dc.audioFormat.channels); - getOutputAudioFormat(&(dc->audioFormat), &(cb->audioFormat)); + getOutputAudioFormat(&(dc.audioFormat), &(cb->audioFormat)); - dc->totalTime = (float)allsamples / dc->audioFormat.sampleRate; - dc->state = DECODE_STATE_DECODE; - dc->seekable = canseek; + dc.totalTime = (float)allsamples / dc.audioFormat.sampleRate; + dc.state = DECODE_STATE_DECODE; + dc.seekable = canseek; position = 0; do { - if (dc->seek) { + if (dc.seek) { if (canseek) { int where; clearOutputBuffer(cb); - where = dc->seekWhere * - dc->audioFormat.sampleRate; + where = dc.seekWhere * + dc.audioFormat.sampleRate; if (WavpackSeekSample(wpc, where)) position = where; else - dc->seekError = 1; + dc.seekError = 1; } else { - dc->seekError = 1; + dc.seekError = 1; } - dc->seek = 0; + dc.seek = 0; decoder_wakeup_player(); } - if (dc->stop) + if (dc.stop) break; samplesgot = WavpackUnpackSamples(wpc, @@ -206,12 +206,12 @@ static void wavpack_decode(OutputBuffer *cb, DecoderControl *dc, 1000 + 0.5); position += samplesgot; file_time = (float)position / - dc->audioFormat.sampleRate; + dc.audioFormat.sampleRate; format_samples(Bps, chunk, - samplesgot * dc->audioFormat.channels); + samplesgot * dc.audioFormat.channels); - sendDataToOutputBuffer(cb, NULL, dc, 0, chunk, + sendDataToOutputBuffer(cb, NULL, 0, chunk, samplesgot * outsamplesize, file_time, bitrate, replayGainInfo); @@ -442,8 +442,7 @@ static unsigned int wavpack_trydecode(InputStream *is) /* * Decodes a stream. */ -static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc, - InputStream *is) +static int wavpack_streamdecode(OutputBuffer *cb, InputStream *is) { char error[ERRORLEN]; WavpackContext *wpc; @@ -462,7 +461,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc, err = 1; /* - * As we use dc->utf8url, this function will be bad for + * As we use dc.utf8url, this function will be bad for * single files. utf8url is not absolute file path :/ */ utf8url = get_song_url(tmp, pc.current_song); @@ -507,7 +506,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc, break; } - if (dc->stop) { + if (dc.stop) { break; } @@ -542,7 +541,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc, return -1; } - wavpack_decode(cb, dc, wpc, canseek, NULL); + wavpack_decode(cb, wpc, canseek, NULL); WavpackCloseFile(wpc); if (wvc_url != NULL) { @@ -557,7 +556,7 @@ static int wavpack_streamdecode(OutputBuffer *cb, DecoderControl *dc, /* * Decodes a file. */ -static int wavpack_filedecode(OutputBuffer *cb, DecoderControl *dc, char *fname) +static int wavpack_filedecode(OutputBuffer *cb, char *fname) { char error[ERRORLEN]; WavpackContext *wpc; @@ -573,7 +572,7 @@ static int wavpack_filedecode(OutputBuffer *cb, DecoderControl *dc, char *fname) replayGainInfo = wavpack_replaygain(wpc); - wavpack_decode(cb, dc, wpc, 1, replayGainInfo); + wavpack_decode(cb, wpc, 1, replayGainInfo); if (replayGainInfo) freeReplayGainInfo(replayGainInfo); |