GNU Radio C++ API
gr_audio_registry.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 Free Software Foundation, Inc.
3  *
4  * This file is part of GNU Radio
5  *
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3, or (at your option)
9  * any later version.
10  *
11  * GNU Radio is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef INCLUDED_GR_AUDIO_REGISTRY_H
23 #define INCLUDED_GR_AUDIO_REGISTRY_H
24 
25 #include <gr_audio_sink.h>
26 #include <gr_audio_source.h>
27 #include <string>
28 
29 typedef audio_source::sptr(*source_factory_t)(int, const std::string &, bool);
30 typedef audio_sink::sptr(*sink_factory_t)(int, const std::string &, bool);
31 
33  REG_PRIO_LOW = 100,
34  REG_PRIO_MED = 200,
36 };
37 
38 void audio_register_source(reg_prio_type prio, const std::string &arch, source_factory_t source);
39 void audio_register_sink(reg_prio_type prio, const std::string &arch, sink_factory_t sink);
40 
41 #define AUDIO_REGISTER_FIXTURE(x) static struct x{x();}x;x::x()
42 
43 #define AUDIO_REGISTER_SOURCE(prio, arch) \
44  static audio_source::sptr arch##_source_fcn(int, const std::string &, bool); \
45  AUDIO_REGISTER_FIXTURE(arch##_source_reg){ \
46  audio_register_source(prio, #arch, &arch##_source_fcn); \
47  } static audio_source::sptr arch##_source_fcn
48 
49 #define AUDIO_REGISTER_SINK(prio, arch) \
50  static audio_sink::sptr arch##_sink_fcn(int, const std::string &, bool); \
51  AUDIO_REGISTER_FIXTURE(arch##_sink_reg){ \
52  audio_register_sink(prio, #arch, &arch##_sink_fcn); \
53  } static audio_sink::sptr arch##_sink_fcn
54 
55 #endif /* INCLUDED_GR_AUDIO_REGISTRY_H */