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 JackCallbackHelper(jack_nframes_t nframes, void *arg);
48  inline int JackXRunCallback();
49  static int JackXRunCallbackHelper(void *arg);
50  inline int JackGraphOrderCallback();
51  static int JackGraphOrderCallbackHelper(void *arg);
52 
53  static jack_client_t* JackClientOpen(void);
54  const char** JackGetPorts(void);
55  bool JackConnectPorts(const char** /*matching_ports*/);
56  inline void JackClientClose(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_staleClient {nullptr};
65  int m_jackLatency {0};
66  int m_jackXruns {0};
67  unsigned char *m_auBuf {nullptr};
68 
69 
70 };
71 
72 #endif
73 
channel
QDomElement channel
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:498
AudioOutputJACK::m_staleClient
jack_client_t * m_staleClient
Definition: audiooutputjack.h:64
AudioOutputJACK::JackClientOpen
static jack_client_t * JackClientOpen(void)
Definition: audiooutputjack.cpp:576
AudioOutputJACK::JackGetPorts
const char ** JackGetPorts(void)
Definition: audiooutputjack.cpp:588
AudioOutputJACK::m_chanVolumes
int m_chanVolumes[JACK_CHANNELS_MAX]
Definition: audiooutputjack.h:62
AudioOutputJACK::JackClientClose
void JackClientClose(jack_client_t **client)
Definition: audiooutputjack.cpp:627
AudioOutputJACK::JackConnectPorts
bool JackConnectPorts(const char **)
Definition: audiooutputjack.cpp:610
AudioOutputJACK::OpenDevice
bool OpenDevice(void) override
Definition: audiooutputjack.cpp:123
AudioOutputJACK::m_jackLatency
int m_jackLatency
Definition: audiooutputjack.h:65
AudioOutputJACK::JackGraphOrderCallback
int JackGraphOrderCallback()
Definition: audiooutputjack.cpp:479
arg
arg(title).arg(filename).arg(doDelete))
AudioOutputJACK
Definition: audiooutputjack.h:17
AudioOutputJACK::StartOutputThread
bool StartOutputThread(void) override
Definition: audiooutputjack.cpp:555
AudioOutputJACK::StopOutputThread
void StopOutputThread(void) override
Definition: audiooutputjack.cpp:560
AudioSettings
Definition: audiosettings.h:29
AudioOutputJACK::JackCallback
int JackCallback(jack_nframes_t nframes)
Definition: audiooutputjack.cpp:360
AudioOutputJACK::GetOutputSettings
AudioOutputSettings * GetOutputSettings(bool digital) override
Definition: audiooutputjack.cpp:56
AudioOutputBase
Definition: audiooutputbase.h:50
AudioOutputJACK::GetBufferedOnSoundcard
int GetBufferedOnSoundcard(void) const override
Return the size in bytes of frames currently in the audio buffer adjusted with the audio playback lat...
Definition: audiooutputjack.cpp:244
AudioOutputJACK::JackCallbackHelper
static int JackCallbackHelper(jack_nframes_t nframes, void *arg)
Definition: audiooutputjack.cpp:345
AudioOutputJACK::m_auBuf
unsigned char * m_auBuf
Definition: audiooutputjack.h:67
AudioOutputJACK::WriteAudio
void WriteAudio(unsigned char *aubuf, int size) override
Definition: audiooutputjack.cpp:565
AudioOutputJACK::m_jackXruns
int m_jackXruns
Definition: audiooutputjack.h:66
AudioOutputJACK::VolumeInit
void VolumeInit(void)
Definition: audiooutputjack.cpp:501
AudioOutputJACK::m_ports
jack_port_t * m_ports[JACK_CHANNELS_MAX]
Definition: audiooutputjack.h:61
JACK_CHANNELS_MAX
#define JACK_CHANNELS_MAX
Definition: audiooutputjack.h:14
AudioOutputJACK::JackXRunCallbackHelper
static int JackXRunCallbackHelper(void *arg)
Definition: audiooutputjack.cpp:441
AudioOutputJACK::DeinterleaveAudio
void DeinterleaveAudio(const float *aubuf, float **bufs, int nframes, const int *channel_volumes)
Definition: audiooutputjack.cpp:258
audiooutputbase.h
AudioOutputJACK::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(AudioOutputJACK)
AudioOutputSettings
Definition: audiooutputsettings.h:53
AudioOutputJACK::JackGraphOrderCallbackHelper
static int JackGraphOrderCallbackHelper(void *arg)
Definition: audiooutputjack.cpp:469
AudioOutputJACK::CloseDevice
void CloseDevice(void) override
Definition: audiooutputjack.cpp:228
AudioOutputJACK::AudioOutputJACK
AudioOutputJACK(const AudioSettings &settings)
Definition: audiooutputjack.cpp:42
AudioOutputJACK::JackXRunCallback
int JackXRunCallback()
Definition: audiooutputjack.cpp:450
AudioOutputJACK::SetVolumeChannel
void SetVolumeChannel(int channel, int volume) override
Definition: audiooutputjack.cpp:528
audiooutputsettings.h
AudioOutputJACK::~AudioOutputJACK
~AudioOutputJACK() override
Definition: audiooutputjack.cpp:117
AudioOutputJACK::m_client
jack_client_t * m_client
Definition: audiooutputjack.h:63
AudioOutputJACK::GetVolumeChannel
int GetVolumeChannel(int channel) const override
Definition: audiooutputjack.cpp:515