ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
media_linux.cpp File Reference
#include <QDateTime>
#include <QMutex>
#include "media.h"
+ Include dependency graph for media_linux.cpp:

Go to the source code of this file.

Functions

muteState getMuteState ()
 

Variables

static muteState lastKnown = UNKNOWN
 

Function Documentation

muteState getMuteState ( )

Definition at line 102 of file media_linux.cpp.

References lastKnown.

102  {
103 #ifdef USE_LIBPULSE
104  static pa_threaded_mainloop* mainLoop = nullptr;
105 
106  QMutexLocker locker(&mutex);
107 
108  //Setup main loop thread used for communicating with Pulse Audio. All
109  //communication is done asynchronously.
110  if(mainLoop == nullptr){
111  mainLoop = pa_threaded_mainloop_new();
112  if(mainLoop == nullptr)
113  return lastKnown;
114 
115  if(pa_threaded_mainloop_start(mainLoop) != 0){
116  pa_threaded_mainloop_free(mainLoop);
117  mainLoop = nullptr;
118  return lastKnown;
119  }
120  }
121 
122  //Connect to the local Pulse Audio server. It's usually running but a
123  //reconnect is attempted periodically whenever the connection fails or is
124  //terminated.
125  if(paContext == nullptr && QDateTime::currentMSecsSinceEpoch() >= reconnectTime){
126  pa_threaded_mainloop_lock(mainLoop);
127  {
128  pa_mainloop_api* api = pa_threaded_mainloop_get_api(mainLoop);
129  Q_ASSERT(api != nullptr);
130 
131  paContext = pa_context_new(api, "QPulse");
132  Q_ASSERT(paContext != nullptr);
133  pa_context_set_state_callback(paContext, &ContextStateCallback, nullptr);
134  pa_context_connect(paContext, nullptr, PA_CONTEXT_NOFAIL, nullptr);
135  }
136  pa_threaded_mainloop_unlock(mainLoop);
137  }
138 #endif
139 
140  return lastKnown;
141 }
static muteState lastKnown
Definition: media_linux.cpp:13

Variable Documentation

muteState lastKnown = UNKNOWN
static

Definition at line 13 of file media_linux.cpp.

Referenced by getMuteState().