ckb-next
beta-v0.2.8 at branch testing
ckb-next driver for corsair devices
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
media_linux.cpp
Go to the documentation of this file.
1
#ifndef __APPLE__
2
3
#include <QDateTime>
4
#include <QProcess>
5
#include "
media.h
"
6
7
static
QProcess
muteProcess
;
8
9
muteState
getMuteState
(){
10
// Get default sink mute state from pulseaudio
11
static
muteState
lastKnown =
UNKNOWN
;
12
static
quint64 lastTime = 0;
13
// Instead of running a command to check the state and waiting for it to finish, run the command now but wait to check it until the next frame
14
// (locking up the GUI thread is bad)
15
if
(lastTime > 0 &&
muteProcess
.state() == QProcess::NotRunning){
16
if
(
muteProcess
.exitCode() != 0)
17
lastKnown =
UNKNOWN
;
18
QString output =
muteProcess
.readLine().trimmed();
19
if
(output ==
"yes"
)
20
lastKnown =
MUTED
;
21
else
if
(output ==
"no"
)
22
lastKnown =
UNMUTED
;
23
}
24
quint64 time = QDateTime::currentMSecsSinceEpoch();
25
if
(time - lastTime < 33)
26
// Don't run it than 30 times per second
27
return
lastKnown;
28
lastTime = time;
29
if
(
muteProcess
.state() == QProcess::NotRunning)
30
// Shamelessly taken from pulseaudio-ctl
31
muteProcess
.start(
"sh"
, QStringList() <<
"-c"
<<
"pacmd list-sinks|grep -A 15 '* index'|awk '/muted:/{ print $2 }'"
);
32
return
lastKnown;
33
}
34
35
#endif
UNKNOWN
Definition:
media.h:20
media.h
muteProcess
static QProcess muteProcess
Definition:
media_linux.cpp:7
getMuteState
muteState getMuteState()
Definition:
media_linux.cpp:9
muteState
muteState
Definition:
media.h:19
UNMUTED
Definition:
media.h:21
MUTED
Definition:
media.h:22
src
ckb
media_linux.cpp
Generated on Sat Feb 3 2018 14:44:04 for ckb-next by
1.8.6