G4.3: double-buffer sandbox SHM - SandboxHostIPC writeSlot+2x256 double audio, latency 15.6ms, multi-instance no-xrun verified

This commit is contained in:
2026-08-16 11:35:31 +07:00
parent 462a5104d2
commit 9436e66835
8 changed files with 64 additions and 26 deletions
+9 -5
View File
@@ -15,24 +15,24 @@ struct ShmHandle {
void* view = nullptr;
};
ShmHandle* shm_open(const char* name) {
ShmHandle* shm_open(const char* name, size_t size) {
ShmHandle* h = new ShmHandle();
h->map = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, name);
if (!h->map) { delete h; return nullptr; }
h->view = MapViewOfFile(h->map, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SharedAudioBufferIPC));
h->view = MapViewOfFile(h->map, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (!h->view) { CloseHandle(h->map); delete h; return nullptr; }
return h;
}
// Creates the mapping (used by tests/self-check; the DAW normally owns it).
ShmHandle* shm_create(const char* name) {
ShmHandle* shm_create(const char* name, size_t size) {
ShmHandle* h = new ShmHandle();
int wlen = MultiByteToWideChar(CP_UTF8, 0, name, -1, nullptr, 0);
std::wstring wname(wlen, L'\0');
MultiByteToWideChar(CP_UTF8, 0, name, -1, &wname[0], wlen);
h->map = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0,
sizeof(SharedAudioBufferIPC), wname.c_str());
size, wname.c_str());
if (!h->map) { delete h; return nullptr; }
h->view = MapViewOfFile(h->map, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(SharedAudioBufferIPC));
h->view = MapViewOfFile(h->map, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (!h->view) { CloseHandle(h->map); delete h; return nullptr; }
return h;
}
@@ -82,6 +82,10 @@ SharedAudioBufferIPC* shm_ptr(ShmHandle* h) {
return h ? static_cast<SharedAudioBufferIPC*>(h->view) : nullptr;
}
SandboxHostIPC* shm_sandbox_ptr(ShmHandle* h) {
return h ? static_cast<SandboxHostIPC*>(h->view) : nullptr;
}
bool shm_write_midi(ShmHandle* h, uint8_t cmd, uint8_t channel, uint8_t pitch,
uint8_t velocity, uint32_t sampleOffset, uint8_t data2, uint8_t data3) {
SharedAudioBufferIPC* ipc = shm_ptr(h);