From 085ea54f4e7a28957f7f5fbad00f7471c8fe3f57 Mon Sep 17 00:00:00 2001 From: "Enzo Persillet (Tutez)" Date: Mon, 18 May 2026 05:19:51 +0200 Subject: [PATCH] Prefer native WAV decoding before SDL_sound Try Lime's native WAV decoder before SDL_sound for eager audio buffer loading. This avoids SDL_sound introducing artifacts for some PCM WAV files loaded from bytes, while keeping SDL_sound as a fallback for formats or WAV variants not handled by the native decoder. --- project/src/ExternalInterface.cpp | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 0fcb20e6e7..c48859613d 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -423,20 +423,19 @@ namespace lime { bytes.Set (data); resource = Resource (&bytes); - #ifdef LIME_SDL_SOUND - if (SDLSound::Decode (&resource, &audioBuffer)) { + if (WAV::Decode (&resource, &audioBuffer)) { return audioBuffer.Value (buffer); } - #endif - - if (WAV::Decode (&resource, &audioBuffer)) { + #ifdef LIME_SDL_SOUND + if (SDLSound::Decode (&resource, &audioBuffer)) { return audioBuffer.Value (buffer); } + #endif #ifdef LIME_OGG if (OGG::Decode (&resource, &audioBuffer)) { @@ -455,19 +454,19 @@ namespace lime { Resource resource = Resource (data); - #ifdef LIME_SDL_SOUND - if (SDLSound::Decode (&resource, buffer)) { + if (WAV::Decode (&resource, buffer)) { return buffer; } - #endif - if (WAV::Decode (&resource, buffer)) { + #ifdef LIME_SDL_SOUND + if (SDLSound::Decode (&resource, buffer)) { return buffer; } + #endif #ifdef LIME_OGG if (OGG::Decode (&resource, buffer)) { @@ -490,19 +489,19 @@ namespace lime { resource = Resource (val_string (data)); - #ifdef LIME_SDL_SOUND - if (SDLSound::Decode (&resource, &audioBuffer)) { + if (WAV::Decode (&resource, &audioBuffer)) { return audioBuffer.Value (buffer); } - #endif - if (WAV::Decode (&resource, &audioBuffer)) { + #ifdef LIME_SDL_SOUND + if (SDLSound::Decode (&resource, &audioBuffer)) { return audioBuffer.Value (buffer); } + #endif #ifdef LIME_OGG if (OGG::Decode (&resource, &audioBuffer)) { @@ -521,19 +520,19 @@ namespace lime { Resource resource = Resource (data ? hl_to_utf8 ((const uchar*)data->bytes) : NULL); - #ifdef LIME_SDL_SOUND - if (SDLSound::Decode (&resource, buffer)) { + if (WAV::Decode (&resource, buffer)) { return buffer; } - #endif - if (WAV::Decode (&resource, buffer)) { + #ifdef LIME_SDL_SOUND + if (SDLSound::Decode (&resource, buffer)) { return buffer; } + #endif #ifdef LIME_OGG if (OGG::Decode (&resource, buffer)) {