Skip to content
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

fix: use separate AudioContexts for each media element? #80

Open
WofWca opened this issue Jul 14, 2022 · 0 comments
Open

fix: use separate AudioContexts for each media element? #80

WofWca opened this issue Jul 14, 2022 · 0 comments

Comments

@WofWca
Copy link
Owner

WofWca commented Jul 14, 2022

Using a shared one causes problems. See

// This is mainly to reduce CPU consumption while the video is paused. Also gets rid of slight misbehaviors like
// speed always becoming silenceSpeed when media element gets paused, which causes a guaranteed audio stretch on
// resume.
// TODO This causes a bug - start playing two media elements (on the same <iframe>), then pause one - both will get
// silenced. Nobody really does that, but still.
const suspendAudioContext = () => audioContext.suspend();

Maybe there are other problems related to this.
It should also prepare us for potentially attaching to several elements on the same document simultaneously.

IIRC the only benefit of using a shared one is performance. Not sure how bad creating several AudioContexts is, but I'm sure not super bad. But currently we only use one Controller at a time anyway, so it's not that we're gonna have a bunch of AudioContexts at simultaneously.
It used to be the case before fa678bf.

So I think we need to create a new one on each controller initialization.

@WofWca WofWca changed the title Use separate AudioContexts for each media element? fix: use separate AudioContexts for each media element? Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant