mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-21 03:46:37 +02:00
The nine channels were one array of one struct, but only index 8 ever used the two DMA descriptors, the played/fraction position and the waiting-thread vector, and only 0-7 ever used the buffer slot - so eight copies of a std::vector sat there dead. They are two different pieces of hardware and now they are two structs: AudioChannel for the eight the mixer walks, and a single AudioSRCChannel for the one the codec reads directly. Found while rereading it: - __AudioUpdate can now run from inside an output call, and it reschedules when it wakes a thread. A context switch there lands before the syscall writes its return value, so the caller loses it and the woken thread gets it instead. Deferred with hleReSchedule when a syscall is in flight. The same fix applies to the release path, which had the problem before this branch existed. - A finished SRC buffer whose waiting thread had given up dropped the completion entirely, so the next caller waited a buffer too long. Now it walks past dead waiters and banks the completion if nobody is left. - An output with a null pointer changed the channel volume, where the hardware returns before touching it. - A busy channel came back as an error from the Output2 path and as debug from the mixer path. It is an ordinary answer a game polls on, so both are debug now; the old behavior filled the log with 18k error lines in a minute of F1 2009. - AudioChannel::reset had no callers left: releasing a channel with a thread parked on it is refused, so there is nobody to wake. - The two routing modes are globals and were written once per channel. They get their own small savestate block. Savestate: the sceAudio section goes to 3, and the SRC channel gets a section of its own. States from released builds carry it as a ninth channel record, which is read and discarded. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>