File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
osu.Framework/Audio/Mixing/Bass Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -261,15 +261,9 @@ public bool StreamFree(IBassAudioChannel channel)
261261
262262 public void UpdateDevice ( int deviceIndex )
263263 {
264- if ( Handle == 0 )
265- createMixer ( ) ;
266- else
267- {
268- ManagedBass . Bass . ChannelSetDevice ( Handle , deviceIndex ) ;
269-
270- if ( manager ? . GlobalMixerHandle . Value != null )
271- BassMix . MixerAddChannel ( manager . GlobalMixerHandle . Value . Value , Handle , BassFlags . MixerChanBuffer | BassFlags . MixerChanNoRampin ) ;
272- }
264+ // It's important that we re-create the mixer after a device change.
265+ // The mixer may need to be initialised with different flags depending on the state of global mixer usage.
266+ createMixer ( ) ;
273267 }
274268
275269 protected override void UpdateState ( )
@@ -291,14 +285,15 @@ protected override void UpdateState()
291285 private void createMixer ( )
292286 {
293287 if ( Handle != 0 )
294- return ;
288+ ManagedBass . Bass . StreamFree ( Handle ) ;
295289
296290 // Make sure that bass is initialised before trying to create a mixer.
297291 // If not, this will be called again when the device is initialised via UpdateDevice().
298292 if ( ! ManagedBass . Bass . GetDeviceInfo ( ManagedBass . Bass . CurrentDevice , out var deviceInfo ) || ! deviceInfo . IsInitialized )
299293 return ;
300294
301295 Handle = manager ? . GlobalMixerHandle . Value != null
296+ // The decode flag here is super important to maintain the lowest latency audio output.
302297 ? BassMix . CreateMixerStream ( frequency , 2 , BassFlags . MixerNonStop | BassFlags . Decode )
303298 : BassMix . CreateMixerStream ( frequency , 2 , BassFlags . MixerNonStop ) ;
304299
You can’t perform that action at this time.
0 commit comments