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_PORTAUDIO_SINK_H
00023 #define INCLUDED_AUDIO_PORTAUDIO_SINK_H
00024
00025 #include <gr_sync_block.h>
00026 #include <gr_buffer.h>
00027 #include <gnuradio/omnithread.h>
00028 #include <string>
00029 #include <portaudio.h>
00030 #include <stdexcept>
00031 #include <gri_logger.h>
00032
00033 class audio_portaudio_sink;
00034 typedef boost::shared_ptr<audio_portaudio_sink> audio_portaudio_sink_sptr;
00035
00036
00037
00038
00039
00040
00041
00042
00043 audio_portaudio_sink_sptr
00044 audio_portaudio_make_sink (int sampling_rate,
00045 const std::string device_name = "",
00046 bool ok_to_block = true);
00047
00048 PaStreamCallback portaudio_sink_callback;
00049
00050
00051
00052
00053
00054
00055
00056 class audio_portaudio_sink : public gr_sync_block {
00057 friend audio_portaudio_sink_sptr
00058 audio_portaudio_make_sink (int sampling_rate,
00059 const std::string device_name,
00060 bool ok_to_block);
00061
00062 friend PaStreamCallback portaudio_sink_callback;
00063
00064
00065 unsigned int d_sampling_rate;
00066 std::string d_device_name;
00067 bool d_ok_to_block;
00068 bool d_verbose;
00069
00070 unsigned int d_portaudio_buffer_size_frames;
00071
00072 PaStream *d_stream;
00073 PaStreamParameters d_output_parameters;
00074
00075 gr_buffer_sptr d_writer;
00076 gr_buffer_reader_sptr d_reader;
00077 omni_semaphore d_ringbuffer_ready;
00078
00079
00080
00081 int d_nunderuns;
00082 gri_logger_sptr d_log;
00083
00084 void output_error_msg (const char *msg, int err);
00085 void bail (const char *msg, int err) throw (std::runtime_error);
00086 void create_ringbuffer();
00087
00088
00089 protected:
00090 audio_portaudio_sink (int sampling_rate, const std::string device_name,
00091 bool ok_to_block);
00092
00093 public:
00094 ~audio_portaudio_sink ();
00095
00096 bool check_topology (int ninputs, int noutputs);
00097
00098 int work (int noutput_items,
00099 gr_vector_const_void_star &input_items,
00100 gr_vector_void_star &output_items);
00101 };
00102
00103 #endif