ckb-next  beta-v0.2.8 at branch testing
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
media.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXTERN_C   extern
 
#define ENUM_C(name)   typedef enum
 
#define ENUM_END_C(name)   name
 

Enumerations

enum  muteState { UNKNOWN = -1, UNMUTED, MUTED }
 

Functions

muteState getMuteState ()
 

Macro Definition Documentation

#define ENUM_C (   name)    typedef enum

Definition at line 13 of file media.h.

#define ENUM_END_C (   name)    name

Definition at line 14 of file media.h.

#define EXTERN_C   extern

Definition at line 12 of file media.h.

Enumeration Type Documentation

enum muteState
Enumerator
UNKNOWN 
UNMUTED 
MUTED 

Definition at line 19 of file media.h.

19  {
20  UNKNOWN = -1,
21  UNMUTED,
22  MUTED
Definition: media.h:20
muteState
Definition: media.h:19
Definition: media.h:21
Definition: media.h:22
#define ENUM_END_C(name)
Definition: media.h:14

Function Documentation

muteState getMuteState ( )

Definition at line 9 of file media_linux.cpp.

References MUTED, muteProcess, UNKNOWN, and UNMUTED.

Referenced by KbPerf::applyIndicators().

9  {
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 }
Definition: media.h:20
static QProcess muteProcess
Definition: media_linux.cpp:7
muteState
Definition: media.h:19
Definition: media.h:21
Definition: media.h:22

+ Here is the caller graph for this function: