Define exact behaviour of .start() / .pause() / .stop()
#1357
Replies: 9 comments 9 replies
|
Im post-op right now at hospital, so i don’t know how lucid I am, why can’t we drain stop in web backend by instead of calling the normal user callback that time we just call fill_equilibrium |
|
because that wouldn't change how long hope your op went well |
|
All the best to you, @Marco-Farruggio! @LastExceed prior art:
No. It returns once the stream is transitioned to RUNNING (ALSA parlance). After that the data callback is allowed to fire.
No, same reasoning. What it should is that once it returns, the data callback isn't entered again.
Yes, bounded by the timeout, and yes, that makes blocking part of the contract. A
The web backends are the documented exception, not evidence against the rule.
Yes, but only internally to cpal and with silence. The line is that the data callback must not fire before
Option 2, discard. 1 is out because playing back audio that a user explicitly paused is a nasty surprise. You'd get a burst of sound on a stream that you asked to be quiet. 3 replays stale audio on
It does, and if it's not clear to you, it may not be clear to others, and is worthwhile documenting. |
|
Is |
|
When would it need to? I have difficulties to imagine when. The data callback always supplies a full buffer, so it shouldn’t need to append anything to flush. Or maybe depending on backend idiosyncrasies it might need to append one period of silence to ensure the last user buffer gets moved into DMA? As opposed to letting it underflow, but normal system APIs would handle that themselves. Other circumstances we should consider? |
|
WASAPI's ring buffer is not an integer multiple of the engine period, so the last period is incomplete. Our current implementation deals with this by effectively appending uninitialized memory, sleeping for the approximate duration of the buffered data, and then queueing a message for the processing thread to call I have also observed that both my native ASIO driver and WASAPI-exclusive mode consume the buffer continuously, rather than in chunks, which makes stopping exactly at the end of user provided data racy, and the only way to deal with that (that I can think of) is appending some silence and deliberately overshooting the goal |
|
Yes, in those cases we need to do something on a best-effort basis. They don't have an API to query the available buffer fill, do they?We could argue whether it's preferred to risk undershoot or to risk overshoot, and whether a millisecond or two will matter at all. |
Exactly that. Somehow this possibility had not occurred to me until now 😅 I rest my case.
WASAPI's ring buffer begs to differ (its total size is notably distinct from the period size)
Is there a word missing here somewhere? My brain fails to parse this part of the sentence |
|
What should happen when |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
.start()block until the stream is running? (e.g. when.start()triggers priming first).pause()block until the processing thread is ready to continue?.stop()block until the buffer is fully drained?.start()is called?.start()ed (populating the buffer), then.pause()d (keeping the buffer), and then.stop()ped (without another call to.start()in between)?Ok(())All reactions