diff --git a/docs/audio_hal_exe_calls.md b/docs/audio_hal_exe_calls.md index a500e16fc3..f6638c0ba2 100644 --- a/docs/audio_hal_exe_calls.md +++ b/docs/audio_hal_exe_calls.md @@ -72,6 +72,12 @@ frame count of the Opus packet's table-of-contents byte (RFC 6716, section 3.1) `xapu_chad_test` covers the layouts and the silent path; `xapu_opus_test` covers the decoded path with a generated packet. +The `chad.dll` signatures, structure layouts, limits and error codes come from the same project +(`crates/victory-hle/src/modules/dsp.rs` at commit `ffe310e`), facts only; the top of `xapu_chad.cpp` lists them. They +fit the shapes above: the title's `0x80` is the stream limit, `XDspActivate`'s two outputs are a 16-byte status block +and the stream, and the dwords the title waits on are the status block's last completed ticket (+4) and its result +(+0xc). Commands complete when submitted and their output is zeros: no convolution is computed. + ## `xg_xs.dll` and `XCRDAPI.dll` | Import | Sites | What the sites show | diff --git a/docs/runtime_imports.md b/docs/runtime_imports.md index e408d223d3..a3ed1cabcb 100644 --- a/docs/runtime_imports.md +++ b/docs/runtime_imports.md @@ -212,9 +212,10 @@ input. Activate, process, deactivate and reset commands are copied from the titl result in order. A process command decodes its Opus packet through `runtime/opus_decoder` (Rust over the BSD-3-Clause `opus-pure`) into the slot's output, honouring first frame, frame count, output length and the deinterleaved option; without the crate the result carries the table-of-contents frame count and silence. The layouts follow Marvisak/VIctory -`crates/victory-hle/src/modules/apu.rs` (GPL-3.0-or-later). `XDspActivate` writes its two outputs as pointers to zeroed -memory, which the title reads as "command done" after each `XDspSubmitCommand`; the DSP stays silent. `xapu_chad_test` -covers the layouts, the queue and the silent path; `xapu_opus_test` the decoded path. With `--trace`, the first call of +`crates/victory-hle/src/modules/apu.rs` (GPL-3.0-or-later). The `chad.dll` layouts, limits and error codes follow +`crates/victory-hle/src/modules/dsp.rs` (same licence and commit): `XDspActivate` hands out a stream and its 16-byte +status block, and each `XDspSubmitCommand` completes at once, advancing the ticket the title waits on and writing +zeros as its output, so the DSP's reverb stays dry. `xapu_chad_test` covers the layouts, the queues and the silent path; `xapu_opus_test` the decoded path. With `--trace`, the first call of each, and the first command of each type, is an `audio_queue` event. The table above was measured before this shim and still lists these ten as unimplemented; they are served now. The call shapes agree with `docs/audio_hal_exe_calls.md`, which was measured with `tools/import_call_sites.py`. diff --git a/runtime/shims/xapu_chad.cpp b/runtime/shims/xapu_chad.cpp index e46a61c977..c1855036f7 100644 --- a/runtime/shims/xapu_chad.cpp +++ b/runtime/shims/xapu_chad.cpp @@ -1,6 +1,6 @@ -// chad.dll: the console's audio DSP command queue. No PC has one, so this gives the title a connection whose calls -// succeed and zeroed DSP status: nothing the title submits is processed. xapu.dll, the APU command queue, is in -// xapu_queue.cpp. +// chad.dll: the console's audio DSP command queue. No PC has one, so this gives the title connections and streams +// whose commands complete at once with silent output: nothing the title submits is processed. xapu.dll, the APU +// command queue, is in xapu_queue.cpp. // // Read from the executable's call sites (counts in docs/runtime_imports.md), statically, never run: // XDspConnectWithMaximumStreamLimit(buffer, u32, u32, 0x80, 1, handle*) 1 site; success is a return of 0. The @@ -14,11 +14,36 @@ // at +4 equals *id. // XDspDeactivate, XDspDisconnect 1 site each, tail calls: the caller returns what they return. // -// HYPOTHESIS: XDspActivate's outputs point at zeroed memory owned by the connection. XDspSubmitCommand leaves *id at -// the title's 0, so the zeroed status reads as "command 0 done, no error" and the title does not wait. +// chad.dll's signatures, layouts, limits and error codes are facts recorded by Marvisak/VIctory (GPL-3.0-or-later, +// crates/victory-hle/src/modules/dsp.rs at commit ffe310e), which runs the retail executable through these calls; see +// docs/related_projects.md. Nothing of its code is copied. They fit every chad shape above: +// HRESULT XDspConnectWithMaximumStreamLimit(void* base, uint32_t base_bytes, uint32_t ir_seconds, +// uint32_t max_streams, uint32_t max_channels, DspConnection** out) +// E_INVALIDARG for a null base, base_bytes outside 0x10000..0x1F400000, ir_seconds above 0x80, +// max_streams above 0x100 or max_channels above 2; then E_POINTER for a null out. +// HRESULT XDspActivate(DspConnection*, const DspStreamDesc*, const DspStatus** status, DspStream** stream) +// E_POINTER for a null status or stream out; E_INVALIDARG for a null connection or description +// or a description that breaks the rules below; E_OUTOFMEMORY once max_streams are active. +// The status block starts zeroed with result S_OK. A description is valid when: +// kind 1 (convolution): 1 or 2 channels, 0x200 or 0x400 frames, option 0x4 clear; +// any other kind: 1 channel, 0x200, 0x400 or 0x800 frames; +// and options 0x2 and 0x8 need 2 channels. +// HRESULT XDspSubmitCommand(DspStream*, const DspCommand*, uint32_t* ticket) +// E_INVALIDARG for a null stream or command. The command completes at once: frames * channels +// floats of output (when not null) are written, the status block's submitted and completed +// words advance to the next ticket and its result is S_OK, and *ticket (when not null) gets +// that ticket. This is the wait above: completed (+4) equals *id and result (+0xc) is 0. +// HRESULT XDspDeactivate(DspStream*), HRESULT XDspDisconnect(DspConnection*) E_INVALIDARG for null. +// No convolution or other block transform is computed: the hardware's impulse response layout is not known, so the +// output of every command is zeros and reverb returns are dry. +// +// HYPOTHESIS: a connection or stream handle that is unknown or already released is refused with E_INVALIDARG, and +// XDspDisconnect with streams still active releases them, so their handles are then refused too. The title releases +// its streams before it disconnects; what the console does otherwise is not recorded. #include #include +#include #include #include #include @@ -31,11 +56,80 @@ namespace { +#pragma pack(push, 1) +struct DspStreamDesc { + uint32_t kind; // 1: convolution + uint32_t options; + uint32_t frames; // per block + uint32_t channels; + uint32_t ir_floats; + const float* ir; // impulse response, in the hardware's layout +}; +#pragma pack(pop) +struct DspStatus { // the block the title polls + uint32_t submitted; + uint32_t completed; // ticket of the last completed command + uint32_t reserved; + HRESULT result; // of that command +}; +struct DspCommand { // one block + float gains[2]; + const float* input; + float* output; + uint64_t reserved; +}; +static_assert(sizeof(DspStreamDesc) == 0x1C && offsetof(DspStreamDesc, ir) == 0x14, "packed description"); +static_assert(sizeof(DspStatus) == 16 && offsetof(DspStatus, completed) == 4 && offsetof(DspStatus, result) == 0xC, + "the dwords the title's wait reads"); +static_assert(sizeof(DspCommand) == 32 && offsetof(DspCommand, output) == 0x10, "gains, input, output, reserved"); + +constexpr uint32_t kDspConvolution = 1; +constexpr uint32_t kDspStereoOptions = 0x2 | 0x8; // need two channels +constexpr uint32_t kDspNotForConvolution = 0x4; +constexpr uint32_t kDspMinBaseBytes = 0x10000; +constexpr uint32_t kDspMaxBaseBytes = 0x1F400000; +constexpr uint32_t kDspMaxIrSeconds = 0x80; +constexpr uint32_t kDspMaxStreams = 0x100; +constexpr uint32_t kDspMaxChannels = 2; + +struct DspStream; struct DspConnection { - uint8_t status[256]; - uint8_t stream[256]; + uint32_t max_streams; + std::set streams; +}; +struct DspStream { + DspConnection* owner; + uint32_t frames; + uint32_t channels; + DspStatus status; // handed to the title by XDspActivate }; +// Every live handle, so a stale or doubled release is refused instead of freeing twice. One lock for all: the title +// submits one command per block, so there is nothing to contend. +std::mutex g_dsp_mutex; +std::set g_dsp_connections; +std::set g_dsp_streams; + +bool dsp_description_valid(const DspStreamDesc& d) { + if ((d.options & kDspStereoOptions) && d.channels != 2) return false; + if (d.kind == kDspConvolution) { + if (d.options & kDspNotForConvolution) return false; + return (d.channels == 1 || d.channels == 2) && (d.frames == 0x200 || d.frames == 0x400); + } + return d.channels == 1 && (d.frames == 0x200 || d.frames == 0x400 || d.frames == 0x800); +} + +// The title polls the status block from other threads: each word is one interlocked store, result before completed. +void dsp_store(uint32_t& word, uint32_t value) { + InterlockedExchange(reinterpret_cast(&word), static_cast(value)); +} + +void dsp_release_stream(DspStream* s) { // under g_dsp_mutex + s->owner->streams.erase(s); + g_dsp_streams.erase(s); + delete s; +} + // gta6rt --trace FILE: the first call of each function, with the caller, so the first boot shows what the title sends // without a line per call. void note(const char* api, uint64_t value, const void* caller) { @@ -52,43 +146,84 @@ void note(const char* api, uint64_t value, const void* caller) { rt::startup_trace::quote(rt::startup_trace::where(reinterpret_cast(caller)))); } -HRESULT __stdcall XDspConnectWithMaximumStreamLimit(void* buffer, uint32_t a, uint32_t b, uint32_t max_streams, - uint32_t flags, void** handle) { +HRESULT __stdcall XDspConnectWithMaximumStreamLimit(void* base, uint32_t base_bytes, uint32_t ir_seconds, + uint32_t max_streams, uint32_t max_channels, + DspConnection** handle) { note("XDspConnectWithMaximumStreamLimit", max_streams, _ReturnAddress()); - (void)buffer; - (void)a; - (void)b; - (void)flags; - if (!handle) return E_INVALIDARG; - *handle = new (std::nothrow) DspConnection{}; - return *handle ? S_OK : E_OUTOFMEMORY; + if (!base || base_bytes < kDspMinBaseBytes || base_bytes > kDspMaxBaseBytes || ir_seconds > kDspMaxIrSeconds || + max_streams > kDspMaxStreams || max_channels > kDspMaxChannels) + return E_INVALIDARG; + if (!handle) return E_POINTER; + auto* c = new (std::nothrow) DspConnection{max_streams, {}}; // a throwing new would unwind into the title + if (!c) return E_OUTOFMEMORY; + try { + const std::lock_guard lock(g_dsp_mutex); + g_dsp_connections.insert(c); + } catch (...) { + delete c; + return E_OUTOFMEMORY; + } + *handle = c; + return S_OK; } -HRESULT __stdcall XDspDisconnect(void* handle) { +HRESULT __stdcall XDspDisconnect(DspConnection* c) { note("XDspDisconnect", 0, _ReturnAddress()); - delete static_cast(handle); + const std::lock_guard lock(g_dsp_mutex); + if (!c || !g_dsp_connections.erase(c)) return E_INVALIDARG; + while (!c->streams.empty()) dsp_release_stream(*c->streams.begin()); + delete c; return S_OK; } -HRESULT __stdcall XDspActivate(void* handle, const void* description, void** status, void** stream) { - note("XDspActivate", 0, _ReturnAddress()); - (void)description; - auto* c = static_cast(handle); - if (!c) return E_INVALIDARG; - if (status) *status = c->status; - if (stream) *stream = c->stream; +HRESULT __stdcall XDspActivate(DspConnection* c, const DspStreamDesc* description, const DspStatus** status, + DspStream** stream) { + note("XDspActivate", description ? description->kind : ~0ull, _ReturnAddress()); + if (!status || !stream) return E_POINTER; + if (!c || !description) return E_INVALIDARG; + DspStreamDesc d; + std::memcpy(&d, description, sizeof d); + if (!dsp_description_valid(d)) return E_INVALIDARG; + const std::lock_guard lock(g_dsp_mutex); + if (!g_dsp_connections.count(c)) return E_INVALIDARG; + if (c->streams.size() >= c->max_streams) return E_OUTOFMEMORY; + auto* s = new (std::nothrow) DspStream{c, d.frames, d.channels, {0, 0, 0, S_OK}}; + if (!s) return E_OUTOFMEMORY; + try { + g_dsp_streams.insert(s); + c->streams.insert(s); + } catch (...) { + g_dsp_streams.erase(s); + delete s; + return E_OUTOFMEMORY; + } + *status = &s->status; + *stream = s; return S_OK; } -HRESULT __stdcall XDspDeactivate(void* handle, uint64_t, uint64_t, uint64_t) { +HRESULT __stdcall XDspDeactivate(DspStream* s) { note("XDspDeactivate", 0, _ReturnAddress()); - (void)handle; + const std::lock_guard lock(g_dsp_mutex); + if (!s || !g_dsp_streams.count(s)) return E_INVALIDARG; + dsp_release_stream(s); return S_OK; } -// *id stays the 0 the title wrote, which the zeroed status block already reports as done. -HRESULT __stdcall XDspSubmitCommand(void*, void*, uint32_t*) { +// Completes at once with a block of silence: no convolution is computed. +HRESULT __stdcall XDspSubmitCommand(DspStream* s, const DspCommand* command, uint32_t* ticket) { note("XDspSubmitCommand", 0, _ReturnAddress()); + if (!s || !command) return E_INVALIDARG; + DspCommand cmd; + std::memcpy(&cmd, command, sizeof cmd); + const std::lock_guard lock(g_dsp_mutex); + if (!g_dsp_streams.count(s)) return E_INVALIDARG; + if (cmd.output) std::memset(cmd.output, 0, size_t{s->frames} * s->channels * sizeof(float)); + const uint32_t next = s->status.submitted + 1; // wraps like the 32-bit word it is + dsp_store(s->status.submitted, next); + dsp_store(reinterpret_cast(s->status.result), static_cast(S_OK)); + dsp_store(s->status.completed, next); + if (ticket) *ticket = next; return S_OK; } diff --git a/runtime/test/xapu_chad_test.cpp b/runtime/test/xapu_chad_test.cpp index 7e667492c7..e9926b1bb0 100644 --- a/runtime/test/xapu_chad_test.cpp +++ b/runtime/test/xapu_chad_test.cpp @@ -5,7 +5,8 @@ // accepted command, in command order, with its id echoed; the per-stream queue limit; the error codes, returned or in // the result; a process command's frame count taken from the Opus packet's table-of-contents byte (RFC 6716, section // 3.1) and clipped, with silence written; and the result event. The packets are hand-made TOC bytes, not audio. -// chad.dll: XDspActivate hands out zeroed status and stream memory, and both disconnect. +// chad.dll: the connect bounds and description rules with their error codes, the status block the title's wait reads, +// one ticket per command with a silent output block, the stream limit, and handles refused once released. #include #include @@ -23,7 +24,7 @@ using XApuGetResultCountFn = uint32_t(__stdcall*)(void*, uint32_t*); using XApuDequeueResultFn = HRESULT(__stdcall*)(void*, void*); using XDspConnectFn = HRESULT(__stdcall*)(void*, uint32_t, uint32_t, uint32_t, uint32_t, void**); using XDspActivateFn = HRESULT(__stdcall*)(void*, const void*, void**, void**); -using XDspDeactivateFn = HRESULT(__stdcall*)(void*, uint64_t, uint64_t, uint64_t); +using XDspDeactivateFn = HRESULT(__stdcall*)(void*); using XDspDisconnectFn = HRESULT(__stdcall*)(void*); using XDspSubmitCommandFn = HRESULT(__stdcall*)(void*, void*, uint32_t*); @@ -271,21 +272,136 @@ int main() { "and it can be activated again"); check(disconnect(apu, 0x20) == S_OK, "XApuDisconnect(handle, 0x20)"); - // XDspConnectWithMaximumStreamLimit(buffer, u32, u32, 0x80, 1, handle*), success read as a return of 0. - alignas(64) static uint8_t dsp_buffer[4096]; + // XDspConnectWithMaximumStreamLimit(base, base_bytes, ir_seconds, max_streams, max_channels, handle*); the title + // passes 0x80 streams and 1 channel, and reads success as a return of 0. + alignas(64) static uint8_t dsp_buffer[0x10000]; void* dsp = nullptr; - check(dsp_connect(dsp_buffer, 0, 0, 0x80, 1, &dsp) == 0 && dsp, "XDspConnectWithMaximumStreamLimit returns 0 and a handle"); - const uint8_t description[0x1c] = {}; + struct Bound { + void* base; + uint32_t bytes, ir_seconds, streams, channels; + const char* what; + } const bounds[] = { + {nullptr, 0x10000, 0, 0x80, 1, "a null base is E_INVALIDARG"}, + {dsp_buffer, 0xFFFF, 0, 0x80, 1, "base_bytes below 0x10000 is E_INVALIDARG"}, + {dsp_buffer, 0x1F400001, 0, 0x80, 1, "base_bytes above 0x1F400000 is E_INVALIDARG"}, + {dsp_buffer, 0x10000, 0x81, 0x80, 1, "ir_seconds above 0x80 is E_INVALIDARG"}, + {dsp_buffer, 0x10000, 0, 0x101, 1, "max_streams above 0x100 is E_INVALIDARG"}, + {dsp_buffer, 0x10000, 0, 0x80, 3, "max_channels above 2 is E_INVALIDARG"}, + }; + for (const Bound& b : bounds) + check(dsp_connect(b.base, b.bytes, b.ir_seconds, b.streams, b.channels, &dsp) == E_INVALIDARG && !dsp, b.what); + check(dsp_connect(nullptr, 0, 0, 0x80, 1, nullptr) == E_INVALIDARG, + "bad arguments are checked before the out pointer"); + check(dsp_connect(dsp_buffer, 0x10000, 0, 0x80, 1, nullptr) == E_POINTER, "a null out pointer is E_POINTER"); + check(dsp_connect(dsp_buffer, 0x1F400000, 0x80, 0x100, 2, &dsp) == 0 && dsp, + "every upper bound itself is accepted"); + check(dsp_disconnect(dsp) == 0, "and that connection disconnects"); + dsp = nullptr; + check(dsp_connect(dsp_buffer, 0x10000, 0, 2, 1, &dsp) == 0 && dsp, + "XDspConnectWithMaximumStreamLimit returns 0 and a handle"); + + // XDspActivate(handle, desc*, status*, stream*): kind, options, frames, channels, ir_floats, ir (0x1C, packed). +#pragma pack(push, 1) + struct Desc { + uint32_t kind, options, frames, channels, ir_floats; + const float* ir; + }; +#pragma pack(pop) + static_assert(sizeof(Desc) == 0x1C, "the packed description"); + struct Shape { + Desc desc; + bool valid; + const char* what; + } const shapes[] = { + {{1, 0, 0x200, 1, 0, nullptr}, true, "convolution, mono, 0x200 frames is valid"}, + {{1, 0, 0x400, 2, 0, nullptr}, true, "convolution, stereo, 0x400 frames is valid"}, + {{1, 0, 0x800, 1, 0, nullptr}, false, "convolution of 0x800 frames is refused"}, + {{1, 0, 0x200, 3, 0, nullptr}, false, "convolution of 3 channels is refused"}, + {{1, 0, 0x200, 0, 0, nullptr}, false, "convolution of 0 channels is refused"}, + {{1, 4, 0x200, 1, 0, nullptr}, false, "convolution with option 0x4 is refused"}, + {{2, 0, 0x800, 1, 0, nullptr}, true, "another kind, mono, 0x800 frames is valid"}, + {{2, 0, 0x100, 1, 0, nullptr}, false, "another kind of 0x100 frames is refused"}, + {{2, 0, 0x200, 2, 0, nullptr}, false, "another kind in stereo is refused"}, + {{2, 4, 0x200, 1, 0, nullptr}, true, "another kind with option 0x4 is valid"}, + {{1, 2, 0x200, 1, 0, nullptr}, false, "option 0x2 on a mono stream is refused"}, + {{1, 8, 0x200, 1, 0, nullptr}, false, "option 0x8 on a mono stream is refused"}, + {{1, 2 | 8, 0x400, 2, 0, nullptr}, true, "options 0x2 and 0x8 on a stereo convolution are valid"}, + }; + for (const Shape& shape : shapes) { + uint32_t* st = nullptr; + void* sp = nullptr; + const HRESULT hr = dsp_activate(dsp, &shape.desc, reinterpret_cast(&st), &sp); + bool ok = shape.valid ? hr == S_OK && st && sp : hr == E_INVALIDARG && !sp; + if (shape.valid && sp) ok = ok && dsp_deactivate(sp) == S_OK; + check(ok, shape.what); + } + const Desc reverb{1, 0, 0x200, 2, 0, nullptr}; uint32_t* status = nullptr; void* stream = nullptr; - check(dsp_activate(dsp, description, reinterpret_cast(&status), &stream) == 0, "XDspActivate returns 0"); + check(dsp_activate(dsp, &reverb, nullptr, &stream) == E_POINTER, "a null status out is E_POINTER"); + check(dsp_activate(dsp, &reverb, reinterpret_cast(&status), nullptr) == E_POINTER, + "a null stream out is E_POINTER"); + check(dsp_activate(nullptr, &reverb, reinterpret_cast(&status), &stream) == E_INVALIDARG, + "a null connection is E_INVALIDARG"); + check(dsp_activate(dsp, nullptr, reinterpret_cast(&status), &stream) == E_INVALIDARG, + "a null description is E_INVALIDARG"); + check(dsp_activate(dsp, &reverb, reinterpret_cast(&status), &stream) == 0, "XDspActivate returns 0"); check(status && stream && static_cast(status) != stream, "XDspActivate writes both outputs"); - uint32_t dsp_id = 0; - check(dsp_submit(stream, dsp_buffer, &dsp_id) == 0, "XDspSubmitCommand returns 0"); - // What the title's wait reads: no error at +0xc and the submitted id at +4. - check(status && status[3] == 0 && status[1] == dsp_id, "the status block reports the submitted command as done"); - check(dsp_deactivate(dsp, 0, 0, 0) == 0, "XDspDeactivate returns 0"); - check(dsp_disconnect(dsp) == 0, "XDspDisconnect returns 0"); + check(status && status[0] == 0 && status[1] == 0 && status[2] == 0 && status[3] == 0, + "the status block starts zeroed"); + if (!status || !stream) return 1; + void* second = nullptr; + uint32_t* second_status = nullptr; + check(dsp_activate(dsp, &reverb, reinterpret_cast(&second_status), &second) == 0, + "a second stream fits a limit of 2"); + void* third = nullptr; + uint32_t* third_status = nullptr; + check(dsp_activate(dsp, &reverb, reinterpret_cast(&third_status), &third) == E_OUTOFMEMORY && !third, + "a third is E_OUTOFMEMORY"); + + // XDspSubmitCommand(stream, cmd*, id*): gains, input, output, reserved (32 bytes). A stereo block of 0x200 frames + // is 0x400 floats. + struct Command { + float gains[2]; + const float* input; + float* output; + uint64_t reserved; + }; + static_assert(sizeof(Command) == 32, "the command"); + static float input[0x400]; + static float output[0x400 + 4]; + for (float& f : input) f = 0.5f; + for (float& f : output) f = 1.0f; + Command command{{1.0f, 1.0f}, input, output, 0}; + bool done = true; + for (uint32_t n = 1; n <= 3; ++n) { + uint32_t id = 0; // as the title zeroes it + done = done && dsp_submit(stream, &command, &id) == 0 && id == n && status[0] == n && status[1] == id && + status[3] == 0; + } + check(done, "each command completes at once: the ticket advances 1, 2, 3 and the status reports it with S_OK"); + bool dsp_silent = true; + for (int i = 0; i < 0x400; ++i) dsp_silent = dsp_silent && output[i] == 0.0f; + check(dsp_silent && output[0x400] == 1.0f, + "the output block (frames * channels floats) is silence, nothing past it"); + check(dsp_submit(stream, &command, nullptr) == 0 && status[1] == 4, "the ticket out pointer may be null"); + command.output = nullptr; + check(dsp_submit(stream, &command, nullptr) == 0 && status[1] == 5, "so may the output"); + check(dsp_submit(nullptr, &command, nullptr) == E_INVALIDARG, "a null stream is E_INVALIDARG"); + check(dsp_submit(stream, nullptr, nullptr) == E_INVALIDARG, "a null command is E_INVALIDARG"); + + // Handles: released once, refused after. + check(dsp_deactivate(stream) == 0, "XDspDeactivate returns 0"); + check(dsp_deactivate(stream) == E_INVALIDARG, "deactivating it again is E_INVALIDARG"); + command.output = output; + check(dsp_submit(stream, &command, nullptr) == E_INVALIDARG, "a released stream takes no command"); + check(dsp_deactivate(nullptr) == E_INVALIDARG, "a null stream is E_INVALIDARG"); + check(dsp_disconnect(dsp) == 0, "XDspDisconnect with a stream still active returns 0"); + check(dsp_deactivate(second) == E_INVALIDARG, "and that stream is released with it"); + check(dsp_disconnect(dsp) == E_INVALIDARG, "disconnecting again is E_INVALIDARG"); + check(dsp_disconnect(nullptr) == E_INVALIDARG, "a null connection is E_INVALIDARG"); + check(dsp_activate(dsp, &reverb, reinterpret_cast(&status), &stream) == E_INVALIDARG, + "a released connection activates nothing"); std::printf("%d checks, %d failures\n", g_checks, g_failures); return g_failures ? 1 : 0;