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 
16 using jack_port_array = std::array<jack_port_t*,JACK_CHANNELS_MAX>;
17 using jack_vol_array = std::array<int,JACK_CHANNELS_MAX>;
18 
20 {
22 
23  public:
24  explicit AudioOutputJACK(const AudioSettings &settings);
25  ~AudioOutputJACK() override;
26 
27  // Volume control
28  int GetVolumeChannel(int channel) const override; // VolumeBase
29  void SetVolumeChannel(int channel, int volume) override; // VolumeBase
30 
31  protected:
32 
33  // You need to implement the following functions
34  bool OpenDevice(void) override; // AudioOutputBase
35  void CloseDevice(void) override; // AudioOutputBase
36  void WriteAudio(unsigned char *aubuf, int size) override; // AudioOutputBase
37  int GetBufferedOnSoundcard(void) const override; // AudioOutputBase
38  AudioOutputSettings* GetOutputSettings(bool digital) override; // AudioOutputBase
39 
40  // Overriding these to do nothing. Not needed here.
41  bool StartOutputThread(void) override; // AudioOutputBase
42  void StopOutputThread(void) override; // AudioOutputBase
43 
44  private:
45 
46  void VolumeInit(void);
47 
48  // Our various callback functions
49  inline int JackCallback(jack_nframes_t nframes);
50  static int JackCallbackHelper(jack_nframes_t nframes, void *arg);
51  inline int JackXRunCallback();
52  static int JackXRunCallbackHelper(void *arg);
53  inline int JackGraphOrderCallback();
54  static int JackGraphOrderCallbackHelper(void *arg);
55 
56  static jack_client_t* JackClientOpen(void);
57  const char** JackGetPorts(void);
58  bool JackConnectPorts(const char** /*matching_ports*/);
59  inline void JackClientClose(jack_client_t **client);
60 
61  void DeinterleaveAudio(const float *aubuf, float **bufs,
62  int nframes, const jack_vol_array& channel_volumes);
63 
66  jack_client_t *m_client {nullptr};
67  jack_client_t *m_staleClient {nullptr};
68  int m_jackLatency {0};
69  int m_jackXruns {0};
70  unsigned char *m_auBuf {nullptr};
71 
72 
73 };
74 
75 #endif
76 
channel
QDomElement channel
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:501
AudioOutputJACK::m_staleClient
jack_client_t * m_staleClient
Definition: audiooutputjack.h:67
AudioOutputJACK::JackClientOpen
static jack_client_t * JackClientOpen(void)
Definition: audiooutputjack.cpp:571
AudioOutputJACK::JackGetPorts
const char ** JackGetPorts(void)
Definition: audiooutputjack.cpp:583
AudioOutputJACK::JackClientClose
void JackClientClose(jack_client_t **client)
Definition: audiooutputjack.cpp:622
AudioOutputJACK::JackConnectPorts
bool JackConnectPorts(const char **)
Definition: audiooutputjack.cpp:605
AudioOutputJACK::OpenDevice
bool OpenDevice(void) override
Definition: audiooutputjack.cpp:119
AudioOutputJACK::m_jackLatency
int m_jackLatency
Definition: audiooutputjack.h:68
AudioOutputJACK::JackGraphOrderCallback
int JackGraphOrderCallback()
Definition: audiooutputjack.cpp:475
arg
arg(title).arg(filename).arg(doDelete))
AudioOutputJACK
Definition: audiooutputjack.h:20
AudioOutputJACK::StartOutputThread
bool StartOutputThread(void) override
Definition: audiooutputjack.cpp:550
AudioOutputJACK::m_ports
jack_port_array m_ports
Definition: audiooutputjack.h:64
AudioOutputJACK::StopOutputThread
void StopOutputThread(void) override
Definition: audiooutputjack.cpp:555
AudioSettings
Definition: audiosettings.h:29
jack_vol_array
std::array< int, JACK_CHANNELS_MAX > jack_vol_array
Definition: audiooutputjack.h:17
AudioOutputJACK::JackCallback
int JackCallback(jack_nframes_t nframes)
Definition: audiooutputjack.cpp:356
AudioOutputJACK::GetOutputSettings
AudioOutputSettings * GetOutputSettings(bool digital) override
Definition: audiooutputjack.cpp:52
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:240
AudioOutputJACK::JackCallbackHelper
static int JackCallbackHelper(jack_nframes_t nframes, void *arg)
Definition: audiooutputjack.cpp:341
AudioOutputJACK::m_auBuf
unsigned char * m_auBuf
Definition: audiooutputjack.h:70
AudioOutputJACK::WriteAudio
void WriteAudio(unsigned char *aubuf, int size) override
Definition: audiooutputjack.cpp:560
AudioOutputJACK::m_jackXruns
int m_jackXruns
Definition: audiooutputjack.h:69
AudioOutputJACK::VolumeInit
void VolumeInit(void)
Definition: audiooutputjack.cpp:497
AudioOutputJACK::JackXRunCallbackHelper
static int JackXRunCallbackHelper(void *arg)
Definition: audiooutputjack.cpp:437
audiooutputbase.h
AudioOutputJACK::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(AudioOutputJACK)
AudioOutputJACK::DeinterleaveAudio
void DeinterleaveAudio(const float *aubuf, float **bufs, int nframes, const jack_vol_array &channel_volumes)
Definition: audiooutputjack.cpp:254
AudioOutputSettings
Definition: audiooutputsettings.h:50
AudioOutputJACK::m_chanVolumes
jack_vol_array m_chanVolumes
Definition: audiooutputjack.h:65
AudioOutputJACK::JackGraphOrderCallbackHelper
static int JackGraphOrderCallbackHelper(void *arg)
Definition: audiooutputjack.cpp:465
AudioOutputJACK::CloseDevice
void CloseDevice(void) override
Definition: audiooutputjack.cpp:224
AudioOutputJACK::AudioOutputJACK
AudioOutputJACK(const AudioSettings &settings)
Definition: audiooutputjack.cpp:40
AudioOutputJACK::JackXRunCallback
int JackXRunCallback()
Definition: audiooutputjack.cpp:446
jack_port_array
std::array< jack_port_t *, JACK_CHANNELS_MAX > jack_port_array
Definition: audiooutputjack.h:16
AudioOutputJACK::SetVolumeChannel
void SetVolumeChannel(int channel, int volume) override
Definition: audiooutputjack.cpp:523
audiooutputsettings.h
AudioOutputJACK::~AudioOutputJACK
~AudioOutputJACK() override
Definition: audiooutputjack.cpp:113
AudioOutputJACK::m_client
jack_client_t * m_client
Definition: audiooutputjack.h:66
AudioOutputJACK::GetVolumeChannel
int GetVolumeChannel(int channel) const override
Definition: audiooutputjack.cpp:510