GNU Radio 3.3.0 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2006,2010 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio. 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_AUDIO_OSX_SINK_H 00024 #define INCLUDED_AUDIO_OSX_SINK_H 00025 00026 #include <gr_sync_block.h> 00027 #include <string> 00028 #include <list> 00029 #include <AudioUnit/AudioUnit.h> 00030 #include <circular_buffer.h> 00031 00032 class audio_osx_sink; 00033 typedef boost::shared_ptr<audio_osx_sink> audio_osx_sink_sptr; 00034 00035 audio_osx_sink_sptr 00036 audio_osx_make_sink (int sample_rate = 44100, 00037 const std::string device_name = "2", 00038 bool do_block = true, 00039 int channel_config = -1, 00040 int max_sample_count = -1); 00041 00042 /*! 00043 * \brief audio sink using OSX 00044 * 00045 * input signature is one or two streams of floats. 00046 * Input samples must be in the range [-1,1]. 00047 */ 00048 00049 class audio_osx_sink : public gr_sync_block { 00050 friend audio_osx_sink_sptr 00051 audio_osx_make_sink (int sample_rate, 00052 const std::string device_name, 00053 bool do_block, 00054 int channel_config, 00055 int max_sample_count); 00056 00057 Float64 d_sample_rate; 00058 int d_channel_config; 00059 UInt32 d_n_channels; 00060 UInt32 d_queueSampleCount, d_max_sample_count; 00061 bool d_do_block; 00062 gruel::mutex* d_internal; 00063 gruel::condition_variable* d_cond_data; 00064 circular_buffer<float>** d_buffers; 00065 00066 // AudioUnits and Such 00067 AudioUnit d_OutputAU; 00068 00069 protected: 00070 audio_osx_sink (int sample_rate = 44100, 00071 const std::string device_name = "2", 00072 bool do_block = true, 00073 int channel_config = -1, 00074 int max_sample_count = -1); 00075 00076 public: 00077 ~audio_osx_sink (); 00078 00079 bool IsRunning (); 00080 bool start (); 00081 bool stop (); 00082 00083 int work (int noutput_items, 00084 gr_vector_const_void_star &input_items, 00085 gr_vector_void_star &output_items); 00086 00087 private: 00088 static OSStatus AUOutputCallback (void *inRefCon, 00089 AudioUnitRenderActionFlags *ioActionFlags, 00090 const AudioTimeStamp *inTimeStamp, 00091 UInt32 inBusNumber, 00092 UInt32 inNumberFrames, 00093 AudioBufferList *ioData); 00094 }; 00095 00096 #endif /* INCLUDED_AUDIO_OSX_SINK_H */