Audio fix

This commit is contained in:
2026-03-14 19:11:59 +01:00
parent 52df67da09
commit b19f595daf
6 changed files with 67 additions and 37 deletions

View File

@@ -15,7 +15,7 @@ namespace Game::Audio {
SDL_AudioDeviceID getAudioDevice() const { return mDevice; }
private:
SDL_AudioSpec mAudioSpec;
SDL_AudioDeviceID mDevice;
SDL_AudioSpec mAudioSpec{};
SDL_AudioDeviceID mDevice = 0;
};
};

View File

@@ -32,6 +32,7 @@ namespace Game::Object {
Uint8* mAudioBuffer = nullptr;
Uint32 mAudioLength = 0;
SDL_AudioStream* mAudioStream = nullptr;
SDL_AudioSpec mSourceSpec{};
int mVolume;
};
}

View File

@@ -10,6 +10,7 @@
#include <state/gamestate.hpp>
#include <game/gamemanager.hpp>
#include <audio/audio.hpp>
#include <chrono>
namespace Game::Window {
class Window {
@@ -24,14 +25,19 @@ namespace Game::Window {
void setTargetFPS(int fps) { mTargetFPS = fps; }
int getTargetFPS() { return mTargetFPS; }
static SDL_Window* getSDLWindowBackend() { return sWindowBackend; }
Renderer::Renderer* getRenderer() { return &mRenderer; }
private:
static inline SDL_Window* sWindowBackend = nullptr;
SDL_Window* mWindow;
Renderer::Renderer mRenderer;
Game::GameManager mGameManager;
std::jthread mGameThread;
bool mRunning;
int mTargetFPS = 60;
size_t mFrameCount = 0;
std::chrono::steady_clock::time_point mLastFPSTime;
};
}