@@ -91,6 +91,7 @@ import {
9191 isRemotePub ,
9292 isSafari ,
9393 isWeb ,
94+ sleep ,
9495 supportsSetSinkId ,
9596 toHttpUrl ,
9697 unpackStreamId ,
@@ -1774,24 +1775,24 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
17741775 this . audioContext = getNewAudioContext ( ) ?? undefined ;
17751776 }
17761777
1778+ if ( this . options . webAudioMix ) {
1779+ this . remoteParticipants . forEach ( ( participant ) =>
1780+ participant . setAudioContext ( this . audioContext ) ,
1781+ ) ;
1782+ }
1783+
1784+ this . localParticipant . setAudioContext ( this . audioContext ) ;
1785+
17771786 if ( this . audioContext && this . audioContext . state === 'suspended' ) {
17781787 // for iOS a newly created AudioContext is always in `suspended` state.
17791788 // we try our best to resume the context here, if that doesn't work, we just continue with regular processing
17801789 try {
1781- await this . audioContext . resume ( ) ;
1790+ await Promise . race ( [ this . audioContext . resume ( ) , sleep ( 200 ) ] ) ;
17821791 } catch ( e : any ) {
17831792 this . log . warn ( 'Could not resume audio context' , { ...this . logContext , error : e } ) ;
17841793 }
17851794 }
17861795
1787- if ( this . options . webAudioMix ) {
1788- this . remoteParticipants . forEach ( ( participant ) =>
1789- participant . setAudioContext ( this . audioContext ) ,
1790- ) ;
1791- }
1792-
1793- this . localParticipant . setAudioContext ( this . audioContext ) ;
1794-
17951796 const newContextIsRunning = this . audioContext ?. state === 'running' ;
17961797 if ( newContextIsRunning !== this . canPlaybackAudio ) {
17971798 this . audioEnabled = newContextIsRunning ;
0 commit comments