pause hotkey freeze fix (Scene Round Trip/ not done)

This commit is contained in:
WarmUpTill 2016-08-26 16:06:35 +02:00 committed by GitHub
parent b8f94cd1d3
commit 5cff22d758
2 changed files with 8 additions and 1 deletions

View File

@ -26,6 +26,7 @@ void Switcher::switcherThreadFunc() {
bool checkFullscreen = false;
bool pauseSwitching = false;
size_t sleepTime = 1000;
auto locked = unique_lock<mutex>(mtx);
while (isRunning) {
//get Scene Name
obs_source_t * transitionUsed = obs_get_output_source(0);
@ -183,7 +184,8 @@ void Switcher::switcherThreadFunc() {
}
}
//sleep for a bit
this_thread::sleep_for(chrono::milliseconds(sleepTime));
terminate.wait_for(locked, chrono::milliseconds(sleepTime));
//this_thread::sleep_for(chrono::milliseconds(sleepTime));
sleepTime = 1000;
}
}
@ -279,6 +281,7 @@ void Switcher::load() {
//start thread
void Switcher::start()
{
auto locked = unique_lock<mutex>(mtx);
isRunning = true;
switcherThread = thread(&Switcher::switcherThreadFunc, this);
}
@ -386,6 +389,7 @@ string Switcher::GetActiveWindowTitle()
//tell the thread to stop
void Switcher::stop() {
auto locked = unique_lock<mutex>(mtx);
isRunning = false;
if (switcherThread.joinable()) switcherThread.join();
}

View File

@ -29,4 +29,7 @@ private:
bool isWindowFullscreen();
string GetActiveWindowTitle();
pair<int, int> getCursorXY();
bool quit;
mutex mtx;
condition_variable terminate;
};