Skip to content

Commit c9c5d48

Browse files
committed
SuperSonic - update
1 parent 4a70b8b commit c9c5d48

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

‎app/api/include/api/audio/server_shm.hpp‎

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,30 @@ inline void shm_remove(const string& name) {
144144

145145
// ──── Fixed-layout shared memory header ─────────────────────────────────
146146
//
147-
// Segment layout:
147+
// Segment layout (must mirror canonical SuperSonic
148+
// src/scsynth/common/server_shm.hpp — supersonic's MAGIC bump enforces
149+
// this; an out-of-date reader sees a stranger's segment and refuses):
148150
//
149-
// scope_shm_header (16 bytes, 16-aligned)
150-
// scope_buffer[MAX_SCOPE_BUFFERS] (128 scope slots)
151-
// float[control_bus_count] (control bus values)
152-
// char[remaining] (TLSF pool for scope data)
151+
// scope_shm_header (16 bytes, 16-aligned)
152+
// scope_buffer[MAX_SCOPE_BUFFERS] (128 scope slots)
153+
// float[control_bus_count] (control bus values)
154+
// PerformanceMetrics (engine perf metrics)
155+
// NodeTreeHeader + NodeEntry[NODE_TREE_MIRROR_MAX_NODES]
156+
// char[remaining] (TLSF pool for scope data)
157+
//
158+
// Sonic Pi's reader path only needs scope buffers and (potentially) the
159+
// pool base — it does not interpret metrics or the node tree. We mirror
160+
// their sizes here purely to compute pool_base_ at the right offset.
161+
162+
// Sizes copied from supersonic/src/shared_memory.h. Keep these in sync
163+
// when the supersonic side changes — the MAGIC value will catch any drift.
164+
static constexpr size_t METRICS_SIZE = 184;
165+
static constexpr size_t NODE_TREE_HEADER_SIZE = 16;
166+
static constexpr size_t NODE_TREE_ENTRY_SIZE = 72;
167+
static constexpr size_t NODE_TREE_MIRROR_MAX_NODES = 1024;
153168

154169
struct scope_shm_header {
155-
static constexpr uint32_t MAGIC = 0x5C09E001;
170+
static constexpr uint32_t MAGIC = 0x5C09E002;
156171

157172
uint32_t magic;
158173
uint32_t num_scope_buffers;
@@ -181,9 +196,22 @@ class server_shared_memory {
181196
off = (off + 15) & ~size_t(15);
182197
control_busses_ = reinterpret_cast<float*>(base + off);
183198

184-
// TLSF pool after control busses (16-aligned)
199+
// PerformanceMetrics after control busses (16-aligned). Sonic Pi
200+
// doesn't read the metrics struct itself; we only need the size to
201+
// place pool_base_ correctly.
185202
off += static_cast<size_t>(control_busses) * sizeof(float);
186203
off = (off + 15) & ~size_t(15);
204+
off += METRICS_SIZE;
205+
206+
// NodeTreeHeader + NodeEntry[NODE_TREE_MIRROR_MAX_NODES] after
207+
// metrics (16-aligned for the header, then 8-aligned entries —
208+
// 8-alignment is naturally satisfied inside a 16-aligned region).
209+
off = (off + 15) & ~size_t(15);
210+
off += NODE_TREE_HEADER_SIZE;
211+
off += NODE_TREE_MIRROR_MAX_NODES * NODE_TREE_ENTRY_SIZE;
212+
213+
// TLSF pool follows (16-aligned).
214+
off = (off + 15) & ~size_t(15);
187215
pool_base_ = base + off;
188216
pool_size_ = SEGMENT_SIZE - off;
189217

‎app/external/supersonic‎

Submodule supersonic updated 50 files

0 commit comments

Comments
 (0)