Skip to content

Commit 27a65ac

Browse files
author
Clement Champetier
committed
AudioDecoder: fixed channel layout value after decoding
After calling 'avcodec_decode_audio4', sometimes the channel layout of the frame is set to 0. I could be a problem in the next steps of the process.
1 parent e623e29 commit 27a65ac

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ void AudioDecoder::setupDecoder(const ProfileLoader::Profile& profile)
7878
bool AudioDecoder::decodeNextFrame(Frame& frameBuffer)
7979
{
8080
bool decodeNextFrame = false;
81+
const size_t channelLayout = frameBuffer.getAVFrame().channel_layout;
8182

8283
if(!_isSetup)
8384
setupDecoder();
@@ -100,6 +101,9 @@ bool AudioDecoder::decodeNextFrame(Frame& frameBuffer)
100101
throw std::runtime_error("An error occurred during audio decoding: " + getDescriptionFromErrorCode(ret));
101102
}
102103

104+
// fixed channel layout value after decoding
105+
frameBuffer.getAVFrame().channel_layout = channelLayout;
106+
103107
// if no frame could be decompressed
104108
if(!nextPacketRead && ret == 0 && got_frame == 0)
105109
decodeNextFrame = false;

0 commit comments

Comments
 (0)