Skip to content

Commit

Permalink
Moved the ScreenSaverDefeater class out of the transport control and …
Browse files Browse the repository at this point in the history
…into utilities
  • Loading branch information
julianstorer committed Nov 15, 2024
1 parent f2ae3c8 commit 58d1202
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 29 deletions.
28 changes: 0 additions & 28 deletions modules/tracktion_engine/playback/tracktion_TransportControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,34 +675,6 @@ struct TransportControl::PlayHeadWrapper
TransportControl& transport;
};


//==============================================================================
static int numScreenSaverDefeaters = 0;

struct TransportControl::ScreenSaverDefeater
{
ScreenSaverDefeater()
{
if (juce::Desktop::getInstance().isHeadless())
return;

TRACKTION_ASSERT_MESSAGE_THREAD
++numScreenSaverDefeaters;
juce::Desktop::setScreenSaverEnabled (numScreenSaverDefeaters == 0);
}

~ScreenSaverDefeater()
{
if (juce::Desktop::getInstance().isHeadless())
return;

TRACKTION_ASSERT_MESSAGE_THREAD
--numScreenSaverDefeaters;
jassert (numScreenSaverDefeaters >= 0);
juce::Desktop::setScreenSaverEnabled (numScreenSaverDefeaters == 0);
}
};

//==============================================================================
static juce::Array<TransportControl*, juce::CriticalSection> activeTransportControls;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ class TransportControl : public juce::ChangeBroadcaster,
bool isStopInProgress = false;
bool recordingIsStoppingFlag = false;

struct ScreenSaverDefeater;
std::unique_ptr<ScreenSaverDefeater> screenSaverDefeater;

struct PlayingFlag
Expand Down
1 change: 1 addition & 0 deletions modules/tracktion_engine/tracktion_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ namespace tracktion { inline namespace engine
#include "utilities/tracktion_CurveEditor.h"
#include "utilities/tracktion_Envelope.h"
#include "utilities/tracktion_Oscillators.h"
#include "utilities/tracktion_ScreenSaverDefeater.h"

#include "project/tracktion_ProjectItemID.h"

Expand Down
1 change: 1 addition & 0 deletions modules/tracktion_engine/tracktion_engine_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ extern "C" char MacGetMacFSRefForREXDLL (FSRef* fsRef)
#include "utilities/tracktion_Engine.cpp"
#include "utilities/tracktion_Threads.cpp"
#include "utilities/tracktion_BinaryData.cpp"
#include "utilities/tracktion_ScreenSaverDefeater.cpp"

#ifdef __GNUC__
#pragma GCC diagnostic pop
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
,--. ,--. ,--. ,--.
,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2018
'-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
| | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
`---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
*/


namespace tracktion { inline namespace engine
{

static int numScreenSaverDefeaters = 0;

ScreenSaverDefeater::ScreenSaverDefeater()
{
if (juce::Desktop::getInstance().isHeadless())
return;

TRACKTION_ASSERT_MESSAGE_THREAD
++numScreenSaverDefeaters;
juce::Desktop::setScreenSaverEnabled (numScreenSaverDefeaters == 0);
}

ScreenSaverDefeater::~ScreenSaverDefeater()
{
if (juce::Desktop::getInstance().isHeadless())
return;

TRACKTION_ASSERT_MESSAGE_THREAD
--numScreenSaverDefeaters;
jassert (numScreenSaverDefeaters >= 0);
juce::Desktop::setScreenSaverEnabled (numScreenSaverDefeaters == 0);
}


}} // namespace tracktion { inline namespace engine
22 changes: 22 additions & 0 deletions modules/tracktion_engine/utilities/tracktion_ScreenSaverDefeater.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
,--. ,--. ,--. ,--.
,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2018
'-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
| | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
`---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
*/


namespace tracktion { inline namespace engine
{

//==============================================================================
/// As long as at least one of these objects exists, the screensaver will be disabled
struct ScreenSaverDefeater
{
ScreenSaverDefeater();
~ScreenSaverDefeater();
};


}} // namespace tracktion { inline namespace engine

0 comments on commit 58d1202

Please sign in to comment.