Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
audiodeviceguard.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Audio Device Guard
22 //=============================================================================
23 
24 #include "audiodeviceguard.h"
25 
26 //-----------------------------------------------------------------------------
27 // Constructor
28 //-----------------------------------------------------------------------------
33 
35  : pAudioBase(audiobase)
36 {
37  LOGSTATUS << "Creating AudioDeviceGuard";
38  setModuleName("Audio");
39  setThreadName("AudioDevGuard");
40 }
41 
42 
43 //-----------------------------------------------------------------------------
44 // Destructor
45 //-----------------------------------------------------------------------------
49 
51 {
52  LOGSTATUS << "Destroying AudioDeviceGuard";
53  stop();
54 }
55 
56 
57 //-----------------------------------------------------------------------------
58 // Start the AudioDeviceGuard
59 //-----------------------------------------------------------------------------
65 
67 {
68  LOGSTATUS << "Starting AudioDeviceGuard";
69  setTimerInterval(1000*seconds,2000);
70  setPriority(QThread::IdlePriority);
71  return ThreadBase::start();
72 }
73 
74 
75 //-----------------------------------------------------------------------------
76 // Thread worker function
77 //-----------------------------------------------------------------------------
82 
84 {
86 }
void setTimerInterval(const int msec, const int firstMsec=0)
Set timer interval for the periodically called worker.
Definition: threadbase.cpp:117
void setModuleName(const QString &name)
Specify the name of the class-specific module.
Definition: log.cpp:82
void setPriority(const QThread::Priority p)
Set thread priority.
Definition: threadbase.cpp:109
virtual void updateListOfDevices()=0
Update the list of devices, called by the DeviceGuard.
~AudioDeviceGuard()
Destructor: Stop the timer, stop the thread and exit.
void periodicallyCalledWorker() override final
Thread worker function, calling updateListOfDevices() of the audio object. This thread is executed at...
#define LOGSTATUS
Definition: log.h:42
virtual bool start()
Start the thread.
Definition: threadbase.cpp:64
void setThreadName(const QString name)
Set thread name (Linux only)
Definition: threadbase.cpp:121
virtual bool stop()
Stop the thread.
Definition: threadbase.cpp:152
AudioBase * pAudioBase
Pointer back to the audio object.
AudioDeviceGuard(AudioBase *output=nullptr)
Construtor of the AudioDeviceGuard.
bool startMonitoring(int seconds=20)
Start the AudioDeviceGuard.
Abstract base class for audio input and output.
Definition: audiobase.h:52