diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 0f08d7bc..ad795263 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -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 diff --git a/src/main/java/electrosphere/audio/AudioEngine.java b/src/main/java/electrosphere/audio/AudioEngine.java index 34fa7e00..7c9b247c 100644 --- a/src/main/java/electrosphere/audio/AudioEngine.java +++ b/src/main/java/electrosphere/audio/AudioEngine.java @@ -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; } diff --git a/src/main/java/electrosphere/audio/AudioSource.java b/src/main/java/electrosphere/audio/AudioSource.java index 4f180cc0..2c7eca7c 100644 --- a/src/main/java/electrosphere/audio/AudioSource.java +++ b/src/main/java/electrosphere/audio/AudioSource.java @@ -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(); }