aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-10 14:06:23 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-10 14:06:23 +0000
commit7626d9a547e9a8dfadbcf0dc148fcef4e61bb2cd (patch)
tree99abd91a2aee35d924476a8188c6b3628f72008e /src/outputBuffer.c
parent9dd098f09b84fadce60a779a2f2daa0e904e94d2 (diff)
downloadmpd-7626d9a547e9a8dfadbcf0dc148fcef4e61bb2cd.tar.gz
mpd-7626d9a547e9a8dfadbcf0dc148fcef4e61bb2cd.tar.xz
mpd-7626d9a547e9a8dfadbcf0dc148fcef4e61bb2cd.zip
more little bits of code in prep for resample/audioFormat conversion,
now to just write the actual audioFormat conversion code! git-svn-id: https://svn.musicpd.org/mpd/trunk@970 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/outputBuffer.c')
-rw-r--r--src/outputBuffer.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 1861fe45a..615139231 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -38,10 +38,32 @@ void flushOutputBuffer(OutputBuffer * cb) {
}
int sendDataToOutputBuffer(OutputBuffer * cb, DecoderControl * dc,
- char * data, long datalen, float time, mpd_uint16 bitRate)
+ char * dataIn, long dataInLen, float time, mpd_uint16 bitRate)
{
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)
+ {
+ data = dataIn;
+ datalen = dataInLen;
+ }
+ else {
+ datalen = pcm_sizeOfOutputBufferForAudioFormatConversion(
+ &(dc->audioFormat), dataIn, dataInLen,
+ &(cb->audioFormat));
+ if(datalen > convBufferLen) {
+ convBuffer = realloc(convBuffer,datalen);
+ convBufferLen = datalen;
+ }
+ data = convBuffer;
+ pcm_convertAudioFormat(&(dc->audioFormat), dataIn, dataInLen,
+ &(cb->audioFormat),data);
+ }
while(datalen) {
if(currentChunk != cb->end) {