Make open of sequential bufer thread safe
This commit is contained in:
parent
42bcd1892c
commit
0aa318cc97
@ -57,7 +57,6 @@ private:
|
|||||||
SequentialBuffer videoBuffer_;
|
SequentialBuffer videoBuffer_;
|
||||||
std::unique_ptr<QVideoWidget> videoWidget_;
|
std::unique_ptr<QVideoWidget> videoWidget_;
|
||||||
std::unique_ptr<QMediaPlayer> mediaPlayer_;
|
std::unique_ptr<QMediaPlayer> mediaPlayer_;
|
||||||
std::mutex mutex_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ public:
|
|||||||
bool reset() override;
|
bool reset() override;
|
||||||
bool canReadLine() const override;
|
bool canReadLine() const override;
|
||||||
qint64 bytesAvailable() const override;
|
qint64 bytesAvailable() const override;
|
||||||
|
bool open(OpenMode mode) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
qint64 readData(char *data, qint64 maxlen) override;
|
qint64 readData(char *data, qint64 maxlen) override;
|
||||||
|
@ -49,8 +49,6 @@ void QtVideoOutput::createVideoOutput()
|
|||||||
|
|
||||||
bool QtVideoOutput::open()
|
bool QtVideoOutput::open()
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
|
||||||
|
|
||||||
return videoBuffer_.open(QIODevice::ReadWrite);
|
return videoBuffer_.open(QIODevice::ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,15 +65,11 @@ void QtVideoOutput::stop()
|
|||||||
|
|
||||||
void QtVideoOutput::write(uint64_t, const aasdk::common::DataConstBuffer& buffer)
|
void QtVideoOutput::write(uint64_t, const aasdk::common::DataConstBuffer& buffer)
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
|
||||||
|
|
||||||
videoBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
videoBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtVideoOutput::onStartPlayback()
|
void QtVideoOutput::onStartPlayback()
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
|
||||||
|
|
||||||
videoWidget_->setAspectRatioMode(Qt::IgnoreAspectRatio);
|
videoWidget_->setAspectRatioMode(Qt::IgnoreAspectRatio);
|
||||||
videoWidget_->setFocus();
|
videoWidget_->setFocus();
|
||||||
videoWidget_->setWindowFlags(Qt::WindowStaysOnTopHint);
|
videoWidget_->setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
@ -89,8 +83,6 @@ void QtVideoOutput::onStartPlayback()
|
|||||||
|
|
||||||
void QtVideoOutput::onStopPlayback()
|
void QtVideoOutput::onStopPlayback()
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
|
||||||
|
|
||||||
videoWidget_->hide();
|
videoWidget_->hide();
|
||||||
mediaPlayer_->stop();
|
mediaPlayer_->stop();
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,13 @@ bool SequentialBuffer::isSequential() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SequentialBuffer::open(OpenMode mode)
|
||||||
|
{
|
||||||
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
|
return QIODevice::open(mode);
|
||||||
|
}
|
||||||
|
|
||||||
qint64 SequentialBuffer::readData(char *data, qint64 maxlen)
|
qint64 SequentialBuffer::readData(char *data, qint64 maxlen)
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user