mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 17:16:00 -05:00
Rework handling of fade threads
Previous implementation did not allow ongoing fades to be stopped. New implementations allows waiting for fade to complete.
This commit is contained in:
@@ -16,6 +16,7 @@ enum class AudioAction {
|
||||
class MacroActionAudio : public MacroAction {
|
||||
public:
|
||||
MacroActionAudio(Macro *m) : MacroAction(m) {}
|
||||
virtual ~MacroActionAudio();
|
||||
bool PerformAction();
|
||||
void LogAction();
|
||||
bool Save(obs_data_t *obj);
|
||||
@@ -32,8 +33,15 @@ public:
|
||||
int _volume = 0;
|
||||
bool _fade = false;
|
||||
Duration _duration;
|
||||
bool _wait = false;
|
||||
|
||||
private:
|
||||
void StartSourceFade();
|
||||
void StartMasterFade();
|
||||
void FadeSourceVolume();
|
||||
void FadeMasterVolume();
|
||||
std::thread _fadeThread;
|
||||
|
||||
static bool _registered;
|
||||
static const std::string id;
|
||||
};
|
||||
@@ -61,6 +69,7 @@ private slots:
|
||||
void VolumeChanged(int value);
|
||||
void FadeChanged(int value);
|
||||
void DurationChanged(double seconds);
|
||||
void WaitChanged(int value);
|
||||
signals:
|
||||
void HeaderInfoChanged(const QString &);
|
||||
|
||||
@@ -70,6 +79,7 @@ protected:
|
||||
QSpinBox *_volumePercent;
|
||||
QCheckBox *_fade;
|
||||
DurationSelection *_duration;
|
||||
QCheckBox *_wait;
|
||||
QHBoxLayout *_fadeLayout;
|
||||
std::shared_ptr<MacroActionAudio> _entryData;
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ public:
|
||||
bool MatchOnChange() { return _matchOnChange; }
|
||||
int GetCount() { return _count; };
|
||||
void ResetCount() { _count = 0; };
|
||||
bool GetStop() { return _stop; }
|
||||
void Stop() { _stop = true; }
|
||||
std::deque<std::shared_ptr<MacroCondition>> &Conditions()
|
||||
{
|
||||
|
||||
@@ -111,7 +111,6 @@ struct SwitcherData {
|
||||
StartupBehavior startupBehavior = PERSIST;
|
||||
AutoStartEvent autoStartEvent = AutoStartEvent::NEVER;
|
||||
|
||||
std::vector<std::thread> audioHelperThreads;
|
||||
std::atomic_bool masterAudioFadeActive = {false};
|
||||
std::unordered_map<std::string, std::atomic_bool> activeAudioFades;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user