Skip to content

Commit

Permalink
fail early in case of empty audiobuffer queue
Browse files Browse the repository at this point in the history
  • Loading branch information
yezhan10 committed Sep 17, 2024
1 parent b6423bb commit aab5a19
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
13 changes: 6 additions & 7 deletions src/g711/pcmacodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ int PCMADecoder::Decode(const AudioFrame::const_shared& audioFrame)

AudioBuffer::shared PCMADecoder::GetDecodedAudioFrame()
{
if(!audioBufferQueue.empty())
{
auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
return {};
if(audioBufferQueue.empty())
return {};

auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
13 changes: 6 additions & 7 deletions src/g711/pcmucodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ int PCMUDecoder::Decode(const AudioFrame::const_shared& audioFrame)

AudioBuffer::shared PCMUDecoder::GetDecodedAudioFrame()
{
if(!audioBufferQueue.empty())
{
auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
return {};
if(audioBufferQueue.empty())
return {};

auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}

13 changes: 6 additions & 7 deletions src/g722/g722codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ int G722Decoder::Decode(const AudioFrame::const_shared& audioFrame)

AudioBuffer::shared G722Decoder::GetDecodedAudioFrame()
{
if(!audioBufferQueue.empty())
{
auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
return {};
if(audioBufferQueue.empty())
return {};

auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
13 changes: 6 additions & 7 deletions src/gsm/gsmcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,10 @@ int GSMDecoder::Decode(const AudioFrame::const_shared& audioFrame)

AudioBuffer::shared GSMDecoder::GetDecodedAudioFrame()
{
if(!audioBufferQueue.empty())
{
auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
return {};
if(audioBufferQueue.empty())
return {};

auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
13 changes: 6 additions & 7 deletions src/opus/OpusDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ int OpusDecoder::Decode(const AudioFrame::const_shared& audioFrame)

AudioBuffer::shared OpusDecoder::GetDecodedAudioFrame()
{
if(!audioBufferQueue.empty())
{
auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}
return {};
if(audioBufferQueue.empty())
return {};

auto audioBuffer = audioBufferQueue.front();
audioBufferQueue.pop();
return audioBuffer;
}

0 comments on commit aab5a19

Please sign in to comment.