diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2006-10-17 03:16:11 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2006-10-17 03:16:11 +0000 |
commit | e9f51778ef4784ae42ff8d13b7d0f3ccfc49bead (patch) | |
tree | 613b914adc6fce0ba4575ee027495bbfca441e1b /src/audioOutput.c | |
parent | e1d1a703f1d09d87a79a54c2f4485367aa0a0c3b (diff) | |
download | mpd-e9f51778ef4784ae42ff8d13b7d0f3ccfc49bead.tar.gz mpd-e9f51778ef4784ae42ff8d13b7d0f3ccfc49bead.tar.xz mpd-e9f51778ef4784ae42ff8d13b7d0f3ccfc49bead.zip |
an attempted fix for bug 1368
- don't close and reopen an audioOutput when it has a fixed output format, and closing and reopening the device is unneccessary when the input audio format changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@4908 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/audioOutput.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/src/audioOutput.c b/src/audioOutput.c index f4750b8df..111531ba7 100644 --- a/src/audioOutput.c +++ b/src/audioOutput.c @@ -155,33 +155,38 @@ int initAudioOutput(AudioOutput *ao, ConfigParam * param) int openAudioOutput(AudioOutput * audioOutput, AudioFormat * audioFormat) { - int ret; + int ret = 0; - if (audioOutput->open) { - if (cmpAudioFormat(audioFormat, &audioOutput->inAudioFormat) - == 0) { + if (audioOutput->open) + { + if (0==cmpAudioFormat(audioFormat, &audioOutput->inAudioFormat)) + { return 0; } - closeAudioOutput(audioOutput); } copyAudioFormat(&audioOutput->inAudioFormat, audioFormat); - if (audioOutput->convertAudioFormat) { + if (audioOutput->convertAudioFormat) + { copyAudioFormat(&audioOutput->outAudioFormat, &audioOutput->reqAudioFormat); - } else { + } + else + { copyAudioFormat(&audioOutput->outAudioFormat, &audioOutput->inAudioFormat); + if (audioOutput->open) closeAudioOutput(audioOutput); } - ret = audioOutput->openDeviceFunc(audioOutput); + if (!audioOutput->open) + { + ret = audioOutput->openDeviceFunc(audioOutput); + } - if (cmpAudioFormat(&audioOutput->inAudioFormat, - &audioOutput->outAudioFormat) == 0) { - audioOutput->sameInAndOutFormats = 1; - } else - audioOutput->sameInAndOutFormats = 0; + audioOutput->sameInAndOutFormats = + !cmpAudioFormat(&audioOutput->inAudioFormat, + &audioOutput->outAudioFormat); return ret; } @@ -190,11 +195,10 @@ static void convertAudioFormat(AudioOutput * audioOutput, char **chunkArgPtr, int *sizeArgPtr) { int size = - pcm_sizeOfOutputBufferForAudioFormatConversion(& - (audioOutput-> - inAudioFormat), -*sizeArgPtr, -&(audioOutput->outAudioFormat)); + pcm_sizeOfOutputBufferForAudioFormatConversion( + &(audioOutput->inAudioFormat), + *sizeArgPtr, + &(audioOutput->outAudioFormat)); if (size > audioOutput->convBufferLen) { audioOutput->convBuffer = @@ -202,8 +206,10 @@ static void convertAudioFormat(AudioOutput * audioOutput, char **chunkArgPtr, audioOutput->convBufferLen = size; } - pcm_convertAudioFormat(&(audioOutput->inAudioFormat), *chunkArgPtr, - *sizeArgPtr, &(audioOutput->outAudioFormat), + pcm_convertAudioFormat(&(audioOutput->inAudioFormat), + *chunkArgPtr, + *sizeArgPtr, + &(audioOutput->outAudioFormat), audioOutput->convBuffer); *sizeArgPtr = size; |