Skip to content

Commit

Permalink
Fixes AudioDevice.disableHrtf() (backport from master)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias <webmaster@pottgames.de>
  • Loading branch information
Hangman committed Jan 22, 2024
1 parent eab9ffa commit 28906c2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions core/src/main/java/de/pottgames/tuningfork/AudioDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,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 @@ -485,15 +490,16 @@ 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 28906c2

Please sign in to comment.