Go to the documentation of this file.
8 #include <QMutexLocker>
17 class VolumeWriteBackThread :
public MThread
19 VolumeWriteBackThread() :
MThread(
"VolumeWriteBack") { }
23 static VolumeWriteBackThread *Instance()
25 QMutexLocker lock(&s_mutex);
26 static auto *s_instance =
new VolumeWriteBackThread;
30 VolumeWriteBackThread(
const VolumeWriteBackThread &) =
delete;
31 VolumeWriteBackThread &
operator =(
const VolumeWriteBackThread &) =
delete;
33 void SetVolume(
int value)
35 QMutexLocker lock(&m_mutex);
37 if (m_volume == value)
56 void run(
void)
override
61 static constexpr std::chrono::milliseconds holdoff { 500ms };
63 controlLabel +=
"MixerVolume";
65 QMutexLocker lock(&m_mutex);
68 int volume = m_volume;
80 if (volume == m_volume)
89 static QMutex s_mutex;
90 QMutex
mutable m_mutex;
91 enum { kStopped, kRunning, kFinished } m_state {kStopped};
95 QMutex VolumeWriteBackThread::s_mutex;
125 m_volume = std::max(std::min(value, 100), 0);
129 VolumeWriteBackThread::Instance()->SetVolume(
m_volume);
virtual void SetCurrentVolume(int value)
virtual int GetVolumeChannel(int channel) const =0
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
virtual void AdjustCurrentVolume(int change)
virtual uint GetCurrentVolume(void) const
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
virtual int GetSWVolume(void)=0
static void setTerminationEnabled(bool enabled=true)
static void usleep(std::chrono::microseconds time)
virtual MuteState SetMuteState(MuteState)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
virtual void ToggleMute(void)
virtual void SetSWVolume(int new_volume, bool save)=0
virtual MuteState GetMuteState(void) const
static MuteState NextMuteState(MuteState)
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
bool SWVolume(void) const
virtual void run(void)
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
bool GetBoolSetting(const QString &key, bool defaultval=false)
MThread & operator=(const MThread &)=delete
This is a wrapper around QThread that does several additional things.
virtual void SetVolumeChannel(int channel, int volume)=0
void SetChannels(int new_channels)
void SaveSetting(const QString &key, int newValue)
MuteState m_currentMuteState
QString GetSetting(const QString &key, const QString &defaultval="")