diff --git a/source/core/audio/audio.cpp b/source/core/audio/audio.cpp index 9e8c5ea..9bcd52f 100644 --- a/source/core/audio/audio.cpp +++ b/source/core/audio/audio.cpp @@ -156,7 +156,6 @@ auto Audio::getMusicState() -> MusicState { return MusicState::PAUSED; case Ja::MusicState::STOPPED: case Ja::MusicState::INVALID: - case Ja::MusicState::DISABLED: default: return MusicState::STOPPED; } diff --git a/source/core/audio/jail_audio.cpp b/source/core/audio/jail_audio.cpp index c643ee5..d02a945 100644 --- a/source/core/audio/jail_audio.cpp +++ b/source/core/audio/jail_audio.cpp @@ -145,7 +145,7 @@ namespace Ja { } void Engine::updateCurrentMusic() { - if (!music_enabled_ || current_music_ == nullptr || current_music_->state != MusicState::PLAYING) { return; } + if (current_music_ == nullptr || current_music_->state != MusicState::PLAYING) { return; } updateIncomingFade(); @@ -156,8 +156,6 @@ namespace Ja { } void Engine::updateSoundChannels() { - if (!sound_enabled_) { return; } - for (int i = 0; i < MAX_SIMULTANEOUS_CHANNELS; ++i) { if (channels_[i].state != ChannelState::PLAYING) { continue; } @@ -214,7 +212,7 @@ namespace Ja { } void Engine::playMusic(Music* music, const int loop) { - if (!music_enabled_ || music == nullptr || music->vorbis == nullptr) { return; } + if (music == nullptr || music->vorbis == nullptr) { return; } stopMusic(); @@ -240,7 +238,6 @@ namespace Ja { } void Engine::pauseMusic() { - if (!music_enabled_) { return; } if (current_music_ == nullptr || current_music_->state != MusicState::PLAYING) { return; } current_music_->state = MusicState::PAUSED; @@ -248,7 +245,6 @@ namespace Ja { } void Engine::resumeMusic() { - if (!music_enabled_) { return; } if (current_music_ == nullptr || current_music_->state != MusicState::PAUSED) { return; } current_music_->state = MusicState::PLAYING; @@ -276,7 +272,6 @@ namespace Ja { } void Engine::fadeOutMusic(const int milliseconds) { - if (!music_enabled_) { return; } if (current_music_ == nullptr || current_music_->state != MusicState::PLAYING) { return; } stealCurrentIntoOutgoing(milliseconds); @@ -284,7 +279,7 @@ namespace Ja { } void Engine::crossfadeMusic(Music* music, const int crossfade_ms, const int loop) { - if (!music_enabled_ || music == nullptr || music->vorbis == nullptr) { return; } + if (music == nullptr || music->vorbis == nullptr) { return; } stealCurrentIntoOutgoing(crossfade_ms); @@ -312,7 +307,6 @@ namespace Ja { } auto Engine::getMusicState() const -> MusicState { - if (!music_enabled_) { return MusicState::DISABLED; } if (current_music_ == nullptr) { return MusicState::INVALID; } return current_music_->state; } @@ -325,11 +319,6 @@ namespace Ja { return music_volume_; } - void Engine::enableMusic(const bool value) { - if (!value && current_music_ != nullptr && (current_music_->state == MusicState::PLAYING)) { stopMusic(); } - music_enabled_ = value; - } - void Engine::onMusicDeleted(const Music* music) { if (music == nullptr) { return; } if (current_music_ == music) { @@ -341,7 +330,7 @@ namespace Ja { // --- Sound --- auto Engine::playSound(Sound* sound, const int loop, const int group) -> int { - if (!sound_enabled_ || sound == nullptr) { return -1; } + if (sound == nullptr) { return -1; } int channel = 0; while (channel < MAX_SIMULTANEOUS_CHANNELS && channels_[channel].state != ChannelState::FREE) { channel++; } @@ -354,7 +343,7 @@ namespace Ja { } auto Engine::playSoundOnChannel(Sound* sound, const int channel, const int loop, const int group) -> int { - if (!sound_enabled_ || sound == nullptr) { return -1; } + if (sound == nullptr) { return -1; } if (channel < 0 || channel >= MAX_SIMULTANEOUS_CHANNELS) { return -1; } stopChannel(channel); @@ -380,7 +369,6 @@ namespace Ja { } void Engine::pauseChannel(const int channel) { - if (!sound_enabled_) { return; } forEachTargetChannel(channel, [](Channel& ch) { if (ch.state == ChannelState::PLAYING) { ch.state = ChannelState::PAUSED; @@ -390,7 +378,6 @@ namespace Ja { } void Engine::resumeChannel(const int channel) { - if (!sound_enabled_) { return; } const SDL_AudioDeviceID DEVICE = sdl_audio_device_; forEachTargetChannel(channel, [DEVICE](Channel& ch) { if (ch.state == ChannelState::PAUSED) { @@ -435,13 +422,6 @@ namespace Ja { return V; } - void Engine::enableSound(const bool value) { - if (!value) { - stopChannel(-1); - } - sound_enabled_ = value; - } - void Engine::onSoundDeleted(const Sound* sound) { if (sound == nullptr) { return; } for (int i = 0; i < MAX_SIMULTANEOUS_CHANNELS; ++i) { diff --git a/source/core/audio/jail_audio.hpp b/source/core/audio/jail_audio.hpp index fc37b48..4571448 100644 --- a/source/core/audio/jail_audio.hpp +++ b/source/core/audio/jail_audio.hpp @@ -32,19 +32,16 @@ namespace Ja { // --- Public Enums --- enum class ChannelState : std::uint8_t { - INVALID, FREE, PLAYING, PAUSED, - SOUND_DISABLED, }; enum class MusicState : std::uint8_t { - INVALID, + INVALID, // Music carregat però mai play-ejat PLAYING, PAUSED, STOPPED, - DISABLED, }; // --- Constants --- @@ -136,7 +133,6 @@ namespace Ja { void crossfadeMusic(Music* music, int crossfade_ms, int loop = -1); [[nodiscard]] auto getMusicState() const -> MusicState; auto setMusicVolume(float volume) -> float; - void enableMusic(bool value); // Notifica al motor que un Music s'està destruint: si és el current_music // s'atura abans que els seus recursos (stream/vorbis) deixin de ser vàlids. void onMusicDeleted(const Music* music); @@ -148,7 +144,6 @@ namespace Ja { void resumeChannel(int channel); void stopChannel(int channel); auto setSoundVolume(float volume, int group = -1) -> float; - void enableSound(bool value); // Notifica al motor que un Sound s'està destruint: els canals que el // referenciïn es paren abans d'alliberar el buffer. void onSoundDeleted(const Sound* sound); @@ -168,8 +163,6 @@ namespace Ja { SDL_AudioSpec audio_spec_{DEFAULT_SPEC}; float music_volume_{1.0F}; float sound_volume_[MAX_GROUPS]{}; - bool music_enabled_{true}; - bool sound_enabled_{true}; SDL_AudioDeviceID sdl_audio_device_{0}; OutgoingMusic outgoing_music_; FadeState incoming_fade_;