From c328d0c85c6add8534ceb85f95497bd3bb44f798 Mon Sep 17 00:00:00 2001 From: player-03 Date: Fri, 7 Jan 2022 20:44:28 -0500 Subject: [PATCH] Make sure `NativeAudioSource.handle` is non-null. Using `getGain()` and `setGain()` as a template. Like gain, you won't be able to set pitch before calling `init()`. --- .../_internal/backend/native/NativeAudioSource.hx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lime/_internal/backend/native/NativeAudioSource.hx b/src/lime/_internal/backend/native/NativeAudioSource.hx index 00ccc24fd..5a3a2070a 100644 --- a/src/lime/_internal/backend/native/NativeAudioSource.hx +++ b/src/lime/_internal/backend/native/NativeAudioSource.hx @@ -512,7 +512,14 @@ class NativeAudioSource public function getPitch():Float { - return AL.getSourcef(handle, AL.PITCH); + if (handle != null) + { + return AL.getSourcef(handle, AL.PITCH); + } + else + { + return 1; + } } public function setPitch(value:Float):Float @@ -533,7 +540,10 @@ class NativeAudioSource } } - AL.sourcef(handle, AL.PITCH, value); + if (handle != null) + { + AL.sourcef(handle, AL.PITCH, value); + } return value; }