-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add async OfflineAudioContext startRendering, suspend and resume #412
Conversation
It is a temporary fix because this simplifies the node bindings. As long as OfflineContext rendering is synchronous, the bounds are not necessary. The tests fail however because we require OfflineAudioContext to be Send and Sync. To be dealt with later.
…d callbacks" This reverts commit 1c66068.
Only at the beginning, and when the context was suspended
/bench |
I'm ready for a first round of reviews! |
|
Ok cool! I will try to have a closer look this week, and (hopefully) try to see where this gets us with the bindings |
src/context/offline.rs
Outdated
/// assert_eq!(buffer.number_of_channels(), 1); | ||
/// assert_eq!(buffer.length(), 512); | ||
/// ``` | ||
pub async fn suspend_at(&self, suspend_time: f64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could just call it suspend
as there is no alternative signature
src/context/offline.rs
Outdated
/// ``` | ||
pub async fn suspend_at(&self, suspend_time: f64) { | ||
let quantum = (suspend_time * self.base.sample_rate() as f64 / RENDER_QUANTUM_SIZE as f64) | ||
.ceil() as usize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should check the other conditions as well, cf. https://webaudio.github.io/web-audio-api/#dom-offlineaudiocontext-suspend, but maybe for another PR (this one may be a bit tricky "is less than or equal to the current time"
src/context/offline.rs
Outdated
/// assert_eq!(buffer.number_of_channels(), 1); | ||
/// assert_eq!(buffer.length(), 512); | ||
/// ``` | ||
pub fn suspend_at_sync<F: FnOnce(&mut Self) + Send + Sync + 'static>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, maybe suspend_sync
is clear enough?
Hey, except my small comments, look all good to me! I will try to implement the bindings, I let you know |
Thanks for the comments. I will address those, plus the leftover performance regression. |
This is slightly different from the spec, where it says we should throw if the suspend time is less than or equal to the current time. However, this is more or less the same because rendering happens so fast the user does not even know about the precise 'current time' anyway.
/bench |
|
Cool, the baseline performance regression is gone and even exceeds performance of the previous release. I guess due to ab48aff |
Todo:
sync
interface this way