Skip to content

Commit

Permalink
Use unique_ptr for m_outBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Aug 11, 2024
1 parent 12b9de4 commit 261642d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/AudioPortAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class AudioPortAudio : public AudioDevice

bool m_wasPAInitError;

SampleFrame* m_outBuf;
std::unique_ptr<SampleFrame[]> m_outBuf;
std::size_t m_outBufPos;
fpp_t m_outBufSize;

Expand Down
5 changes: 2 additions & 3 deletions src/core/audio/AudioPortAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ AudioPortAudio::AudioPortAudio(bool& successful, AudioEngine* engine)
engine)
, m_paStream(nullptr)
, m_wasPAInitError(false)
, m_outBuf(new SampleFrame[engine->framesPerPeriod()])
, m_outBuf(std::make_unique<SampleFrame[]>(engine->framesPerPeriod()))
, m_outBufPos(0)
, m_outBufSize(engine->framesPerPeriod())
{
Expand Down Expand Up @@ -139,7 +139,6 @@ AudioPortAudio::~AudioPortAudio()
{
Pa_Terminate();
}
delete[] m_outBuf;
}


Expand Down Expand Up @@ -186,7 +185,7 @@ int AudioPortAudio::processCallback(const float* inputBuffer, float* outputBuffe
{
if( m_outBufPos == 0 )
{
const fpp_t frames = getNextBuffer( m_outBuf );
const fpp_t frames = getNextBuffer(m_outBuf.get());
if( !frames )
{
m_stopped = true;
Expand Down

0 comments on commit 261642d

Please sign in to comment.