fix audio bugs
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
f9e12553c9
commit
83185bb8ce
@ -1339,6 +1339,8 @@ Increase fall delay
|
||||
Rearchitect foliage rendering to combat grass pop-in/pop-out
|
||||
Increase sim range to fight game object pop-in
|
||||
Filter select-able saves on singleplayer screen to full game saves
|
||||
Increase number of invalid openAL IDs
|
||||
Fix audio engine not cleaning up audio sources
|
||||
|
||||
|
||||
|
||||
|
||||
@ -207,8 +207,8 @@ public class AudioEngine {
|
||||
* Updates the audio engine
|
||||
*/
|
||||
public void update(){
|
||||
updateListener();
|
||||
updateOpenALSources();
|
||||
this.updateListener();
|
||||
this.updateOpenALSources();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -33,11 +33,15 @@ public class AudioSource {
|
||||
protected static AudioSource create(boolean loop){
|
||||
AudioSource rVal = new AudioSource();
|
||||
rVal.sourceId = AL10.alGenSources();
|
||||
if(rVal.sourceId == AudioSource.INVALID_ID){
|
||||
throw new Error("Was allocated an invalid id from openAL! " + rVal.sourceId);
|
||||
}
|
||||
Globals.audioEngine.checkError();
|
||||
if(loop){
|
||||
AL10.alSourcei(rVal.sourceId, AL10.AL_LOOPING, AL10.AL_TRUE);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
Globals.audioEngine.registerSource(rVal);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -46,8 +50,8 @@ public class AudioSource {
|
||||
* @param bufferId The id of the buffer
|
||||
*/
|
||||
public void setBuffer(int bufferId) {
|
||||
stop();
|
||||
if(isAllocated()){
|
||||
this.stop();
|
||||
if(this.isAllocated()){
|
||||
AL10.alSourcei(sourceId, AL10.AL_BUFFER, bufferId);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -58,7 +62,7 @@ public class AudioSource {
|
||||
* @param position the position
|
||||
*/
|
||||
public void setPosition(Vector3f position) {
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
AL10.alSource3f(sourceId, AL10.AL_POSITION, position.x, position.y, position.z);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -69,7 +73,7 @@ public class AudioSource {
|
||||
* @param speed the speed
|
||||
*/
|
||||
public void setSpeed(Vector3f speed) {
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
AL10.alSource3f(sourceId, AL10.AL_VELOCITY, speed.x, speed.y, speed.z);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -89,7 +93,7 @@ public class AudioSource {
|
||||
* @param time The time in seconds
|
||||
*/
|
||||
public void setOffset(float time){
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
AL10.alSourcef(sourceId, AL11.AL_SEC_OFFSET, time);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -100,7 +104,7 @@ public class AudioSource {
|
||||
* @param gain the gain
|
||||
*/
|
||||
public void setGain(float gain) {
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
LoggerInterface.loggerAudio.DEBUG("Set Gain: " + gain);
|
||||
AL10.alSourcef(sourceId, AL10.AL_GAIN, gain);
|
||||
if(Globals.audioEngine.checkError()){
|
||||
@ -115,7 +119,7 @@ public class AudioSource {
|
||||
* @param value The value to set the param to
|
||||
*/
|
||||
public void setProperty(int param, float value) {
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
AL10.alSourcef(sourceId, param, value);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -125,7 +129,7 @@ public class AudioSource {
|
||||
* Plays the audio source
|
||||
*/
|
||||
public void play() {
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
AL10.alSourcePlay(sourceId);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -137,7 +141,7 @@ public class AudioSource {
|
||||
*/
|
||||
public boolean isPlaying() {
|
||||
boolean isPlaying = false;
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
isPlaying = AL10.alGetSourcei(sourceId, AL10.AL_SOURCE_STATE) == AL10.AL_PLAYING;
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -148,7 +152,7 @@ public class AudioSource {
|
||||
* Pauses the audio source
|
||||
*/
|
||||
public void pause() {
|
||||
if(isAllocated()){
|
||||
if(this.isAllocated()){
|
||||
AL10.alSourcePause(sourceId);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -158,7 +162,7 @@ public class AudioSource {
|
||||
* Stops the audio source
|
||||
*/
|
||||
public void stop() {
|
||||
if(isAllocated() && this.sourceId != INVALID_ID){
|
||||
if(this.isAllocated()){
|
||||
AL10.alSourceStop(sourceId);
|
||||
Globals.audioEngine.checkError();
|
||||
}
|
||||
@ -180,6 +184,6 @@ public class AudioSource {
|
||||
* @return true if allocated, false otherwise
|
||||
*/
|
||||
private boolean isAllocated(){
|
||||
return sourceId != UNDEFINED_ID;
|
||||
return sourceId != UNDEFINED_ID && this.sourceId != INVALID_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public class AudioUtils {
|
||||
* @return The audio source
|
||||
*/
|
||||
protected static AudioSource playAudioAtLocation(String audioFile, Vector3d position, boolean loops){
|
||||
return playAudioAtLocation(audioFile,new Vector3f((float)position.x,(float)position.y,(float)position.z),loops);
|
||||
return AudioUtils.playAudioAtLocation(audioFile,new Vector3f((float)position.x,(float)position.y,(float)position.z),loops);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,6 +8,7 @@ import java.util.Random;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType;
|
||||
import electrosphere.client.terrain.sampling.ClientVoxelSampler;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.game.data.audio.SurfaceAudioCollection;
|
||||
import electrosphere.game.data.audio.SurfaceAudioType;
|
||||
@ -101,6 +102,10 @@ public class MovementAudioService {
|
||||
String rVal = null;
|
||||
SurfaceAudioType surfaceAudio = this.defaultSurfaceAudio;
|
||||
|
||||
if(voxelType == ClientVoxelSampler.INVALID_POSITION){
|
||||
return null;
|
||||
}
|
||||
|
||||
//Check if ignored
|
||||
if(this.ignoredVoxelTypes != null){
|
||||
for(int ignoredVoxelType : this.ignoredVoxelTypes){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user