Fix Opus audio sample rate to 48kHz

This commit is contained in:
Sérgio Agostinho 2018-01-25 14:42:59 +00:00 committed by Lukas Dürrenberger
parent aaae80e7f4
commit 4008cbfe6a

View File

@ -119,9 +119,12 @@ bool SoundFileReaderOpus::open(InputStream& stream, Info& info)
// Retrieve the music attributes
const OpusHead* opusHead = op_head(m_opus, -1);
info.channelCount = opusHead->channel_count;
info.sampleRate = opusHead->input_sample_rate;
info.sampleCount = static_cast<std::size_t>(op_pcm_total(m_opus, -1) * opusHead->channel_count);
// All Opus audio is encoded at 48kHz
// https://opus-codec.org/docs/opusfile_api-0.5/structOpusHead.html#a73b80a913eca33d829f1667caee80d9e
info.sampleRate = 48000;
// We must keep the channel count for the seek function
m_channelCount = info.channelCount;