MythTV  master
audiooutputjack.h
Go to the documentation of this file.
1 #ifndef AUDIOOUTPUTJACK
2 #define AUDIOOUTPUTJACK
3 
4 // Qt headers
5 #include <QCoreApplication>
6 
7 #include <jack/jack.h>
8 #include <jack/statistics.h>
9 #include "audiooutputbase.h"
10 #include "audiooutputsettings.h"
11 
13 #define JACK_CHANNELS_MIN 2
14 #define JACK_CHANNELS_MAX 8
15 
17 {
19 
20  public:
21  explicit AudioOutputJACK(const AudioSettings &settings);
22  ~AudioOutputJACK() override;
23 
24  // Volume control
25  int GetVolumeChannel(int channel) const override; // VolumeBase
26  void SetVolumeChannel(int channel, int volume) override; // VolumeBase
27 
28  protected:
29 
30  // You need to implement the following functions
31  bool OpenDevice(void) override; // AudioOutputBase
32  void CloseDevice(void) override; // AudioOutputBase
33  void WriteAudio(unsigned char *aubuf, int size) override; // AudioOutputBase
34  int GetBufferedOnSoundcard(void) const override; // AudioOutputBase
35  AudioOutputSettings* GetOutputSettings(bool digital) override; // AudioOutputBase
36 
37  // Overriding these to do nothing. Not needed here.
38  bool StartOutputThread(void) override; // AudioOutputBase
39  void StopOutputThread(void) override; // AudioOutputBase
40 
41  private:
42 
43  void VolumeInit(void);
44 
45  // Our various callback functions
46  inline int JackCallback(jack_nframes_t nframes);
47  static int _JackCallback(jack_nframes_t nframes, void *arg);
48  inline int JackXRunCallback();
49  static int _JackXRunCallback(void *arg);
50  inline int JackGraphOrderCallback();
51  static int _JackGraphOrderCallback(void *arg);
52 
53  jack_client_t* _jack_client_open(void);
54  const char** _jack_get_ports(void);
55  bool _jack_connect_ports(const char** /*matching_ports*/);
56  inline void _jack_client_close(jack_client_t **client);
57 
58  void DeinterleaveAudio(const float *aubuf, float **bufs,
59  int nframes, const int* channel_volumes);
60 
61  jack_port_t *m_ports[JACK_CHANNELS_MAX];
63  jack_client_t *m_client {nullptr};
64  jack_client_t *m_stale_client {nullptr};
65  int m_jack_latency {0};
66  int m_jack_xruns {0};
67  unsigned char *m_aubuf {nullptr};
68 
69 
70 };
71 
72 #endif
73 
jack_client_t * m_client
#define JACK_CHANNELS_MAX
void CloseDevice(void) override
const char ** _jack_get_ports(void)
int GetBufferedOnSoundcard(void) const override
Return the size in bytes of frames currently in the audio buffer adjusted with the audio playback lat...
jack_client_t * _jack_client_open(void)
void DeinterleaveAudio(const float *aubuf, float **bufs, int nframes, const int *channel_volumes)
AudioOutputJACK(const AudioSettings &settings)
static int _JackGraphOrderCallback(void *arg)
void WriteAudio(unsigned char *aubuf, int size) override
void _jack_client_close(jack_client_t **client)
static int _JackCallback(jack_nframes_t nframes, void *arg)
int GetVolumeChannel(int channel) const override
jack_client_t * m_stale_client
bool _jack_connect_ports(const char **)
static int _JackXRunCallback(void *arg)
void SetVolumeChannel(int channel, int volume) override
bool OpenDevice(void) override
~AudioOutputJACK() override
int JackCallback(jack_nframes_t nframes)
jack_port_t * m_ports[JACK_CHANNELS_MAX]
unsigned char * m_aubuf
int m_chan_volumes[JACK_CHANNELS_MAX]
bool StartOutputThread(void) override
AudioOutputSettings * GetOutputSettings(bool digital) override
Q_DECLARE_TR_FUNCTIONS(AudioOutputJACK)
void StopOutputThread(void) override