mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-30 11:03:00 +02:00
use alias for unique_lock and mutex
This commit is contained in:
parent
3b56df6e99
commit
adf41fce19
2 changed files with 11 additions and 8 deletions
libraries/audio/src
|
@ -21,7 +21,7 @@
|
|||
AudioInjectorManager::~AudioInjectorManager() {
|
||||
_shouldStop = true;
|
||||
|
||||
std::unique_lock<std::mutex> lock(_injectorsMutex);
|
||||
Lock lock(_injectorsMutex);
|
||||
|
||||
// make sure any still living injectors are stopped and deleted
|
||||
while (!_injectors.empty()) {
|
||||
|
@ -61,7 +61,7 @@ void AudioInjectorManager::createThread() {
|
|||
void AudioInjectorManager::run() {
|
||||
while (!_shouldStop) {
|
||||
// wait until the next injector is ready, or until we get a new injector given to us
|
||||
std::unique_lock<std::mutex> lock(_injectorsMutex);
|
||||
Lock lock(_injectorsMutex);
|
||||
|
||||
if (_injectors.size() > 0) {
|
||||
// when does the next injector need to send a frame?
|
||||
|
@ -119,7 +119,7 @@ bool AudioInjectorManager::threadInjector(AudioInjector* injector) {
|
|||
}
|
||||
|
||||
// guard the injectors vector with a mutex
|
||||
std::unique_lock<std::mutex> lock(_injectorsMutex);
|
||||
Lock lock(_injectorsMutex);
|
||||
|
||||
// check if we'll be able to thread this injector (do we have < max concurrent injectors)
|
||||
if (_injectors.size() < MAX_INJECTORS_PER_THREAD) {
|
||||
|
@ -150,7 +150,7 @@ bool AudioInjectorManager::threadInjector(AudioInjector* injector) {
|
|||
void AudioInjectorManager::restartFinishedInjector(AudioInjector* injector) {
|
||||
if (!_shouldStop) {
|
||||
// guard the injectors vector with a mutex
|
||||
std::unique_lock<std::mutex> lock(_injectorsMutex);
|
||||
Lock lock(_injectorsMutex);
|
||||
|
||||
// add the injector to the queue with a send timestamp of now
|
||||
_injectors.emplace(usecTimestampNow(), InjectorQPointer { injector });
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
#include <DependencyManager.h>
|
||||
|
||||
class AudioInjector;
|
||||
using InjectorQPointer = QPointer<AudioInjector>;
|
||||
using TimeInjectorPointerPair = std::pair<uint64_t, InjectorQPointer>;
|
||||
using InjectorQueue = std::queue<TimeInjectorPointerPair>;
|
||||
|
||||
class AudioInjectorManager : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
@ -36,6 +33,12 @@ public:
|
|||
private slots:
|
||||
void run();
|
||||
private:
|
||||
using InjectorQPointer = QPointer<AudioInjector>;
|
||||
using TimeInjectorPointerPair = std::pair<uint64_t, InjectorQPointer>;
|
||||
using InjectorQueue = std::queue<TimeInjectorPointerPair>;
|
||||
using Mutex = std::mutex;
|
||||
using Lock = std::unique_lock<Mutex>;
|
||||
|
||||
bool threadInjector(AudioInjector* injector);
|
||||
void restartFinishedInjector(AudioInjector* injector);
|
||||
void notifyInjectorReadyCondition() { _injectorReady.notify_one(); }
|
||||
|
@ -49,7 +52,7 @@ private:
|
|||
QThread* _thread { nullptr };
|
||||
bool _shouldStop { false };
|
||||
InjectorQueue _injectors;
|
||||
std::mutex _injectorsMutex;
|
||||
Mutex _injectorsMutex;
|
||||
std::condition_variable _injectorReady;
|
||||
|
||||
friend class AudioInjector;
|
||||
|
|
Loading…
Reference in a new issue