Subsistema d'àudio: port de ../aee/core/audio refactoritzat amb namespace Ja, desacoblat d'Options via Audio::Config i extensió de Resource::Cache per preloading de música i sons; pyramid_1.ogg sona a GameScene (v0.15.0)

This commit is contained in:
JailDesigner committed 2026-04-19 23:19:20 +02:00
1 parent 6f3fafbfff
commit e2b8d0e459
16 files changed
+6796 -5

No files matched your search

+16
View File
@@ -28,10 +28,24 @@ namespace Resource {
// Carrega una paleta (.pal JASC o .gif) i la registra amb el nom donat.
// Pensat per a paletes compartides (UI, fonts, tilesets reciclats).
void loadPalette(const std::string& name, const std::string& file_path);
// Carrega una pista OGG de música (streaming) i la registra amb el nom donat.
void loadMusic(const std::string& name, const std::string& file_path);
// Carrega un so WAV (descomprimit a memòria) i el registra amb el nom donat.
void loadSound(const std::string& name, const std::string& file_path);
auto getSurface(const std::string& name) -> std::shared_ptr<Surface>;
auto getAnimationData(const std::string& name) -> const AnimationResource&;
auto getPalette(const std::string& name) -> const Palette&;
// Retornen el punter cru; l'ownership queda al Cache.
auto getMusic(const std::string& name) -> Ja::Music*;
auto getSound(const std::string& name) -> Ja::Sound*;
// Allibera explícitament música i sons. Cal cridar-la des de ~Director
// ABANS de destruir Audio i de SDL_Quit(): com que el Cache és Meyers
// i es destrueix a la sortida del programa, si esperem els seus
// destructors els streams de SDL ja estarien invalidats i la deletion
// de Ja::Music crashejaria.
void clearAudio();
private:
Cache() = default;
@@ -40,6 +54,8 @@ namespace Resource {
std::vector<SurfaceResource> surfaces_;
std::vector<AnimationResource> animations_;
std::vector<PaletteResource> palettes_;
std::vector<MusicResource> musics_;
std::vector<SoundResource> sounds_;
};
} // namespace Resource