Skip to content

Commit c908e9b

Browse files
author
Clement Champetier
committed
AudioGenerator: check channel layout of the input frame to be able to copy silence
1 parent 243bb78 commit c908e9b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/AvTranscoder/decoder/AudioGenerator.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ void AudioGenerator::setNextFrame(Frame& inputFrame)
3838

3939
bool AudioGenerator::decodeNextFrame(Frame& frameBuffer)
4040
{
41+
// Check channel layout of the given frame to be able to copy audio data to it.
42+
// @see Frame.copyData method
43+
if(frameBuffer.getAVFrame().channel_layout == 0)
44+
{
45+
const size_t channelLayout = av_get_default_channel_layout(frameBuffer.getAVFrame().channels);
46+
LOG_WARN("Channel layout en the audio frame is not set. Set it to '" << channelLayout << "' to be able to copy silence data.")
47+
av_frame_set_channel_layout(&frameBuffer.getAVFrame(), channelLayout);
48+
}
49+
4150
// Generate silent
4251
if(!_inputFrame)
4352
{

0 commit comments

Comments
 (0)