mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Fix crashing when using OpenAL backend (Thanks Vladcosmonaut)
This commit is contained in:
parent
42c38611df
commit
998768b9f7
@ -61,12 +61,15 @@ namespace ClassicalSharp.Audio {
|
|||||||
PlayCurrentSound( stereoOutputs );
|
PlayCurrentSound( stereoOutputs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IAudioOutput firstSoundOut;
|
||||||
void PlayCurrentSound( IAudioOutput[] outputs ) {
|
void PlayCurrentSound( IAudioOutput[] outputs ) {
|
||||||
for( int i = 0; i < monoOutputs.Length; i++ ) {
|
for( int i = 0; i < monoOutputs.Length; i++ ) {
|
||||||
IAudioOutput output = outputs[i];
|
IAudioOutput output = outputs[i];
|
||||||
if( output == null ) {
|
if( output == null ) {
|
||||||
output = GetPlatformOut();
|
output = GetPlatformOut();
|
||||||
output.Create( 1 );
|
output.Create( 1, firstSoundOut );
|
||||||
|
if( firstSoundOut == null )
|
||||||
|
firstSoundOut = output;
|
||||||
outputs[i] = output;
|
outputs[i] = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +83,8 @@ namespace ClassicalSharp.Audio {
|
|||||||
void DisposeSound() {
|
void DisposeSound() {
|
||||||
DisposeOutputs( ref monoOutputs );
|
DisposeOutputs( ref monoOutputs );
|
||||||
DisposeOutputs( ref stereoOutputs );
|
DisposeOutputs( ref stereoOutputs );
|
||||||
|
if( firstSoundOut != null )
|
||||||
|
firstSoundOut.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisposeOutputs( ref IAudioOutput[] outputs ) {
|
void DisposeOutputs( ref IAudioOutput[] outputs ) {
|
||||||
@ -97,7 +102,7 @@ namespace ClassicalSharp.Audio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < outputs.Length; i++ ) {
|
for( int i = 0; i < outputs.Length; i++ ) {
|
||||||
if( outputs[i] == null ) continue;
|
if( outputs[i] == null || outputs[i] == firstSoundOut ) continue;
|
||||||
outputs[i].Dispose();
|
outputs[i].Dispose();
|
||||||
}
|
}
|
||||||
outputs = null;
|
outputs = null;
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user