From 5c5f32cf5922620bb9ad4a6a2c7ddb867a92c3d2 Mon Sep 17 00:00:00 2001 From: Panos Karabelas Date: Wed, 12 Feb 2025 18:40:06 +0000 Subject: [PATCH] [github] removed fmod dll from workflow --- .github/workflows/workflow.yml | 4 +-- runtime/World/Components/AudioSource.cpp | 33 ++++++++++++------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 438391f1e..3354f016c 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -67,10 +67,10 @@ jobs: echo "Creating artifacts for ${{ matrix.api }} - ${{ matrix.configuration }}" IF "${{ matrix.configuration }}" == "Release" ( echo "Creating binaries-only archive for Release..." - build_scripts\7z.exe a -bb1 spartan_vulkan_release.7z .\binaries\7z.exe .\binaries\dxcompiler.dll .\binaries\download_assets.py .\binaries\file_utilities.py .\binaries\fmod.dll .\binaries\data .\binaries\spartan_${{ matrix.api }}.exe + build_scripts\7z.exe a -bb1 spartan_vulkan_release.7z .\binaries\7z.exe .\binaries\dxcompiler.dll .\binaries\download_assets.py .\binaries\file_utilities.py .\binaries\data .\binaries\spartan_${{ matrix.api }}.exe ) ELSE ( echo "Creating binaries-only archive for Debug..." - build_scripts\7z.exe a -bb1 spartan_vulkan_debug.7z .\binaries\7z.exe .\binaries\dxcompiler.dll .\binaries\download_assets.py .\binaries\file_utilities.py .\binaries\fmodL.dll .\binaries\data .\binaries\spartan_${{ matrix.api }}_debug.exe + build_scripts\7z.exe a -bb1 spartan_vulkan_debug.7z .\binaries\7z.exe .\binaries\dxcompiler.dll .\binaries\download_assets.py .\binaries\file_utilities.py .\binaries\data .\binaries\spartan_${{ matrix.api }}_debug.exe ) echo "Artifact creation completed for ${{ matrix.api }} - ${{ matrix.configuration }}" diff --git a/runtime/World/Components/AudioSource.cpp b/runtime/World/Components/AudioSource.cpp index ae1e2bb29..e370c11d6 100644 --- a/runtime/World/Components/AudioSource.cpp +++ b/runtime/World/Components/AudioSource.cpp @@ -24,12 +24,17 @@ connection with the software or the use or other dealings in the software. #include "AudioSource.h" #include "../../IO/FileStream.h" #include -#include //============================== using namespace std; using namespace spartan::math; +#define CHECK_SDL_ERROR(call) \ + if (!(call)) { \ + SP_LOG_ERROR("%s", SDL_GetError()); \ + return; \ + } + namespace spartan { AudioSource::AudioSource(Entity* entity) : Component(entity) @@ -115,11 +120,7 @@ namespace spartan // allocate an audio spec and load the wav file into our buffer m_spec = make_shared(); - if (!SDL_LoadWAV(file_path.c_str(), m_spec.get(), &m_buffer, &m_length)) - { - SP_LOG_ERROR("failed to load \"%s\": %s", file_path.c_str(), SDL_GetError()); - return; - } + CHECK_SDL_ERROR(SDL_LoadWAV(file_path.c_str(), m_spec.get(), &m_buffer, &m_length)); // open an audio stream with the wav file's spec, conversion to the hardware format is automatic m_stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, m_spec.get(), nullptr, nullptr); @@ -132,26 +133,26 @@ namespace spartan void AudioSource::Play() { - SDL_ResumeAudioStreamDevice(m_stream); + if (m_is_playing) + return; + CHECK_SDL_ERROR(SDL_ResumeAudioStreamDevice(m_stream)); // feed the entire wav data into the stream; for looping playback, you'll want to call this // again when the stream's available data falls below a certain threshold (in an update loop) - if (!SDL_PutAudioStreamData(m_stream, m_buffer, m_length)) - { - SP_LOG_ERROR("%s", SDL_GetError()); - return; - } + CHECK_SDL_ERROR(SDL_PutAudioStreamData(m_stream, m_buffer, m_length)); - m_is_playing = true; + m_is_playing = true; } void AudioSource::Stop() { - // pause the audio stream to halt playback - SDL_PauseAudioStreamDevice(m_stream); + if (!m_is_playing) + return; + // pause the audio stream to halt playback + CHECK_SDL_ERROR(!SDL_PauseAudioStreamDevice(m_stream)); // flush any queued audio data so that playback starts from the beginning next time - SDL_FlushAudioStream(m_stream); + CHECK_SDL_ERROR(SDL_FlushAudioStream(m_stream)); m_is_playing = false; }