mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor: Remove unused bool result
This commit is contained in:
parent
b562b31413
commit
a22694c9e8
|
@ -206,29 +206,15 @@ CameraSource::~CameraSource()
|
|||
QThread::yieldCurrentThread();
|
||||
}
|
||||
|
||||
bool CameraSource::subscribe()
|
||||
void CameraSource::subscribe()
|
||||
{
|
||||
QWriteLocker locker{&streamMutex};
|
||||
|
||||
if (_isNone) {
|
||||
++subscriptions;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (openDevice()) {
|
||||
++subscriptions;
|
||||
return true;
|
||||
} else {
|
||||
while (device && !device->close()) {
|
||||
}
|
||||
device = nullptr;
|
||||
cctx = nullptr;
|
||||
#if LIBAVCODEC_VERSION_INT < 3747941
|
||||
cctxOrig = nullptr;
|
||||
#endif
|
||||
videoStreamIndex = -1;
|
||||
return false;
|
||||
}
|
||||
openDevice();
|
||||
}
|
||||
|
||||
void CameraSource::unsubscribe()
|
||||
|
@ -256,15 +242,15 @@ void CameraSource::unsubscribe()
|
|||
/**
|
||||
* @brief Opens the video device and starts streaming.
|
||||
* @note Callers must own the biglock.
|
||||
* @return True if success, false otherwise.
|
||||
*/
|
||||
bool CameraSource::openDevice()
|
||||
void CameraSource::openDevice()
|
||||
{
|
||||
qDebug() << "Opening device " << deviceName;
|
||||
|
||||
if (device) {
|
||||
device->open();
|
||||
return true;
|
||||
emit openFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to create a new CameraDevice
|
||||
|
@ -273,7 +259,8 @@ bool CameraSource::openDevice()
|
|||
|
||||
if (!device) {
|
||||
qWarning() << "Failed to open device!";
|
||||
return false;
|
||||
emit openFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to open the device as many time as we already have subscribers,
|
||||
|
@ -297,7 +284,8 @@ bool CameraSource::openDevice()
|
|||
|
||||
if (videoStreamIndex == -1) {
|
||||
qWarning() << "Video stream not found";
|
||||
return false;
|
||||
emit openFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
AVCodecID codecId;
|
||||
|
@ -312,7 +300,8 @@ bool CameraSource::openDevice()
|
|||
codec = avcodec_find_decoder(codecId);
|
||||
if (!codec) {
|
||||
qWarning() << "Codec not found";
|
||||
return false;
|
||||
emit openFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -321,14 +310,16 @@ bool CameraSource::openDevice()
|
|||
cctx = avcodec_alloc_context3(codec);
|
||||
if (avcodec_copy_context(cctx, cctxOrig) != 0) {
|
||||
qWarning() << "Can't copy context";
|
||||
return false;
|
||||
emit openFailed();
|
||||
return;
|
||||
}
|
||||
#else
|
||||
// Create a context for our codec, using the existing parameters
|
||||
cctx = avcodec_alloc_context3(codec);
|
||||
if (avcodec_parameters_to_context(cctx, cparams) < 0) {
|
||||
qWarning() << "Can't create AV context from parameters";
|
||||
return false;
|
||||
emit openFailed();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -338,7 +329,8 @@ bool CameraSource::openDevice()
|
|||
if (avcodec_open2(cctx, codec, nullptr) < 0) {
|
||||
qWarning() << "Can't open codec";
|
||||
avcodec_free_context(&cctx);
|
||||
return false;
|
||||
emit openFailed();
|
||||
return;
|
||||
}
|
||||
|
||||
if (streamFuture.isRunning())
|
||||
|
@ -351,8 +343,6 @@ bool CameraSource::openDevice()
|
|||
QThread::yieldCurrentThread();
|
||||
|
||||
emit deviceOpened();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,17 +44,18 @@ public:
|
|||
bool isNone() const;
|
||||
|
||||
// VideoSource interface
|
||||
virtual bool subscribe() override;
|
||||
virtual void subscribe() override;
|
||||
virtual void unsubscribe() override;
|
||||
|
||||
signals:
|
||||
void deviceOpened();
|
||||
void openFailed();
|
||||
|
||||
private:
|
||||
CameraSource();
|
||||
~CameraSource();
|
||||
void stream();
|
||||
bool openDevice();
|
||||
void openDevice();
|
||||
void closeDevice();
|
||||
|
||||
private:
|
||||
|
|
|
@ -102,11 +102,10 @@ void CoreVideoSource::pushFrame(const vpx_image_t* vpxframe)
|
|||
emit frameAvailable(vframe);
|
||||
}
|
||||
|
||||
bool CoreVideoSource::subscribe()
|
||||
void CoreVideoSource::subscribe()
|
||||
{
|
||||
QMutexLocker locker(&biglock);
|
||||
++subscribers;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CoreVideoSource::unsubscribe()
|
||||
|
|
|
@ -31,7 +31,7 @@ class CoreVideoSource : public VideoSource
|
|||
Q_OBJECT
|
||||
public:
|
||||
// VideoSource interface
|
||||
virtual bool subscribe() override;
|
||||
virtual void subscribe() override;
|
||||
virtual void unsubscribe() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
* @brief If subscribe sucessfully opens the source, it will start emitting frameAvailable
|
||||
* signals.
|
||||
*/
|
||||
virtual bool subscribe() = 0;
|
||||
virtual void subscribe() = 0;
|
||||
/**
|
||||
* @brief Stop emitting frameAvailable signals, and free associated resources if necessary.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user