From 59317743fa40576e8b3ec2068393038581239c49 Mon Sep 17 00:00:00 2001 From: milek7 Date: Fri, 25 Aug 2017 20:24:06 +0200 Subject: [PATCH] configurable complex_sound stop during beginning behavior --- Globals.cpp | 12 ++++++++++++ Globals.h | 11 ++++++++++- sound.cpp | 12 ++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/Globals.cpp b/Globals.cpp index dc271446..bcfd5ca8 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -204,6 +204,7 @@ int Global::iMWDdivider = 5; opengl_light Global::DayLight; Global::soundmode_t Global::soundpitchmode = Global::linear; Global::soundmode_t Global::soundgainmode = Global::linear; +Global::soundstopmode_t Global::soundstopmode = Global::queue; //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -571,6 +572,17 @@ void Global::ConfigParse(cParser &Parser) else if (token == "compat") Global::soundgainmode = Global::compat; } + else if (token == "soundstopmode") + { + Parser.getTokens(); + Parser >> token; + if (token == "queue") + Global::soundstopmode = Global::queue; + else if (token == "playstop") + Global::soundstopmode = Global::playstop; + else if (token == "stop") + Global::soundstopmode = Global::stop; + } else if (token == "soundpitchmode") { Parser.getTokens(); diff --git a/Globals.h b/Globals.h index db8313c1..ef1d6fa0 100644 --- a/Globals.h +++ b/Globals.h @@ -359,9 +359,18 @@ class Global { linear, scaled, - compat + compat, }; + + enum soundstopmode_t + { + queue, + playstop, + stop + }; + static soundmode_t soundpitchmode; static soundmode_t soundgainmode; + static soundstopmode_t soundstopmode; }; //--------------------------------------------------------------------------- diff --git a/sound.cpp b/sound.cpp index d80a0aeb..4c6f2277 100644 --- a/sound.cpp +++ b/sound.cpp @@ -440,7 +440,7 @@ void complex_sound::play() void complex_sound::stop() { - if (cs == state::main) + if (cs == state::main || (Global::soundstopmode == Global::playstop && cs == state::premain)) { alSourceRewind(id); @@ -453,7 +453,15 @@ void complex_sound::stop() cs = state::post; } else if (cs == state::premain) - cs = state::prepost; + { + if (Global::soundstopmode == Global::queue) + cs = state::prepost; + else if (Global::soundstopmode == Global::stop) + { + alSourceRewind(id); + cs = state::post; + } + } } void complex_sound::update(float dt)