1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: Split device and stream mutexes

This commit is contained in:
Diadlo 2017-06-26 14:00:29 +03:00
parent 50eaea8f8e
commit d720cca969
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 7 additions and 3 deletions

View File

@ -155,7 +155,7 @@ void CameraSource::setupDefault()
*/
void CameraSource::setupDevice(const QString& DeviceName, const VideoMode& Mode)
{
QWriteLocker locker{&streamMutex};
QWriteLocker locker{&deviceMutex};
if (DeviceName == deviceName && Mode == mode) {
return;
@ -180,6 +180,7 @@ bool CameraSource::isNone() const
CameraSource::~CameraSource()
{
QWriteLocker locker{&streamMutex};
QWriteLocker locker2{&deviceMutex};
if (_isNone) {
return;
@ -217,7 +218,7 @@ CameraSource::~CameraSource()
void CameraSource::subscribe()
{
QWriteLocker locker{&streamMutex};
QWriteLocker locker{&deviceMutex};
++subscriptions;
openDevice();
@ -225,7 +226,7 @@ void CameraSource::subscribe()
void CameraSource::unsubscribe()
{
QWriteLocker locker{&streamMutex};
QWriteLocker locker{&deviceMutex};
--subscriptions;
if (subscriptions == 0) {
@ -239,6 +240,7 @@ void CameraSource::unsubscribe()
*/
void CameraSource::openDevice()
{
QWriteLocker locker{&streamMutex};
qDebug() << "Opening device " << deviceName;
if (device) {
@ -345,6 +347,7 @@ void CameraSource::openDevice()
*/
void CameraSource::closeDevice()
{
QWriteLocker locker{&streamMutex};
qDebug() << "Closing device " << deviceName;
// Free all remaining VideoFrame

View File

@ -70,6 +70,7 @@ private:
AVCodecContext* cctxOrig;
int videoStreamIndex;
QReadWriteLock deviceMutex;
QReadWriteLock streamMutex;
std::atomic_bool _isNone;