audio_jack_sink.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef INCLUDED_AUDIO_JACK_SINK_H
00023 #define INCLUDED_AUDIO_JACK_SINK_H
00024
00025 #include <gr_sync_block.h>
00026 #include <string>
00027 #include <jack/jack.h>
00028 #include <jack/ringbuffer.h>
00029 #include <stdexcept>
00030
00031 class audio_jack_sink;
00032 typedef boost::shared_ptr<audio_jack_sink> audio_jack_sink_sptr;
00033
00041 audio_jack_sink_sptr
00042 audio_jack_make_sink (int sampling_rate,
00043 const std::string dev = "",
00044 bool ok_to_block = true);
00045
00046 int jack_sink_process (jack_nframes_t nframes, void *arg);
00047
00055 class audio_jack_sink : public gr_sync_block {
00056 friend audio_jack_sink_sptr
00057 audio_jack_make_sink (int sampling_rate, const std::string device_name, bool ok_to_block);
00058
00059 friend int jack_sink_process (jack_nframes_t nframes, void *arg);
00060
00061
00062 typedef int (audio_jack_sink::*work_t)(int noutput_items,
00063 gr_vector_const_void_star &input_items,
00064 gr_vector_void_star &output_items);
00065
00066 unsigned int d_sampling_rate;
00067 std::string d_device_name;
00068 bool d_ok_to_block;
00069
00070 jack_client_t *d_jack_client;
00071 jack_port_t *d_jack_output_port;
00072 jack_ringbuffer_t *d_ringbuffer;
00073 jack_nframes_t d_jack_buffer_size;
00074 pthread_cond_t d_ringbuffer_ready;
00075 pthread_mutex_t d_jack_process_lock;
00076
00077
00078 int d_nunderuns;
00079
00080 void output_error_msg (const char *msg, int err);
00081 void bail (const char *msg, int err) throw (std::runtime_error);
00082
00083
00084 protected:
00085 audio_jack_sink (int sampling_rate, const std::string device_name, bool ok_to_block);
00086
00087 public:
00088 ~audio_jack_sink ();
00089
00090 bool check_topology (int ninputs, int noutputs);
00091
00092 int work (int noutput_items,
00093 gr_vector_const_void_star &input_items,
00094 gr_vector_void_star &output_items);
00095 };
00096
00097 #endif