diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-01-04 04:28:11 +0300 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2015-01-04 04:28:11 +0300 |
commit | e8fd51a63141efad8582c69b47817a6771dbe1e7 (patch) | |
tree | 5f82e730adf78ef2f43e4e73d9ed2c050da3db05 /decoder | |
parent | cd9344ce6de708d02beb9e88304ba73639ca55a3 (diff) |
Fix audio format negotiation when one or more formats are disabled
Diffstat (limited to 'decoder')
-rw-r--r-- | decoder/LAVAudio/LAVAudio.cpp | 3 | ||||
-rw-r--r-- | decoder/LAVAudio/LAVAudio.h | 2 | ||||
-rw-r--r-- | decoder/LAVAudio/Media.cpp | 5 |
3 files changed, 7 insertions, 3 deletions
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; } |