summaryrefslogtreecommitdiffstats
path: root/rtl_fm.h
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2016-12-23 00:30:27 -0500
committerScott Murray <scott.murray@konsulko.com>2016-12-23 05:21:30 -0500
commitd9a424c6c35dfb2ce7aefaaca708f3bc67d8c938 (patch)
tree99dcccaca2a753cda578aeb8ac649da4a64be1d8 /rtl_fm.h
parentbb08422f14659e811e11d15cc5365b3b91fccef0 (diff)
Switch to direct use of librtlsdr and PulseAudio
Substantial rework to replace the spawning of rtl_fm and aplay with direct usage of librtlsdr and PulseAudio in a multi-threaded model. This is required due to changes in AGL application execution that prevent spawned processes from exiting, resulting in the plugin hanging on frequency changes or stopping. The rework has been accomplished by refactoring the source of rtl_fm.c into a reusable form and connecting it to the RtlFmRadioTunerControl class used to implement the functionality exposed by the RtlFmRadioPlugin class. The idea for reusing the source code in rtl_fm.c in this way is inspired by the older qml_radio_plugin codebase, but a new refactor of rtl_fm.c was done to keep more of its filtering functionality and ensure behavior consistent with the previous implementation. The files radio_output.{h,cpp} are adapted from qml_radio_plugin with some additional modifications. Other changes include: - The files in the convenience subdirectory have been copied from the librtldr source tree to reduce the effort of importing rtl_fm.c. - The COPYING file containing the GPL license has been copied from the librtlsdr source tree to accompany rtl_fm.c and the convenience/* files. - The recently added AM band support has been removed as the USB DVB adapters are incapable of receiving AM without significant tweaking, and a single adapter would be unable to do both AM and FM at the same time. The plugin now explicitly reports that it only supports FM. - The list of known stations to act as an ersatz seeking implementation has been removed, as the updated higher-level QML application no longer exposes seeking. Adding this functionality back in would be straightforward if it becomes required again. There is also some code in rtl_fm.c that could possibly be adapted into a proper signal strength detection scheme in the future if that is desired. - A Qt QSettings file is used to store the FM band plan information to allow using the specific frequency ranges for North America versus Japan. The band plan can be changed by modifying the "fmbandplan" entry in the QSettings .conf file to either "US" or "JP". The location of the .conf file can be one of: $HOME/.config/AGL/qtmultimedia-rtlfm-radio-plugin.conf $HOME/.config/AGL.conf /etc/xdg/AGL/qtmultimedia-rtlfm-radio-plugin.conf /etc/xdg/AGL.conf Note that some debugging output has been left in place in the start and stop methods to facilitate debugging of the higher-level QML application. They will be removed once that is complete. Change-Id: I1d92c74eb24b24cb5416dd531b599645d1287295 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Diffstat (limited to 'rtl_fm.h')
-rw-r--r--rtl_fm.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/rtl_fm.h b/rtl_fm.h
new file mode 100644
index 0000000..a35d341
--- /dev/null
+++ b/rtl_fm.h
@@ -0,0 +1,50 @@
+/*
+ * rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver
+ * Copyright (C) 2016 by Scott Murray <scott.murray@konsulko.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RTL_FM_H
+#define RTL_FM_H
+
+#define RTL_FM_DEFAULT_BUF_LENGTH (1 * 16384)
+#define RTL_FM_MAXIMUM_OVERSAMPLE 16
+#define RTL_FM_MAXIMUM_BUF_LENGTH (RTL_FM_MAXIMUM_OVERSAMPLE * RTL_FM_DEFAULT_BUF_LENGTH)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*rtl_fm_output_fn_t)(int16_t *result, int result_len, void *data);
+
+int rtl_fm_init(uint32_t freq,
+ uint32_t sample_rate,
+ uint32_t resample_rate,
+ rtl_fm_output_fn_t output_fn,
+ void *output_fn_data);
+
+void rtl_fm_start(void);
+
+void rtl_fm_set_freq(uint32_t freq);
+
+void rtl_fm_stop(void);
+
+void rtl_fm_cleanup(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* RTL_FM_H */