fix for ground audio bug
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-10-16 16:29:12 -04:00
parent 6409d752de
commit db043eda43
3 changed files with 14 additions and 3 deletions

View File

@ -868,6 +868,7 @@ Work on separating procedural tree generation steps
(10/16/2024)
Camera offset definitions in entity files
Non-Lsystem pine tree
Potential fix for ground audio bug
# TODO

View File

@ -344,12 +344,15 @@ public class AudioEngine {
/**
* Checks for an error
* @return true if an error was thrown, false otherwise
*/
public void checkError(){
public boolean checkError(){
String latestMessage = this.getLatestErrorMessage();
if(latestMessage != null){
LoggerInterface.loggerAudio.ERROR(new IllegalStateException(latestMessage));
return true;
}
return false;
}

View File

@ -18,6 +18,11 @@ public class AudioSource {
*/
static final int UNDEFINED_ID = -1;
/**
* This id is being sent for some reason, and it is an invalid id
*/
static final int INVALID_ID = 0;
//The id for the source
int sourceId = UNDEFINED_ID;
@ -98,7 +103,9 @@ public class AudioSource {
if(isAllocated()){
LoggerInterface.loggerAudio.DEBUG("Set Gain: " + gain);
AL10.alSourcef(sourceId, AL10.AL_GAIN, gain);
Globals.audioEngine.checkError();
if(Globals.audioEngine.checkError()){
LoggerInterface.loggerAudio.WARNING("Audio source id for error: " + sourceId);
}
}
}
@ -151,7 +158,7 @@ public class AudioSource {
* Stops the audio source
*/
public void stop() {
if(isAllocated()){
if(isAllocated() && this.sourceId != INVALID_ID){
AL10.alSourceStop(sourceId);
Globals.audioEngine.checkError();
}