Maelgrum wrote on 2023-10-07, 12:14:
rip this stuff out, and insert in command loop dedicated processing of CMD 0x14
I guess you are aware of the "correct" way to use CMD 0x14, but I consider the classic playback command to be severely underdocumented on most "soundblaster guides". Of course, they all get the basics correct: You issue command 0x14 and then you send the length. The card starts playback at the rate programmed by command 0x40, and after the last byte has been played back, an interrupt is generated. You can do the same with command 0x1C ("auto init"), and in that case, the soundblaster card keeps playing back samples and resets the sample counter, so interrupts are generated periodically. That's what everyone knows...
The key point on the other hand is that the CMD 0x14 can be queued in a queue with depth 1. You can send another 0x14 command while the previous block is still worked on, and when the counter of the first block expired, another block is seamlessly started with the length given in the second command, allowing gapless chaining of blocks even without using the auto-init feature, and allowing a different block size on each chained block.
Furthermore, you can also queue a 0x14 command while an auto-init playback (0x1c) is still in progress. In that case, the current iteration of the auto-init command is finished, an IRQ is generated, and then a final block is played with the length given in the 0x14 command and then a second IRQ is generated and playback stops.
The same applies to the ADPCM playback commands in a similar manner.
Whatever you do to optimize "command 0x14" playback, make sure to not disrupt the "queued command" use-case.