fix fragile qtvideooutput (#3)

This commit is contained in:
Robert Stanley Judka 2020-05-16 19:14:48 -05:00 committed by GitHub
parent 6cda29433a
commit 254382acf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,6 +57,8 @@ ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration
, activeCallback_(activeCallback)
#ifdef USE_OMX
, omxVideoOutput_(std::make_shared<projection::OMXVideoOutput>(configuration_, this->QRectToDestRect(screenGeometry_), activeCallback_))
#else
, qtVideoOutput_(nullptr)
#endif
, nightMode_(nightMode)
{
@ -90,7 +92,11 @@ IService::Pointer ServiceFactory::createVideoService(aasdk::messenger::IMessenge
qtVideoOutput_ = new projection::QtVideoOutput(configuration_, activeArea_);
if (activeCallback_ != nullptr) {
QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::startPlayback, [callback = activeCallback_]() { callback(true); });
QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::stopPlayback, [callback = activeCallback_]() { callback(false); });
QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::stopPlayback, [this]() {
activeCallback_(false);
qtVideoOutput_->disconnect();
qtVideoOutput_ = nullptr;
});
}
projection::IVideoOutput::Pointer videoOutput(qtVideoOutput_, std::bind(&QObject::deleteLater, std::placeholders::_1));
#endif