mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: Add deviceThread
This commit is contained in:
parent
60dc4b34a4
commit
50eaea8f8e
|
@ -90,7 +90,8 @@ extern "C" {
|
||||||
CameraSource* CameraSource::instance{nullptr};
|
CameraSource* CameraSource::instance{nullptr};
|
||||||
|
|
||||||
CameraSource::CameraSource()
|
CameraSource::CameraSource()
|
||||||
: deviceName{"none"}
|
: deviceThread{new QThread}
|
||||||
|
, deviceName{"none"}
|
||||||
, device{nullptr}
|
, device{nullptr}
|
||||||
, mode(VideoMode())
|
, mode(VideoMode())
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -102,6 +103,10 @@ CameraSource::CameraSource()
|
||||||
, _isNone{true}
|
, _isNone{true}
|
||||||
, subscriptions{0}
|
, subscriptions{0}
|
||||||
{
|
{
|
||||||
|
deviceThread->setObjectName("Device thread");
|
||||||
|
deviceThread->start();
|
||||||
|
moveToThread(deviceThread);
|
||||||
|
|
||||||
subscriptions = 0;
|
subscriptions = 0;
|
||||||
av_register_all();
|
av_register_all();
|
||||||
avdevice_register_all();
|
avdevice_register_all();
|
||||||
|
@ -204,6 +209,10 @@ CameraSource::~CameraSource()
|
||||||
// Synchronize with our stream thread
|
// Synchronize with our stream thread
|
||||||
while (streamFuture.isRunning())
|
while (streamFuture.isRunning())
|
||||||
QThread::yieldCurrentThread();
|
QThread::yieldCurrentThread();
|
||||||
|
|
||||||
|
deviceThread->exit(0);
|
||||||
|
deviceThread->wait();
|
||||||
|
delete deviceThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraSource::subscribe()
|
void CameraSource::subscribe()
|
||||||
|
|
|
@ -60,6 +60,8 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFuture<void> streamFuture;
|
QFuture<void> streamFuture;
|
||||||
|
QThread* deviceThread;
|
||||||
|
|
||||||
QString deviceName;
|
QString deviceName;
|
||||||
CameraDevice* device;
|
CameraDevice* device;
|
||||||
VideoMode mode;
|
VideoMode mode;
|
||||||
|
@ -67,6 +69,7 @@ private:
|
||||||
// TODO: Remove when ffmpeg version will be bumped to the 3.1.0
|
// TODO: Remove when ffmpeg version will be bumped to the 3.1.0
|
||||||
AVCodecContext* cctxOrig;
|
AVCodecContext* cctxOrig;
|
||||||
int videoStreamIndex;
|
int videoStreamIndex;
|
||||||
|
|
||||||
QReadWriteLock streamMutex;
|
QReadWriteLock streamMutex;
|
||||||
|
|
||||||
std::atomic_bool _isNone;
|
std::atomic_bool _isNone;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user