From e35e4c5a1598c70c9da81cb66046663ab0cf146f Mon Sep 17 00:00:00 2001 From: Raffaello Bertini Date: Fri, 20 Oct 2023 11:27:35 +0100 Subject: [PATCH] fix IMusicDriver play if no audio resurce/file was set --- CMakeLists.txt | 2 +- .../src/HyperSonicDrivers/drivers/MIDDriver.cpp | 3 +++ .../src/HyperSonicDrivers/drivers/westwood/ADLDriver.cpp | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f39d224a..7cf37b37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) endif() -project ("sdl2-hyper-sonic-drivers" VERSION 0.12.1 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards") +project ("sdl2-hyper-sonic-drivers" VERSION 0.12.2 DESCRIPTION "SDL2 based Hyper-Sonic Drivers for emulating old soundcards") include (TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) if(IS_BIG_ENDIAN) diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/MIDDriver.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/MIDDriver.cpp index 79d4d5c5..f2dec378 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/MIDDriver.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/MIDDriver.cpp @@ -164,6 +164,9 @@ namespace HyperSonicDrivers::drivers void MIDDriver::play(const uint8_t track) noexcept { + if (m_midi == nullptr) + return; + if (track >= m_midi->numTracks) { logW(std::format("track not available: {}", track)); diff --git a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/westwood/ADLDriver.cpp b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/westwood/ADLDriver.cpp index 43e2b4ac..cb1ec3d8 100644 --- a/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/westwood/ADLDriver.cpp +++ b/sdl2-hyper-sonic-drivers/src/HyperSonicDrivers/drivers/westwood/ADLDriver.cpp @@ -233,6 +233,9 @@ namespace HyperSonicDrivers::drivers::westwood void ADLDriver::play(const uint8_t track) noexcept { std::scoped_lock lock(m_mutex); + + if (m_adl_file == nullptr) + return; constexpr uint8_t volume = std::numeric_limits::max(); const uint16_t soundId = m_adl_file->getTrack(track);