From 7626d9a547e9a8dfadbcf0dc148fcef4e61bb2cd Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Mon, 10 May 2004 14:06:23 +0000 Subject: 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 --- src/audio.c | 2 -- src/outputBuffer.c | 24 +++++++++++++++++++++++- src/pcm_utils.c | 19 ++++++++++++++++++- src/pcm_utils.h | 10 ++++++---- 4 files changed, 47 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/audio.c b/src/audio.c index 9e80c6762..de5296f2e 100644 --- a/src/audio.c +++ b/src/audio.c @@ -167,7 +167,6 @@ void initAudioConfig() { } switch(audio_configFormat->bits) { - case 8: case 16: break; default: @@ -184,7 +183,6 @@ void initAudioConfig() { } switch(audio_configFormat->channels) { - case 1: case 2: break; default: 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) { diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 3d39b20e3..741cb3d7b 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -136,4 +136,21 @@ void pcm_mix(char * buffer1, char * buffer2, size_t bufferSize1, pcm_add(buffer1,buffer2,bufferSize1,bufferSize2,vol1,1000-vol1,format); } -/* vim:set shiftwidth=4 tabstop=8 expandtab: */ + +void pcm_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t + inSize, AudioFormat * outFormat, char * outBuffer) +{ + abort(); + + return; +} + +size_t pcm_sizeOfOutputBufferForAudioFormatConversion(AudioFormat * inFormat, + char * inBuffer, size_t inSize, AudioFormat * outFormat) +{ + abort(); + + return 0; +} + +/* vim:set shiftwidth=8 tabstop=8 expandtab: */ diff --git a/src/pcm_utils.h b/src/pcm_utils.h index 839005ccf..bf1e68799 100644 --- a/src/pcm_utils.h +++ b/src/pcm_utils.h @@ -33,8 +33,10 @@ void pcm_volumeChange(char * buffer, int bufferSize, AudioFormat * format, void pcm_mix(char * buffer1, char * buffer2, size_t bufferSize1, size_t bufferSize2, AudioFormat * format, float portion1); -void pmc_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t - inSize, size_t * inLeft, AudioFormat * outFormat, - char * outBuffer, size_t outSize, size_t * outLeft); +void pcm_convertAudioFormat(AudioFormat * inFormat, char * inBuffer, size_t + inSize, AudioFormat * outFormat, char * outBuffer); + +size_t pcm_sizeOfOutputBufferForAudioFormatConversion(AudioFormat * inFormat, + char * inBuffer, size_t inSize, AudioFormat * outFormat); #endif -/* vim:set shiftwidth=4 tabstop=8 expandtab: */ +/* vim:set shiftwidth=8 tabstop=8 expandtab: */ -- cgit v1.2.3