Description
Am I correct, when I assume that there is a 1:1 relation between an Audio Device Client and an AudioContext? Each Audio Device Client can only have one AudioContext and each AudioContext can only belong to one Audio Device Client. But an AudioContext is optional and an Audio Device Client can exist without an AudioContext associated to it.
If my assumption is correct, I think it would make sense to flip around the process of creating an AudioContext associated to an Audio Device Client. If there is a getContext()
method on the Audio Device Client, it implies that the context is already there and just has to be returned. If the AudioContext would just be created as usual but with an additional constructor argument it might better reflect what is actually going on behind the scenes.
const ac = new AudioContext({ deviceClient: myPreviouslyCreatedAudioDeviceClient });
// This will then throw an error, because there is already
// a context associated to the same Audio Device Client
const ac2 = new AudioContext({ deviceClient: myPreviouslyCreatedAudioDeviceClient });