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

[question] snapstream in a separate thread .. #40

Closed
fredele opened this issue Jan 28, 2022 · 4 comments
Closed

[question] snapstream in a separate thread .. #40

fredele opened this issue Jan 28, 2022 · 4 comments

Comments

@fredele
Copy link

fredele commented Jan 28, 2022

Hello,
I've integrated a javascript snapstream in a web application of my own, basically a remote controlled audio player ( a python flask webserver embding a gstreamer playbin sending audio data to snapserver and a mongoDB database with a webapp as "controller", works like mopidy for the comparison ... )

I can clearly play the audio on the "controller" webapp, no problem with that.
But when I have a big content response from one of my API endpoint, the audio is stuttering 1-2 seconds due to the temporary heavy processing of the request response.

Is there a way to put a javascript snapstream object in a Web Worker ? I believe not, because there's no audiocontext in a Web Worker ... So is there an other way ? I'm not familiar with Web Audio API ...
I wonder if somebody knows what I can do ...

@Pajn
Copy link

Pajn commented Jan 28, 2022

Without deep knowledge about this I would guess your best bet is to follow WebAudio/web-audio-api#2423

@fredele
Copy link
Author

fredele commented Jan 28, 2022

It seems that going this way is takling the limits of what Chromium can do ...

I've looked at the source code in snapstream.js and I wonder if putting all the websocket thing in a web worker, all the rest (sending audio) in the main thread would solve the problem, but it's too complicated to do for me and I'm not sure if it will work as expected.

I'll simply live with the separate snapclient for now I think ..

@kingosticks
Copy link

You might find some inspiration at https://github.com/geekuillaume/soundsync/tree/master/src/audio but note the project itself is webrtc based rather than tcp sockets so it's a little different.

@fredele
Copy link
Author

fredele commented Feb 3, 2022

Finally, I've done it the other way.
My pages where not javascript optimized : avoiding too big images, limiting DOM access from javascript and things are mutch better.
Finally, I've a remote controlled audio player with sound everywhere ... fantastic !
Thank you all for your participation.

@fredele fredele closed this as completed Feb 3, 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

3 participants