File tree Expand file tree Collapse file tree 4 files changed +32
-10
lines changed
Expand file tree Collapse file tree 4 files changed +32
-10
lines changed Original file line number Diff line number Diff line change @@ -1736,6 +1736,7 @@ export class FastStreamClient extends EventEmitter {
17361736 }
17371737 this . resetFailed ( ) ;
17381738 this . updateQualityLevels ( ) ;
1739+ this . audioConfigManager . updateChannelCount ( ) ;
17391740 }
17401741 }
17411742
Original file line number Diff line number Diff line change @@ -625,6 +625,11 @@ export class AudioChannelMixer extends AbstractAudioModule {
625625 els . dynButton . classList . toggle ( 'configured' , isEqActive || isCompActive ) ;
626626 }
627627
628+ updateChannelCount ( ) {
629+ this . updateNodes ( ) ;
630+ if ( this . masterNodes . compressor ) this . masterNodes . compressor . updateChannelCount ( ) ;
631+ }
632+
628633 async updateNodes ( ) {
629634 if ( ! this . audioContext ) return ;
630635
Original file line number Diff line number Diff line change @@ -73,6 +73,19 @@ export class AudioCompressor extends AbstractAudioModule {
7373 this . updateCompressor ( ) ;
7474 }
7575
76+ updateChannelCount ( ) {
77+ const count = this . numberOfChannelsGetter ? this . numberOfChannelsGetter ( ) . catch ( ( e ) => 0 ) : 2 ;
78+ if ( count && this . compressorNode ) {
79+ if ( count > 2 && ( ! this . splitterNode || this . splitterNode . numberOfOutputs !== Math . min ( count , 6 ) ) ) {
80+ this . destroyCompressorNodes ( ) ;
81+ this . createCompressorNodes ( ) ;
82+ } else if ( count <= 2 && this . splitterNode ) {
83+ this . destroyCompressorNodes ( ) ;
84+ this . createCompressorNodes ( ) ;
85+ }
86+ }
87+ }
88+
7689 async updateCompressor ( ) {
7790 if ( ! this . compressorConfig ) return ;
7891
Original file line number Diff line number Diff line change @@ -452,7 +452,7 @@ export class AudioConfigManager extends AbstractAudioModule {
452452 super . setupNodes ( audioContext ) ;
453453
454454 try {
455- this . discardChannelCount ( ) ;
455+ this . updateChannelCount ( ) ;
456456 this . audioUpscaler . setupNodes ( this . audioContext ) ;
457457 this . audioChannelMixer . setupNodes ( this . audioContext ) ;
458458 this . audioCrosstalk . setupNodes ( this . audioContext ) ;
@@ -463,20 +463,23 @@ export class AudioConfigManager extends AbstractAudioModule {
463463 this . audioChannelMixer . getOutputNode ( ) . connect ( this . audioCrosstalk . getInputNode ( ) ) ;
464464 this . audioCrosstalk . getOutputNode ( ) . connect ( this . finalGain . getInputNode ( ) ) ;
465465 this . finalGain . getOutputNode ( ) . connect ( this . getOutputNode ( ) ) ;
466-
467- this . getChannelCount ( ) . then ( ( count ) => {
468- if ( count === 1 ) {
469- this . audioUpscaler . enable ( ) ;
470- } else {
471- this . audioUpscaler . disable ( ) ;
472- }
473- } ) . catch ( ( e ) => {
474- } ) ;
475466 } catch ( e ) {
476467 AlertPolyfill . errorSendToDeveloper ( e ) ;
477468 }
478469 }
479470
471+ updateChannelCount ( ) {
472+ this . discardChannelCount ( ) ;
473+ this . getChannelCount ( ) . then ( ( count ) => {
474+ if ( count === 1 ) {
475+ this . audioUpscaler . enable ( ) ;
476+ } else {
477+ this . audioUpscaler . disable ( ) ;
478+ }
479+ this . audioChannelMixer . updateChannelCount ( ) ;
480+ } ) . catch ( ( e ) => {
481+ } ) ;
482+ }
480483
481484 async getChannelCount ( ) {
482485 if ( ! this . audioContext ) {
You can’t perform that action at this time.
0 commit comments