1 /* -*- c++ -*- */
2 /*
3  * Gqrx SDR: Software defined radio receiver powered by GNU Radio and Qt
4  *           https://gqrx.dk/
5  *
6  * Copyright 2012 Alexandru Csete OZ9AEC.
7  *
8  * Gqrx is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3, or (at your option)
11  * any later version.
12  *
13  * Gqrx is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Gqrx; see the file COPYING.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street,
21  * Boston, MA 02110-1301, USA.
22  */
23 #ifndef PA_SOURCE_H
24 #define PA_SOURCE_H
25 
26 #include <string>
27 #include <gnuradio/sync_block.h>
28 #include <pulse/simple.h>
29 
30 using namespace std;
31 
32 class pa_source;
33 
34 #if GNURADIO_VERSION < 0x030900
35 typedef boost::shared_ptr<pa_source> pa_source_sptr;
36 #else
37 typedef std::shared_ptr<pa_source> pa_source_sptr;
38 #endif
39 
40 pa_source_sptr make_pa_source(const string device_name,
41                               int sample_rate,
42                               int num_chan,
43                               const string app_name,
44                               const string stream_name);
45 
46 
47 /*! \brief Pulseaudio source.
48  *  \ingroup IO
49  *
50  */
51 class pa_source : public gr::sync_block
52 {
53     friend pa_source_sptr make_pa_source(const string device_name, int sample_rate, int num_chan,
54                                          const string app_name, const string stream_name);
55 
56 public:
57     pa_source(const string device_name, int sample_rate, int num_chan,
58               const string app_name, const string stream_name);
59     ~pa_source();
60 
61     int work (int noutput_items,
62               gr_vector_const_void_star &input_items,
63               gr_vector_void_star &output_items);
64 
65     void select_device(string device_name);
66 
67 private:
68     pa_sample_spec d_ss;           /*! Sample specification. */
69     string         d_stream_name;  /*! Descriptive name of the stream. */
70     string         d_app_name;     /*! Descriptive name of the application. */
71     pa_simple     *d_pasrc;        /*! The pulseaudio object. */
72 
73 };
74 
75 #endif /* PA_SOURCE_H */
76