-
Notifications
You must be signed in to change notification settings - Fork 342
/
audiooutputjack.h
70 lines (52 loc) · 1.94 KB
/
audiooutputjack.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
#ifndef AUDIOOUTPUTJACK
#define AUDIOOUTPUTJACK
#include <jack/jack.h>
#include <jack/statistics.h>
#include "audiooutputbase.h"
#include "audiooutputsettings.h"
using namespace std;
//! maximum number of channels supported, avoids lots of mallocs
#define JACK_CHANNELS_MIN 2
#define JACK_CHANNELS_MAX 8
class AudioOutputJACK : public AudioOutputBase
{
public:
AudioOutputJACK(const AudioSettings &settings);
virtual ~AudioOutputJACK();
// Volume control
virtual int GetVolumeChannel(int channel) const; // Returns 0-100
virtual void SetVolumeChannel(int channel, int volume); // range 0-100
protected:
// You need to implement the following functions
virtual bool OpenDevice(void);
virtual void CloseDevice(void);
virtual void WriteAudio(unsigned char *aubuf, int size);
virtual int GetBufferedOnSoundcard(void) const;
AudioOutputSettings* GetOutputSettings(bool /*digital*/);
// Overriding these to do nothing. Not needed here.
virtual bool StartOutputThread(void);
virtual void StopOutputThread(void);
private:
void VolumeInit(void);
// Our various callback functions
inline int JackCallback(jack_nframes_t nframes);
static int _JackCallback(jack_nframes_t nframes, void *arg);
inline int JackXRunCallback();
static int _JackXRunCallback(void *arg);
inline int JackGraphOrderCallback();
static int _JackGraphOrderCallback(void *arg);
jack_client_t* _jack_client_open(void);
const char** _jack_get_ports(void);
bool _jack_connect_ports(const char**);
inline void _jack_client_close(jack_client_t **client);
void DeinterleaveAudio(float *aubuf, float **bufs,
int nframes, int* channel_volumes);
jack_port_t *ports[JACK_CHANNELS_MAX];
int chan_volumes[JACK_CHANNELS_MAX];
jack_client_t *client, *stale_client;
int jack_latency;
bool jack_underrun;
int jack_xruns;
unsigned char *aubuf;
};
#endif