Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
gpu_audio_node.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5
7
8namespace pulp::gpu_audio {
9
40
45 std::string name;
46 uint32_t input_channels = 0;
47 uint32_t output_channels = 0;
48 uint32_t block_size = 0;
49 uint32_t sample_rate = 0;
52 uint32_t latency_blocks = 1;
53
54 // Both default to FAILING CLOSED. A node that says nothing about its miss
55 // behavior gets a bounded, obvious dropout — not a timeline break, and not a
56 // CPU fallback it never implemented. Passing audio through on a miss has to
57 // be a deliberate, stated choice, because a node author who never thought
58 // about misses is exactly the author who has not made the fallback correct.
61
67 std::uint32_t worker_pipeline_blocks = 0;
68};
69
70} // namespace pulp::gpu_audio
71
72// After MissPolicy: the status header forward-declares it, and the class below
73// needs GpuAudioStatus complete for status_snapshot().
75
76namespace pulp::gpu_audio {
77
78namespace detail {
79struct RealtimeGpuNodeBinding;
80} // namespace detail
81
93public:
94 virtual ~GpuAudioNode() = default;
95
97
99 virtual bool prepare() = 0;
100
107 virtual bool cpu_fallback_prepared() const noexcept {
108 return false;
109 }
110
114 uint32_t n) = 0;
115
121 virtual void prime_fallback(const audio::BufferView<const float>& /*input*/,
122 uint32_t /*n*/) noexcept {}
123
134 uint32_t n) noexcept {
135 const uint32_t ch = output.num_channels() < input.num_channels()
136 ? output.num_channels()
137 : input.num_channels();
138 for (uint32_t c = 0; c < ch; ++c) {
139 const float* src = input.channel_ptr(c);
140 float* dst = output.channel_ptr(c);
141 for (uint32_t i = 0; i < n; ++i) dst[i] = src[i];
142 }
143 }
144
145 // Appended virtuals: new hooks go after every existing one so established
146 // vtable slots keep their positions (tools/scripts/node_abi_gate.py).
147
150 virtual GpuAudioStatus status_snapshot() const noexcept {
151 return {};
152 }
153
157 virtual bool release_bounded(std::uint64_t /*budget_ns*/) noexcept {
158 return true;
159 }
160
165 virtual bool bind_realtime_path(detail::RealtimeGpuNodeBinding& /*binding*/) noexcept {
166 return false;
167 }
168};
169
170} // namespace pulp::gpu_audio
Non-owning view over multi-channel audio sample data.
Definition buffer.hpp:30
A unit of audio work the transport schedules onto a non-real-time worker.
Definition gpu_audio_node.hpp:92
virtual bool bind_realtime_path(detail::RealtimeGpuNodeBinding &) noexcept
Private transport hook, not for node authors: a node that the GPU audio transport drives through a st...
Definition gpu_audio_node.hpp:165
virtual ~GpuAudioNode()=default
virtual void process_cpu_fallback(const audio::BufferView< const float > &input, audio::BufferView< float > &output, uint32_t n) noexcept
RT-safe fallback.
Definition gpu_audio_node.hpp:132
virtual bool release_bounded(std::uint64_t) noexcept
Host thread, audio stopped.
Definition gpu_audio_node.hpp:157
virtual GpuAudioStatus status_snapshot() const noexcept
Host/UI thread.
Definition gpu_audio_node.hpp:150
virtual void process_block(const audio::BufferView< const float > &input, audio::BufferView< float > &output, uint32_t n)=0
Non-RT worker context. Process exactly one block (n == block_size).
virtual GpuAudioNodeDescriptor descriptor() const =0
virtual bool prepare()=0
Non-RT. Allocate/compile/upload static data here.
virtual void prime_fallback(const audio::BufferView< const float > &, uint32_t) noexcept
RT-safe.
Definition gpu_audio_node.hpp:121
virtual bool cpu_fallback_prepared() const noexcept
Host-thread witness that the realtime CPU fallback is already built before prepare() returns.
Definition gpu_audio_node.hpp:107
Definition gpu_audio_node.hpp:78
Definition flow_pans.hpp:19
MissPolicy
What the transport does for a block when the GPU result is not ready in time (the worker fell behind,...
Definition gpu_audio_node.hpp:12
@ PassthroughDry
Output the dry input for the missed block.
Definition gpu_audio_node.hpp:31
@ CpuFallback
Run the node's CPU fallback for the missed block.
Definition gpu_audio_node.hpp:38
@ Silence
Output silence for the missed block (+ telemetry).
Definition gpu_audio_node.hpp:15
Declared, fixed scheduling properties of a GPU audio node.
Definition gpu_audio_node.hpp:44
uint32_t output_channels
Definition gpu_audio_node.hpp:47
bool supports_cpu_fallback
Definition gpu_audio_node.hpp:60
uint32_t block_size
Definition gpu_audio_node.hpp:48
uint32_t input_channels
Definition gpu_audio_node.hpp:46
uint32_t sample_rate
Definition gpu_audio_node.hpp:49
MissPolicy miss_policy
Definition gpu_audio_node.hpp:59
std::string name
Definition gpu_audio_node.hpp:45
std::uint32_t worker_pipeline_blocks
Number of blocks the node's worker emits behind its submit (wet(N-D)).
Definition gpu_audio_node.hpp:67
uint32_t latency_blocks
Fixed latency in host blocks.
Definition gpu_audio_node.hpp:52
Versioned, allocation-free status shared by native hosts and UI adapters.
Definition gpu_audio_status.hpp:80