From e8fd51a63141efad8582c69b47817a6771dbe1e7 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Sun, 4 Jan 2015 02:28:11 +0100 Subject: Fix audio format negotiation when one or more formats are disabled --- decoder/LAVAudio/LAVAudio.cpp | 3 ++- decoder/LAVAudio/LAVAudio.h | 2 +- decoder/LAVAudio/Media.cpp | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'decoder') diff --git a/decoder/LAVAudio/LAVAudio.cpp b/decoder/LAVAudio/LAVAudio.cpp index fc0308fe..d9345246 100644 --- a/decoder/LAVAudio/LAVAudio.cpp +++ b/decoder/LAVAudio/LAVAudio.cpp @@ -982,9 +982,10 @@ HRESULT CLAVAudio::GetMediaType(int iPosition, CMediaType *pMediaType) if (iPosition == 1) { lav_sample_fmt = SampleFormat_16; bits = 16; + } else { + lav_sample_fmt = GetBestAvailableSampleFormat(lav_sample_fmt, &bits, TRUE); } - lav_sample_fmt = GetBestAvailableSampleFormat(lav_sample_fmt, TRUE); *pMediaType = CreateMediaType(lav_sample_fmt, nSamplesPerSec, nChannels, dwChannelMask, bits); } return S_OK; diff --git a/decoder/LAVAudio/LAVAudio.h b/decoder/LAVAudio/LAVAudio.h index d0ad9809..13b41e09 100644 --- a/decoder/LAVAudio/LAVAudio.h +++ b/decoder/LAVAudio/LAVAudio.h @@ -229,7 +229,7 @@ private: HRESULT Create61Conformity(DWORD dwLayout); HRESULT Create71Conformity(DWORD dwLayout); - LAVAudioSampleFormat GetBestAvailableSampleFormat(LAVAudioSampleFormat inFormat, BOOL bNoFallback = FALSE); + LAVAudioSampleFormat GetBestAvailableSampleFormat(LAVAudioSampleFormat inFormat, int *bits = NULL, BOOL bNoFallback = FALSE); HRESULT Truncate32Buffer(BufferDetails *buffer); HRESULT PadTo32(BufferDetails *buffer); diff --git a/decoder/LAVAudio/Media.cpp b/decoder/LAVAudio/Media.cpp index d72dbaba..de68e9b7 100644 --- a/decoder/LAVAudio/Media.cpp +++ b/decoder/LAVAudio/Media.cpp @@ -714,7 +714,7 @@ static LAVAudioSampleFormat sampleFormatMapping[5][5] = { { SampleFormat_FP32, SampleFormat_24, SampleFormat_32, SampleFormat_16, SampleFormat_U8 }, // SampleFormat_FP32 }; -LAVAudioSampleFormat CLAVAudio::GetBestAvailableSampleFormat(LAVAudioSampleFormat inFormat, BOOL bNoFallback) +LAVAudioSampleFormat CLAVAudio::GetBestAvailableSampleFormat(LAVAudioSampleFormat inFormat, int *bits, BOOL bNoFallback) { ASSERT(inFormat >= 0 && inFormat < SampleFormat_Bitstream); @@ -729,5 +729,8 @@ LAVAudioSampleFormat CLAVAudio::GetBestAvailableSampleFormat(LAVAudioSampleForma } } + if (bits && outFormat != inFormat) + *bits = get_byte_per_sample(outFormat) << 3; + return outFormat; } -- cgit v1.2.3