Merge branch 'master' into node-view-show-ctx
This commit is contained in:
@@ -39,7 +39,7 @@ PlaybackControls::PlaybackControls(QWidget *parent) :
|
||||
lower_control_layout->setSpacing(0);
|
||||
lower_control_layout->setMargin(0);
|
||||
|
||||
QSizePolicy lower_container_size_policy(QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
QSizePolicy lower_container_size_policy(QSizePolicy::Maximum, QSizePolicy::Expanding);
|
||||
lower_container_size_policy.setHorizontalStretch(1);
|
||||
|
||||
// In the lower-left, we create a current timecode label wrapped in a QWidget for fixed sizing
|
||||
|
||||
@@ -26,6 +26,8 @@ set(OLIVE_SOURCES
|
||||
widget/viewer/viewerdisplay.h
|
||||
widget/viewer/viewerplaybacktimer.cpp
|
||||
widget/viewer/viewerplaybacktimer.h
|
||||
widget/viewer/viewerpreventsleep.cpp
|
||||
widget/viewer/viewerpreventsleep.h
|
||||
widget/viewer/viewerqueue.h
|
||||
widget/viewer/viewersafemargininfo.h
|
||||
widget/viewer/viewersizer.cpp
|
||||
|
||||
@@ -30,10 +30,6 @@
|
||||
#include <QtMath>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "winbase.h"
|
||||
#endif
|
||||
|
||||
#include "audio/audiomanager.h"
|
||||
#include "common/clamp.h"
|
||||
#include "common/power.h"
|
||||
@@ -44,6 +40,7 @@
|
||||
#include "node/project/project.h"
|
||||
#include "render/rendermanager.h"
|
||||
#include "task/taskmanager.h"
|
||||
#include "viewerpreventsleep.h"
|
||||
#include "widget/menu/menu.h"
|
||||
#include "window/mainwindow/mainwindow.h"
|
||||
|
||||
@@ -436,7 +433,7 @@ void ViewerWidget::QueueNextAudioBuffer()
|
||||
|
||||
// Clamp queue end by zero and the audio length
|
||||
queue_end = clamp(queue_end, rational(0), GetConnectedNode()->GetAudioLength());
|
||||
if (queue_end == audio_playback_queue_time_) {
|
||||
if (queue_end <= audio_playback_queue_time_) {
|
||||
// This will queue nothing, so stop the loop here
|
||||
if (prequeuing_audio_) {
|
||||
DecrementPrequeuedAudio();
|
||||
@@ -483,8 +480,6 @@ void ViewerWidget::ReceivedAudioBufferForPlayback()
|
||||
if (prequeuing_audio_) {
|
||||
// Add to prequeued audio buffer
|
||||
prequeued_audio_.append(pack);
|
||||
|
||||
DecrementPrequeuedAudio();
|
||||
} else {
|
||||
// Push directly to audio manager
|
||||
AudioManager::instance()->PushToOutput(GetConnectedNode()->GetAudioParams(), pack);
|
||||
@@ -493,6 +488,10 @@ void ViewerWidget::ReceivedAudioBufferForPlayback()
|
||||
}
|
||||
}
|
||||
|
||||
if (prequeuing_audio_) {
|
||||
DecrementPrequeuedAudio();
|
||||
}
|
||||
|
||||
delete watcher;
|
||||
}
|
||||
}
|
||||
@@ -707,9 +706,7 @@ void ViewerWidget::PlayInternal(int speed, bool in_to_out_only)
|
||||
}
|
||||
}
|
||||
// Force screen to stay awake
|
||||
#ifdef _WIN32
|
||||
SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_CONTINUOUS);
|
||||
#endif
|
||||
PreventSleep(true);
|
||||
}
|
||||
|
||||
void ViewerWidget::PauseInternal()
|
||||
@@ -752,9 +749,7 @@ void ViewerWidget::PauseInternal()
|
||||
prequeuing_audio_ = 0;
|
||||
|
||||
// Reset screen timeout timer
|
||||
#ifdef _WIN32
|
||||
SetThreadExecutionState(ES_CONTINUOUS);
|
||||
#endif
|
||||
PreventSleep(false);
|
||||
}
|
||||
|
||||
void ViewerWidget::PushScrubbedAudio()
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "viewerpreventsleep.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#if defined(Q_OS_WINDOWS)
|
||||
#include <windows.h>
|
||||
#elif defined(Q_OS_MAC)
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#elif defined(Q_OS_LINUX)
|
||||
#include <QtDBus/QtDBus>
|
||||
#endif
|
||||
|
||||
namespace olive {
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
IOPMAssertionID assertionID = 0;
|
||||
#elif defined(Q_OS_LINUX)
|
||||
|
||||
#endif
|
||||
|
||||
void PreventSleep(bool on)
|
||||
{
|
||||
#if defined(Q_OS_WINDOWS)
|
||||
SetThreadExecutionState(on ? ES_DISPLAY_REQUIRED | ES_CONTINUOUS : ES_CONTINUOUS);
|
||||
#elif defined(Q_OS_MAC)
|
||||
if (on) {
|
||||
static const CFStringRef reasonForActivity = CFSTR("Video Playback");
|
||||
|
||||
IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep,
|
||||
kIOPMAssertionLevelOn, reasonForActivity, &assertionID);
|
||||
} else if (assertionID) {
|
||||
IOPMAssertionRelease(assertionID);
|
||||
assertionID = 0;
|
||||
}
|
||||
#elif defined(Q_OS_LINUX)
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
if(bus.isConnected()) {
|
||||
static const QStringList sleep_services = {
|
||||
QStringLiteral("org.freedesktop.ScreenSaver"),
|
||||
//QStringLiteral("org.gnome.SessionManager")
|
||||
};
|
||||
static const QStringList sleep_paths = {
|
||||
QStringLiteral("/org/freedesktop/ScreenSaver"),
|
||||
//QStringLiteral("/org/gnome/SessionManager")
|
||||
};
|
||||
static QVector<uint> sleep_cookies;
|
||||
|
||||
// Initialize vector to 0
|
||||
if (sleep_cookies.isEmpty()) {
|
||||
sleep_cookies.resize(sleep_services.size());
|
||||
sleep_cookies.fill(0);
|
||||
}
|
||||
|
||||
for (int i=0; i<sleep_cookies.size(); i++) {
|
||||
QDBusInterface interface(sleep_services.at(i), sleep_paths.at(i), sleep_services.at(i), bus);
|
||||
if (interface.isValid()) {
|
||||
QDBusReply<uint> reply;
|
||||
|
||||
if (on) {
|
||||
reply = interface.call(QStringLiteral("Inhibit"), QStringLiteral("Olive Video Editor"), QStringLiteral("Video Playback"));
|
||||
} else {
|
||||
reply = interface.call(QStringLiteral("UnInhibit"), sleep_cookies.at(i));
|
||||
}
|
||||
|
||||
if (reply.isValid()) {
|
||||
sleep_cookies[i] = reply.value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef VIEWERPREVENTSLEEP_H
|
||||
#define VIEWERPREVENTSLEEP_H
|
||||
|
||||
namespace olive {
|
||||
|
||||
void PreventSleep(bool on);
|
||||
|
||||
}
|
||||
|
||||
#endif // VIEWERPREVENTSLEEP_H
|
||||
Reference in New Issue
Block a user