Files
betterxen/shims/audio/chad.cpp
T
ates 058bc981dc Merge main and address PR #429 review findings
- Reject ApuAlloc before ApuCreateHeap is called and reset used=0 explicitly on heap creation
- Validate max_streams > 0 and record it on DSP connections in XDspConnectWithMaximumStreamLimit
- Expand test_audio_input to cover pre-heap ApuAlloc failure, single-output ApuAlloc, zero max_streams rejection, and GameInput v0 QueryInterface/method dispatch
- Resolve CHANGELOG.md merge conflict with main

Signed-off-by: ates <ahmetrizaates@hotmail.com>
2026-11-26 18:08:53 +03:00

42 lines
1.3 KiB
C++

#define BX_DSP_CONNECTIONS
#include "command_ring.h"
extern "C" {
// Validate and record the caller's stream limit; the synthetic command ring
// holds a fixed 32-packet backlog independent of stream count.
HRESULT WINAPI XDspConnectWithMaximumStreamLimit(uint32_t max_streams, void** out) {
if (!out) return E_POINTER;
*out = nullptr;
if (!max_streams) return E_INVALIDARG;
return connect(out, max_streams);
}
HRESULT WINAPI XDspDisconnect(void* handle) { return disconnect(handle); }
HRESULT WINAPI XDspActivate(void* handle) {
std::lock_guard guard(connections_lock);
auto* c = lookup(handle);
if (!c) return E_HANDLE;
c->active = true;
// chad has no result export. Active DSP commands complete synchronously.
while (c->queue.count) c->queue.pop();
return S_OK;
}
HRESULT WINAPI XDspDeactivate(void* handle) {
std::lock_guard guard(connections_lock);
auto* c = lookup(handle);
if (!c) return E_HANDLE;
c->active = false;
return S_OK;
}
HRESULT WINAPI XDspSubmitCommand(void* handle, const void* cmd, uint32_t size) {
std::lock_guard guard(connections_lock);
auto* c = lookup(handle);
if (!c) return E_HANDLE;
const HRESULT hr = c->queue.push(cmd, size);
if (SUCCEEDED(hr) && c->active) c->queue.pop();
return hr;
}
}