Skip to content

Commit

Permalink
Fix bug when recreating AudioGraph after destroy()
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Feb 18, 2024
1 parent eece853 commit 770126c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions source/src/core/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,28 @@ void AudioGraph::clear()

void AudioGraph::destroy()
{
AudioOut_Abstract *audioout = (AudioOut_Abstract *) this->output.get();
if (audioout)
{
audioout->destroy();
}
if (shared_graph == this)
// Clear output when destroyed to ensure that multiply destroy() calls won't crash
if (this->output)
{
shared_graph = nullptr;
AudioOut_Abstract *audioout = (AudioOut_Abstract *) this->output.get();
if (audioout)
{
audioout->destroy();
}
if (shared_graph == this)
{
shared_graph = nullptr;
}
this->output = nullptr;
}
}

AudioGraph::~AudioGraph() { this->destroy(); }
AudioGraph::~AudioGraph()
{
// When the AudioGraph is deallocated (which happens automatically at the end of a Python script),
// ensure it is destroyed.
this->destroy();
}

void AudioGraph::wait(float time)
{
Expand Down

0 comments on commit 770126c

Please sign in to comment.