Skip to content

Commit

Permalink
Make StopAllSounds do what the name implies, and not stop all audio i…
Browse files Browse the repository at this point in the history
…nstead
  • Loading branch information
Kolfering committed Sep 26, 2024
1 parent aec34eb commit cb2a50a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions Source_Files/Misc/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ static void update_interface_fades(void);
static void interface_fade_out(short pict_resource_number, bool fade_music);
static bool can_interface_fade_out(void);
static void transfer_to_new_level(short level_number);
static void try_and_display_chapter_screen(short level, bool interface_table_is_valid, bool text_block, bool epilogue_screen);
static void try_and_display_chapter_screen(short level, bool interface_table_is_valid, bool text_block);

static screen_data *get_screen_data(
short index);
Expand Down Expand Up @@ -1710,7 +1710,7 @@ static void display_epilogue(
end_count = 2;
}
for (int i=0; i<end_count; i++)
try_and_display_chapter_screen(end_offset+i, true, true, true);
try_and_display_chapter_screen(end_offset+i, true, true);
show_cursor();
}

Expand Down Expand Up @@ -2350,7 +2350,7 @@ static void transfer_to_new_level(
return;
}

if (!game_is_networked) try_and_display_chapter_screen(level_number, true, false, false);
if (!game_is_networked) try_and_display_chapter_screen(level_number, true, false);
success= goto_level(&entry, dynamic_world->player_count, nullptr);
set_keyboard_controller_status(true);
}
Expand Down Expand Up @@ -2647,7 +2647,7 @@ static bool begin_game(
{
FindLevelMovie(entry.level_number);
show_movie(entry.level_number);
try_and_display_chapter_screen(entry.level_number, false, false, false);
try_and_display_chapter_screen(entry.level_number, false, false);
}

Plugins::instance()->set_mode(number_of_players > 1 ? Plugins::kMode_Net : Plugins::kMode_Solo);
Expand Down Expand Up @@ -3225,8 +3225,7 @@ static void handle_interface_menu_screen_click(
static void try_and_display_chapter_screen(
short level,
bool interface_table_is_valid,
bool text_block,
bool epilogue_screen)
bool text_block)
{
if (Movie::instance()->IsRecording() || !shell_options.replay_directory.empty())
return;
Expand All @@ -3238,7 +3237,7 @@ static void try_and_display_chapter_screen(
short existing_state= game_state.state;
game_state.state= _display_chapter_heading;

if (!epilogue_screen) SoundManager::instance()->StopAllSounds(); //don't stop the music if intro restarted for epilogue
SoundManager::instance()->StopAllSounds();

/* This will NOT work if the initial level entered has a chapter screen, which is why */
/* we perform this check. (The interface_color_table is not valid...) */
Expand Down
2 changes: 1 addition & 1 deletion Source_Files/Sound/OpenALManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class OpenALManager {
void Pause(bool paused);
void Start();
void Stop();
void StopAllPlayers();
std::shared_ptr<SoundPlayer> PlaySound(const Sound& sound, const SoundParameters& parameters);
std::shared_ptr<MusicPlayer> PlayMusic(std::shared_ptr<StreamDecoder> decoder, MusicParameters parameters);
std::shared_ptr<StreamPlayer> PlayStream(CallBackStreamPlayer callback, int length, int rate, bool stereo, AudioFormat audioFormat);
Expand Down Expand Up @@ -87,6 +86,7 @@ class OpenALManager {
bool paused_audio = false;
uint32_t elapsed_pause_time = 0;
AtomicStructure<world_location3d> listener_location = {};
void StopAllPlayers();
void UpdateParameters(const AudioParameters& parameters);
void UpdateListener();
void CleanEverything();
Expand Down
4 changes: 2 additions & 2 deletions Source_Files/Sound/SoundManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ std::shared_ptr<SoundPlayer> SoundManager::DirectPlaySound(short sound_index, an
}

void SoundManager::StopAllSounds() {
auto manager = OpenALManager::Get();
if (manager) manager->StopAllPlayers();
for (auto& soundPlayer : sound_players)
soundPlayer->AskStop();
}

int SoundManager::GetCurrentAudioTick() {
Expand Down

0 comments on commit cb2a50a

Please sign in to comment.