Mercurial > hg > svapp
comparison audioio/AudioPulseAudioTarget.h @ 117:2bc8bf6d016c
* Provisional PulseAudio output driver. No latency handling yet, and
some other things missing. The very basic basics work.
author | Chris Cannam |
---|---|
date | Wed, 21 May 2008 16:54:24 +0000 |
parents | |
children | c41e340dfe8d |
comparison
equal
deleted
inserted
replaced
116:9554c19c42fd | 117:2bc8bf6d016c |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2008 QMUL. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef _AUDIO_PULSE_AUDIO_TARGET_H_ | |
17 #define _AUDIO_PULSE_AUDIO_TARGET_H_ | |
18 | |
19 #ifdef HAVE_LIBPULSE | |
20 | |
21 #include <pulse/pulseaudio.h> | |
22 | |
23 #include <QObject> | |
24 #include <QMutex> | |
25 #include <QThread> | |
26 | |
27 #include "AudioCallbackPlayTarget.h" | |
28 | |
29 class AudioCallbackPlaySource; | |
30 | |
31 class AudioPulseAudioTarget : public AudioCallbackPlayTarget | |
32 { | |
33 Q_OBJECT | |
34 | |
35 public: | |
36 AudioPulseAudioTarget(AudioCallbackPlaySource *source); | |
37 virtual ~AudioPulseAudioTarget(); | |
38 | |
39 virtual void shutdown(); | |
40 | |
41 virtual bool isOK() const; | |
42 | |
43 virtual double getCurrentTime() const; | |
44 | |
45 public slots: | |
46 virtual void sourceModelReplaced(); | |
47 | |
48 protected: | |
49 void streamWrite(size_t); | |
50 void streamStateChanged(); | |
51 void contextStateChanged(); | |
52 | |
53 static void streamWriteStatic(pa_stream *, size_t, void *); | |
54 static void streamStateChangedStatic(pa_stream *, void *); | |
55 static void contextStateChangedStatic(pa_context *, void *); | |
56 | |
57 QMutex m_mutex; | |
58 | |
59 class MainLoopThread : public QThread | |
60 { | |
61 public: | |
62 MainLoopThread(pa_mainloop *loop) : m_loop(loop) { } | |
63 virtual void run() { | |
64 int rv = 0; | |
65 pa_mainloop_run(m_loop, &rv); //!!! check return value from this, and rv | |
66 } | |
67 | |
68 private: | |
69 pa_mainloop *m_loop; | |
70 }; | |
71 | |
72 pa_mainloop *m_loop; | |
73 pa_mainloop_api *m_api; | |
74 pa_context *m_context; | |
75 pa_stream *m_stream; | |
76 pa_sample_spec m_spec; | |
77 | |
78 MainLoopThread *m_loopThread; | |
79 | |
80 int m_bufferSize; | |
81 int m_sampleRate; | |
82 int m_latency; | |
83 bool m_done; | |
84 }; | |
85 | |
86 #endif /* HAVE_PULSEAUDIO */ | |
87 | |
88 #endif | |
89 |