-
Notifications
You must be signed in to change notification settings - Fork 8
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
Queue incoming events #28
Conversation
aarthificial
commented
Jan 24, 2025
- Requests the mic access first, before initiating a connection
- Queues any websocket events that may happen during AudioContext initialization
try { | ||
const parsedEvent = JSON.parse(event.data); | ||
if (!isValidSocketEvent(parsedEvent)) { | ||
return; |
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 should actually report this in console? Not a point of the PR so we can skip.
// some browsers won't allow calling getSupportedConstraints or enumerateDevices | ||
// before getting approval for microphone access | ||
const preliminaryInputStream = await navigator.mediaDevices.getUserMedia({ | ||
audio: true, | ||
}); | ||
preliminaryInputStream?.getTracks().forEach(track => track.stop()); | ||
|
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.
I think this was moved here to init the microphone before everything else, but we close it right after. I'm guessing it's solving the problem from your testing, but it's a bit weird that we'd close it here and then recreate shortly after without awaiting. Seems like it could still keep some issues.
Would it make sense to create Input
first instead here? That one already had this check, and we can await Input
creation before moving to anything else. This bit of the code would stay where it was, and the code related to input (and the comment) would stay in place where the input code was meant to be.
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.
Yes, this is how it used to be before. But the input can now have a different sampling rate depending on the agent configuration, so we need to establish a connection first, before we know how to set up the streams.
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.
Gotcha! Perhaps it could be within Input.prepare
method or something, which would be called here? The code (at least with the current comment about getSupportedConstraints or enumerateDevices) doesn't make much sense here.