Throw error if creation of buffered audio source fails.

This can happen if we're out of audio streams. Before, we just kinda pretended like everything was OK, which easily caused crash bugs in e.g. MIDI.

Ideally the audio engine would be less terrible and this could be handled better than "throw new Exception()", but I'm fixing a stack overflow here alright?
This commit is contained in:
Pieter-Jan Briers
2023-07-24 20:52:11 +02:00
parent 8270442d66
commit 8375a4038b
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ END TEMPLATE-->
### Bugfixes
*None yet*
* Fixed potential crashes if buffered audio sources (e.g. MIDI) fail to create due to running out of audio streams.
### Other
@@ -261,6 +261,9 @@ namespace Robust.Client.Graphics.Audio
{
var source = AL.GenSource();
if (!AL.IsSource(source))
throw new Exception("Failed to generate source. Too many simultaneous audio streams?");
// ReSharper disable once PossibleInvalidOperationException
var audioSource = new BufferedAudioSource(this, source, AL.GenBuffers(buffers), floatAudio);