Skip to content

Commit

Permalink
Fixes #14 missing context attributes buffer termination
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias <[email protected]>
  • Loading branch information
Hangman committed Jan 22, 2024
1 parent 815c286 commit 2ac3b04
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions core/src/main/java/de/pottgames/tuningfork/AudioDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ public boolean enableHrtf(String specifier) {
* Disables hrtf on this device.
*/
public void disableHrtf() {
if (!this.isHrtfSupported()) {
this.logger.warn(this.getClass(), "HRTF is not supported by this device and was never enabled.");
return;
}

if (this.isHrtfSupported()) {
// SET NEW DEVICE ATTRIBUTES
final ContextAttributes oldAttributes = this.contextAttributes;
Expand All @@ -486,15 +491,17 @@ public void disableHrtf() {
this.contextAttributes = new ContextAttributes(attributes);

// RESET DEVICE
if (SOFTHRTF.alcResetDeviceSOFT(this.deviceHandle, attributes)) {
this.hrtfEnabled = false;
this.logger.info(this.getClass(), "HRTF disabled.");
} else {
if (!SOFTHRTF.alcResetDeviceSOFT(this.deviceHandle, this.contextAttributes.getBuffer())) {
this.contextAttributes = oldAttributes;
this.logger.error(this.getClass(), "Failed to reset device: " + ALC10.alcGetString(this.deviceHandle, ALC10.alcGetError(this.deviceHandle)));
return;

}
this.hrtfEnabled = false;
this.logger.info(this.getClass(), "HRTF disabled.");
if (this.deviceRerouter != null) {
this.deviceRerouter.updateContextAttributes(this.contextAttributes);
}
} else {
this.logger.warn(this.getClass(), "HRTF is not supported by this device and was therefore never enabled.");
}
}

Expand Down

0 comments on commit 2ac3b04

Please sign in to comment.