-
Notifications
You must be signed in to change notification settings - Fork 342
/
audiooutputpulse.h
72 lines (62 loc) · 2.47 KB
/
audiooutputpulse.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* Copyright (C) 2008 Alan Calvert
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#ifndef AUDIOOUTPUTPULSE
#define AUDIOOUTPUTPULSE
#include <pulse/pulseaudio.h>
#include "audiooutputbase.h"
class AudioOutputPulseAudio : public AudioOutputBase
{
public:
AudioOutputPulseAudio(const AudioSettings &settings);
~AudioOutputPulseAudio();
int GetVolumeChannel(int channel) const;
void SetVolumeChannel(int channel, int volume);
void Drain(void);
protected:
AudioOutputSettings* GetOutputSettings(bool /*digital*/);
bool OpenDevice(void);
void CloseDevice(void);
void WriteAudio(unsigned char *aubuf, int size);
int GetBufferedOnSoundcard(void) const;
private:
char *ChooseHost(void);
bool MapChannels(void);
bool ContextConnect(void);
bool ConnectPlaybackStream(void);
void FlushStream(const char *caller);
static void ContextStateCallback(pa_context *c, void *arg);
static void StreamStateCallback(pa_stream *s, void *arg);
static void OpCompletionCallback(pa_context *c, int ok, void *arg);
static void WriteCallback(pa_stream *s, size_t size, void *arg);
static void BufferFlowCallback(pa_stream *s, void *tag);
static void ServerInfoCallback(pa_context *context,
const pa_server_info *inf, void *arg);
static void SinkInfoCallback(pa_context *c, const pa_sink_info *info,
int eol, void *arg);
pa_context *pcontext;
pa_stream *pstream;
pa_threaded_mainloop *mainloop;
pa_sample_spec sample_spec;
pa_channel_map channel_map;
pa_cvolume volume_control;
pa_buffer_attr buffer_settings;
AudioOutputSettings *m_aosettings;
};
#endif
/* vim: set expandtab tabstop=4 shiftwidth=4: */