Skip to content

Commit c64bf15

Browse files
committed
CaptureCont Move timeer to a start functiopn
1 parent 4bc7e15 commit c64bf15

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

include/hyperion/CaptureCont.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ class CaptureCont : public QObject
2323
void setVideoCaptureEnable(bool enable);
2424
void setAudioCaptureEnable(bool enable);
2525

26+
///
27+
/// @brief Start Capture Control and its timers
28+
///
29+
void start();
30+
31+
///
32+
/// @brief Stop Capture Control and its timers
33+
///
2634
void stop();
2735

2836
private slots:
@@ -82,17 +90,17 @@ private slots:
8290
bool _screenCaptureEnabled;
8391
int _screenCapturePriority;
8492
QString _screenCaptureName;
85-
QTimer* _screenCaptureInactiveTimer;
93+
QScopedPointer<QTimer, QScopedPointerDeleteLater> _screenCaptureInactiveTimer;
8694

8795
/// Reflect state of video capture and prio
8896
bool _videoCaptureEnabled;
8997
int _videoCapturePriority;
9098
QString _videoCaptureName;
91-
QTimer* _videoInactiveTimer;
99+
QScopedPointer<QTimer, QScopedPointerDeleteLater> _videoInactiveTimer;
92100

93101
/// Reflect state of audio capture and prio
94102
bool _audioCaptureEnabled;
95103
int _audioCapturePriority;
96104
QString _audioCaptureName;
97-
QTimer* _audioCaptureInactiveTimer;
105+
QScopedPointer<QTimer, QScopedPointerDeleteLater> _audioCaptureInactiveTimer;
98106
};

libsrc/hyperion/CaptureCont.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,41 @@ CaptureCont::CaptureCont(Hyperion* hyperion)
2525
: _hyperion(hyperion)
2626
, _screenCaptureEnabled(false)
2727
, _screenCapturePriority(0)
28-
, _screenCaptureInactiveTimer(new QTimer(this))
28+
, _screenCaptureInactiveTimer(nullptr)
2929
, _videoCaptureEnabled(false)
3030
, _videoCapturePriority(0)
31-
, _videoInactiveTimer(new QTimer(this))
31+
, _videoInactiveTimer(nullptr)
3232
, _audioCaptureEnabled(false)
3333
, _audioCapturePriority(0)
34-
, _audioCaptureInactiveTimer(new QTimer(this))
34+
, _audioCaptureInactiveTimer(nullptr)
3535
{
36+
}
37+
38+
void CaptureCont::start()
39+
{
40+
qDebug() << "CaptureCont::start()...";
41+
3642
// settings changes
3743
connect(_hyperion, &Hyperion::settingsChanged, this, &CaptureCont::handleSettingsUpdate);
3844

3945
// comp changes
4046
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &CaptureCont::handleCompStateChangeRequest);
4147

4248
// inactive timer screen
43-
connect(_screenCaptureInactiveTimer, &QTimer::timeout, this, &CaptureCont::onScreenIsInactive);
49+
_screenCaptureInactiveTimer.reset(new QTimer(this));
50+
connect(_screenCaptureInactiveTimer.get(), &QTimer::timeout, this, &CaptureCont::onScreenIsInactive);
4451
_screenCaptureInactiveTimer->setSingleShot(true);
4552
_screenCaptureInactiveTimer->setInterval(DEFAULT_SCREEN_CAPTURE_INACTIVE_TIMEOUT);
4653

4754
// inactive timer video
48-
connect(_videoInactiveTimer, &QTimer::timeout, this, &CaptureCont::onVideoIsInactive);
55+
_videoInactiveTimer.reset(new QTimer(this));
56+
connect(_videoInactiveTimer.get(), &QTimer::timeout, this, &CaptureCont::onVideoIsInactive);
4957
_videoInactiveTimer->setSingleShot(true);
5058
_videoInactiveTimer->setInterval(DEFAULT_VIDEO_CAPTURE_INACTIVE_TIMEOUT);
5159

5260
// inactive timer audio
53-
connect(_audioCaptureInactiveTimer, &QTimer::timeout, this, &CaptureCont::onAudioIsInactive);
61+
_audioCaptureInactiveTimer.reset(new QTimer(this));
62+
connect(_audioCaptureInactiveTimer.get(), &QTimer::timeout, this, &CaptureCont::onAudioIsInactive);
5463
_audioCaptureInactiveTimer->setSingleShot(true);
5564
_audioCaptureInactiveTimer->setInterval(DEFAULT_AUDIO_CAPTURE_INACTIVE_TIMEOUT);
5665

@@ -62,16 +71,18 @@ void CaptureCont::stop()
6271
{
6372
qDebug() << "CaptureCont::stop()...";
6473

74+
disconnect(_hyperion, &Hyperion::compStateChangeRequest, this, &CaptureCont::handleCompStateChangeRequest);
75+
disconnect(_hyperion, &Hyperion::settingsChanged, this, &CaptureCont::handleSettingsUpdate);
76+
6577
_videoInactiveTimer->stop();
6678
_screenCaptureInactiveTimer->stop();
6779
_audioCaptureInactiveTimer->stop();
6880

69-
disconnect(_videoInactiveTimer, &QTimer::timeout, this, &CaptureCont::onVideoIsInactive);
70-
disconnect(_screenCaptureInactiveTimer, &QTimer::timeout, this, &CaptureCont::onScreenIsInactive);
71-
disconnect(_audioCaptureInactiveTimer, &QTimer::timeout, this, &CaptureCont::onAudioIsInactive);
81+
disconnect(_videoInactiveTimer.get(), &QTimer::timeout, this, &CaptureCont::onVideoIsInactive);
82+
disconnect(_screenCaptureInactiveTimer.get(), &QTimer::timeout, this, &CaptureCont::onScreenIsInactive);
83+
disconnect(_audioCaptureInactiveTimer.get(), &QTimer::timeout, this, &CaptureCont::onAudioIsInactive);
84+
7285

73-
disconnect(_hyperion, &Hyperion::compStateChangeRequest, this, &CaptureCont::handleCompStateChangeRequest);
74-
disconnect(_hyperion, &Hyperion::settingsChanged, this, &CaptureCont::handleSettingsUpdate);
7586
}
7687

7788
CaptureCont::~CaptureCont()

libsrc/hyperion/Hyperion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ void Hyperion::start()
162162

163163
// create the Daemon capture interface
164164
_captureCont.reset(new CaptureCont(this));
165+
_captureCont->start();
165166

166167
// link global signals with the corresponding slots
167168
connect(GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput, this, &Hyperion::registerInput);

0 commit comments

Comments
 (0)