CARMA C++
AudioControlThread.h
1 
2 /*
3  * $Id: AudioControlThread.h,v 1.6 2012/01/20 17:04:50 iws Exp $
4  */
5 
6 #ifndef CARMA_ALARM_AUDIOCONTROLTHREAD_H
7 #define CARMA_ALARM_AUDIOCONTROLTHREAD_H
8 
9 #include <string>
10 #include <canberra.h>
11 
12 #include <carma/alarm/SoundsTable.h>
13 #include <carma/util/PthreadMutex.h>
14 #include <carma/util/ConcurrentQueue.h>
15 
16 namespace carma {
17 namespace alarm {
18 
19  class AudioControlThread2
20  {
21  public:
22  /* constructor / destructor */
23  AudioControlThread2(const std::string &devName, const bool emulate, const std::string &soundsTab);
24  ~AudioControlThread2();
25 
26  /* change various properties */
27  void setState(const bool alarmOn);
28  void setSound(const std::string &newSound);
29  void setRepeat(const bool repeat);
30 
31  /* thread entry point */
32  static void audioThreadEP(AudioControlThread2 &This);
33  void exitThread();
34 
35  /* libcanberra audio state machine */
36  void alarmStart();
37  void alarmStop();
38  void alarmCallback();
39 
40  private:
41 
42  /* Alarm Sounds Configuration */
43  SoundsTable table;
44 
45  /* libcanberra audio control */
46  ca_context *ctx;
47  ca_proplist *prop;
48 
49  /* constants from the constructor */
50  const std::string deviceName;
51  const bool emulate;
52 
53  /* protection for members */
54  mutable carma::util::PthreadMutex mutex;
55 
56  /* audio control */
57  std::string sound;
58  bool repeat;
59 
60  carma::util::ConcurrentQueue<int> queue_;
61  };
62 
63 } // namespace alarm
64 } // namespace carma
65 
66 #endif // CARMA_ALARM_AUDIOCONTROLTHREAD_H
A simple wrapper class that makes use of ::pthread_mutex_t easier in a C++ world. ...
Definition: PthreadMutex.h:41