Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.6k views
in Technique[技术] by (71.8m points)

Chrome produces no audio after reaching 50 audio output streams

During my testing, I have found out that reaching 50 audio output streams (as displayed in chrome://media-internals/ Audio tab) on a single tab causes the audio output to disappear. Does Chrome have a set maximum limit of audio output streams allowed per displayed tab? If so, is there some workaround for that? The Chrome version that I am using is Version 87.0.4280.141.

Whenever we're muting/unmuting the audio(second function below) and adjusting the mic volume(first function below), we create a new audio context. Does too many audio context instances caused the issue?

private setLocalStreamVolume(stream: MediaStream | undefined) {
    const context = new AudioContext()
    const destination = context.createMediaStreamDestination()
    const gainNode = context.createGain()
    if (stream) {
        for(const track of stream.getTracks()){
            const sourceStream = context.createMediaStreamSource(new MediaStream([track]));    
            sourceStream.connect(gainNode)
            gainNode.connect(destination)
            gainNode.gain.value = this._micVolume            
        }        
    }
    return destination.stream
  }


export function mixStreams(streams: Iterable<(MediaStream | undefined)>) {
    const context = new AudioContext()
    const mixedOutput = context.createMediaStreamDestination()
    for(const stream of streams)
        if(stream)
            for(const track of stream.getTracks()){
                const sourceStream = context.createMediaStreamSource(new MediaStream([track]));
                sourceStream.connect(mixedOutput);
            }
    return mixedOutput.stream.getTracks()[0]
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Does too many audio context interactions caused the issue?

Too many AudioContext instances certainly will. In fact, on some systems you can only use a single AudioContext.

I'm not sure what your specific use case is, but you probably only need one AudioContext. All your MediaStreamSourceNodes can live in the same context.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...