00001 #ifndef AUDIOOUTPUTJACK 00002 #define AUDIOOUTPUTJACK 00003 00004 #include <jack/jack.h> 00005 #include <jack/statistics.h> 00006 #include "audiooutputbase.h" 00007 #include "audiooutputsettings.h" 00008 00009 using namespace std; 00010 00012 #define JACK_CHANNELS_MIN 2 00013 #define JACK_CHANNELS_MAX 8 00014 00015 class AudioOutputJACK : public AudioOutputBase 00016 { 00017 public: 00018 AudioOutputJACK(const AudioSettings &settings); 00019 virtual ~AudioOutputJACK(); 00020 00021 // Volume control 00022 virtual int GetVolumeChannel(int channel) const; // Returns 0-100 00023 virtual void SetVolumeChannel(int channel, int volume); // range 0-100 00024 00025 protected: 00026 00027 // You need to implement the following functions 00028 virtual bool OpenDevice(void); 00029 virtual void CloseDevice(void); 00030 virtual void WriteAudio(unsigned char *aubuf, int size); 00031 virtual int GetBufferedOnSoundcard(void) const; 00032 AudioOutputSettings* GetOutputSettings(bool digital); 00033 00034 // Overriding these to do nothing. Not needed here. 00035 virtual bool StartOutputThread(void); 00036 virtual void StopOutputThread(void); 00037 00038 private: 00039 00040 void VolumeInit(void); 00041 00042 // Our various callback functions 00043 inline int JackCallback(jack_nframes_t nframes); 00044 static int _JackCallback(jack_nframes_t nframes, void *arg); 00045 inline int JackXRunCallback(); 00046 static int _JackXRunCallback(void *arg); 00047 inline int JackGraphOrderCallback(); 00048 static int _JackGraphOrderCallback(void *arg); 00049 00050 jack_client_t* _jack_client_open(void); 00051 const char** _jack_get_ports(void); 00052 bool _jack_connect_ports(const char**); 00053 inline void _jack_client_close(jack_client_t **client); 00054 00055 void DeinterleaveAudio(float *aubuf, float **bufs, 00056 int nframes, int* channel_volumes); 00057 00058 jack_port_t *ports[JACK_CHANNELS_MAX]; 00059 int chan_volumes[JACK_CHANNELS_MAX]; 00060 jack_client_t *client, *stale_client; 00061 int jack_latency; 00062 bool jack_underrun; 00063 int jack_xruns; 00064 unsigned char *aubuf; 00065 00066 00067 }; 00068 00069 #endif 00070
1.6.3