Skip to content

Commit

Permalink
[gfx] Fix audio textures continually recreating fft objects
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jun 11, 2024
1 parent b1bbb09 commit 70766d2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/plugins/score-plugin-gfx/Gfx/GfxExecutionAction.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <Gfx/GfxExecContext.hpp>

#include <ossia/dataflow/audio_port.hpp>
#include <ossia/detail/algorithms.hpp>

namespace Gfx
{

Expand All @@ -20,6 +20,18 @@ GfxExecutionAction::GfxExecutionAction(GfxContext& w)
}
}

struct clear_msg_visitor
{
void operator()(const auto& whatever) { }
void operator()(ossia::audio_vector& vec)
{
while(!vec.empty())
{
ossia::audio_buffer_pool::instance().release(std::move(vec.back()));
vec.pop_back();
}
}
};
score::gfx::Message GfxExecutionAction::allocateMessage(int inputs)
{
score::gfx::Message m{
Expand All @@ -28,6 +40,11 @@ score::gfx::Message GfxExecutionAction::allocateMessage(int inputs)
.input = ui->m_buffers.acquire(),
};

for(auto& in : m.input)
{
visit(clear_msg_visitor{}, in);
}

m.input.clear();
m.input.reserve(8);
return m;
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/score-plugin-gfx/Gfx/Graph/RenderedISFNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,8 +958,10 @@ void SimpleRenderedISFNode::update(RenderList& renderer, QRhiResourceUpdateBatch
n.standardUBO.passIndex = 0;

// Update audio textures
if(!n.m_audio_textures.empty())
if(!n.m_audio_textures.empty() && !m_audioTex)
{
m_audioTex.emplace();
}

for(auto& audio : n.m_audio_textures)
{
Expand Down

0 comments on commit 70766d2

Please sign in to comment.