cpal
cpal copied to clipboard
Pause semantics
Each platform has its own way of abstracting pauses, and cpal currently only expose a simple API (which probably has inconsistent behavior wrt following description).
Many driver seems to implement hardware level pauses, which IIUC can stop processing even in the middle of the buffer. When paused though there are two choices regarding the remaining buffer: flush (drain) until they're fully played, drop them completely (resetting the stream), or just keep them until the stream is resumed.
Interaction with OS mixers, though, is unknown as in theory hardware pause won't be used if another application is playing audio.
- On Windows, only
StartandStopis exposed, with aResetfunction that clears playback position, achieving the "drop" behavior above. - ALSA exposes a variety of APIs, but portability of those are unknown. The exposed API covers all of the behavior listed above.
- Android (AAudio) has a rather strange API that distinguish between a "pause" operation (output stream only) and a "stop" operation. Neither of them closes (destroys) the stream. The paused state has an additional option of getting flushed.
How should we expose these behaviors? Or if we decide to not do so, which behavior should we consistently achieve on every platform?
I'm experiencing the issue that some samples that are pulled before pausing are played after resuming (using ALSA). That's exactly what this issue is about?