void PlayCurrentSound(IAudioOutput[] outputs, float volume) { for (int i = 0; i < outputs.Length; i++) { IAudioOutput output = outputs[i]; if (output == null) { output = MakeOutput(1); outputs[i] = output; } else { if (!output.IsFinished()) { continue; } } AudioFormat fmt = output.Format; if (fmt.Channels == 0 || fmt.Equals(format)) { PlaySound(output, volume); return; } } // This time we try to play the sound on all possible devices, // even if it requires the expensive case of recreating a device for (int i = 0; i < outputs.Length; i++) { IAudioOutput output = outputs[i]; if (!output.IsFinished()) { continue; } PlaySound(output, volume); return; } }