From 4146df48a96de9ad99368d9e7c4e09843be49200 Mon Sep 17 00:00:00 2001 From: h4570 Date: Sat, 6 Feb 2021 18:45:03 +0100 Subject: [PATCH] fixed audio playing - dirty way --- src/engine/include/modules/audio.hpp | 1 + src/engine/modules/audio.cpp | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/engine/include/modules/audio.hpp b/src/engine/include/modules/audio.hpp index be2709a..1899cd7 100644 --- a/src/engine/include/modules/audio.hpp +++ b/src/engine/include/modules/audio.hpp @@ -126,6 +126,7 @@ public: private: u8 songLoaded, volume, realVolume, songPlaying, songInLoop, songFinished; + u8 hack; // TODO std::vector songListeners; FILE *wav; audsrv_fmt_t format; diff --git a/src/engine/modules/audio.cpp b/src/engine/modules/audio.cpp index 0c8b052..f7b51c0 100644 --- a/src/engine/modules/audio.cpp +++ b/src/engine/modules/audio.cpp @@ -178,8 +178,20 @@ void Audio::startThread(FileService *t_fileService) /** Main thread loop */ void Audio::threadLoop() { - if (songPlaying) - songPlaying = 1; // GCC11: wtf? we need to put some code there, because song is not playing.. + // --- + // TODO - bug here, GCC11 is doing some optimizations and this method probably think that + // "songPlaying" is false + on real PS2 I see that program tries to turn on this + // method as rarely as possible (slow, flickering sound). On GCC 3.2.3 this one was fine lol!. + if (songPlaying) // HACK1 - im not proud of that + songPlaying = 1; + if (songLoaded) + songLoaded = 1; + if (hack == 1) // HACK2 - lets give some work to gcc lol + hack = 2; + else + hack = 1; + // --- + if (!songPlaying || !songLoaded) return; if (songFinished)