diff options
author | Andreas Claesson <andreas.claesson@gmail.com> | 2005-05-22 21:40:23 +0000 |
---|---|---|
committer | Andreas Claesson <andreas.claesson@gmail.com> | 2005-05-22 21:40:23 +0000 |
commit | 422410c46de81cec8872a9b91d07a7c9eca96b82 (patch) | |
tree | 36597b9d2d6c487d7becf01fba056e1dda23ff6c /src/outputBuffer.c | |
parent | c2616b44581f9cef1509a91ca5eb663ed9f0db1b (diff) | |
download | mpd-422410c46de81cec8872a9b91d07a7c9eca96b82.tar.gz mpd-422410c46de81cec8872a9b91d07a7c9eca96b82.tar.xz mpd-422410c46de81cec8872a9b91d07a7c9eca96b82.zip |
Addin floating point modifications
git-svn-id: https://svn.musicpd.org/mpd/branches/ancl@3274 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/outputBuffer.c')
-rw-r--r-- | src/outputBuffer.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c index e52c6e1a4..ff15a7795 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -62,19 +62,21 @@ void flushOutputBuffer(OutputBuffer * cb) { } } -int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream, - DecoderControl * dc, int seekable, char * dataIn, - long dataInLen, float time, mpd_uint16 bitRate, +int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream, + DecoderControl * dc, int seekable, char * dataIn, + long dataInLen, float time, mpd_uint16 bitRate, ReplayGainInfo * replayGainInfo) { - mpd_uint16 dataToSend; + mpd_uint16 dataToSend; mpd_uint16 chunkLeft; char * data; size_t datalen; static char * convBuffer = NULL; static long convBufferLen = 0; - if(memcmp(&(cb->audioFormat),&(dc->audioFormat),sizeof(AudioFormat))==0) + /* make sure the data is in the internal format */ + getInternalAudioFormat(&(dc->audioFormat), &(cb->audioFormat)); + if(cmpAudioFormat(&(dc->audioFormat), &(cb->audioFormat)) == 0) { data = dataIn; datalen = dataInLen; @@ -91,34 +93,34 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream, pcm_convertAudioFormat(&(dc->audioFormat), dataIn, dataInLen, &(cb->audioFormat),data); } - + if(replayGainInfo) { doReplayGain(replayGainInfo, data, datalen, &cb->audioFormat); } - while(datalen) { + while(datalen) { if(currentChunk != cb->end) { - int next = cb->end+1; - if(next>=buffered_chunks) { - next = 0; - } - while(cb->begin==next && !dc->stop) { - if(dc->seek) { - if(seekable) { - return OUTPUT_BUFFER_DC_SEEK; - } - else { - dc->seekError = 1; - dc->seek = 0; - } - } - if(!inStream || - bufferInputStream(inStream) <= 0) - { - my_usleep(10000); - } + int next = cb->end+1; + if(next>=buffered_chunks) { + next = 0; + } + while(cb->begin==next && !dc->stop) { + if(dc->seek) { + if(seekable) { + return OUTPUT_BUFFER_DC_SEEK; + } + else { + dc->seekError = 1; + dc->seek = 0; + } + } + if(!inStream || + bufferInputStream(inStream) <= 0) + { + my_usleep(10000); + } } - if(dc->stop) return OUTPUT_BUFFER_DC_STOP; + if(dc->stop) return OUTPUT_BUFFER_DC_STOP; currentChunk = cb->end; cb->chunkSize[currentChunk] = 0; @@ -127,24 +129,24 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream, cb->metaChunk[currentChunk] = currentMetaChunk; } else cb->metaChunk[currentChunk] = -1; - cb->bitRate[currentChunk] = bitRate; - cb->times[currentChunk] = time; + cb->bitRate[currentChunk] = bitRate; + cb->times[currentChunk] = time; } chunkLeft = CHUNK_SIZE-cb->chunkSize[currentChunk]; - dataToSend = datalen > chunkLeft ? chunkLeft : datalen; + dataToSend = datalen > chunkLeft ? chunkLeft : datalen; - memcpy(cb->chunks+currentChunk*CHUNK_SIZE+ - cb->chunkSize[currentChunk], - data, dataToSend); - cb->chunkSize[currentChunk]+= dataToSend; - datalen-= dataToSend; - data+= dataToSend; + memcpy(cb->chunks+currentChunk*CHUNK_SIZE+ + cb->chunkSize[currentChunk], + data, dataToSend); + cb->chunkSize[currentChunk]+= dataToSend; + datalen-= dataToSend; + data+= dataToSend; if(cb->chunkSize[currentChunk] == CHUNK_SIZE) { flushOutputBuffer(cb); } - } + } return 0; } |