summaryrefslogtreecommitdiffstats
path: root/binding/radio_impl_null.c
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2020-12-06 16:17:51 -0500
committerScott Murray <scott.murray@konsulko.com>2020-12-06 16:24:43 -0500
commit47d61abc94a8c7140c3950329890d0f71f5714eb (patch)
tree23458664ae2611950d75330d15b88154cf3ceff3 /binding/radio_impl_null.c
parentd4fb6eb7a4648b74f930af667f9231226e4ce208 (diff)
Rework hardware probing and RTL-SDR helper startup
The lazy startup of the separate helper program for the RTL-SDR backend on playback start was incorrect with respect to the expected behavior the frequency setting verbs. This was not visible during usage by the radio application, but was triggering failures in several tests in the pyagl binding wrapper test suite. To facilitate starting the helper during backend initialization, the probing part of the backend "init" has been split into a separate "probe" function, and all backends have been updated to reflect this change. Logic has been added to enforce that "init" is only called after "probe" has succeeded for a backend, and a comment has been added to radio_impl.h to document this intended behavior. Bug-AGL: SPEC-3717 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ic37331a92bae7cc01ee448e69894fa5f49d08a74
Diffstat (limited to 'binding/radio_impl_null.c')
-rw-r--r--binding/radio_impl_null.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/binding/radio_impl_null.c b/binding/radio_impl_null.c
index a90835b..b66c025 100644
--- a/binding/radio_impl_null.c
+++ b/binding/radio_impl_null.c
@@ -52,6 +52,7 @@ static fm_band_plan_t known_fm_band_plans[5] = {
static unsigned int bandplan;
static bool present;
+static bool initialized;
static bool active;
static bool scanning;
static uint32_t current_frequency;
@@ -60,7 +61,12 @@ static void *freq_callback_data;
static uint32_t null_get_min_frequency(radio_band_t band);
static void null_set_frequency(uint32_t frequency);
-//static void null_scan_stop(void);
+
+static int null_probe(void)
+{
+ present = true;
+ return 0;
+}
static int null_init(void)
{
@@ -69,7 +75,10 @@ static int null_init(void)
char *rootdir;
char *helper_path;
- if(present)
+ if(!present)
+ return -1;
+
+ if(initialized)
return 0;
// Load settings from configuration file if it exists
@@ -103,7 +112,7 @@ static int null_init(void)
// Start off with minimum bandplan frequency
current_frequency = null_get_min_frequency(BAND_FM);
- present = true;
+ initialized = true;
null_set_frequency(current_frequency);
return 0;
@@ -184,7 +193,7 @@ static uint32_t null_get_frequency_step(radio_band_t band)
static void null_start(void)
{
- if(!present)
+ if(!initialized)
return;
if(active)
@@ -195,7 +204,7 @@ static void null_start(void)
static void null_stop(void)
{
- if(!present)
+ if(!initialized)
return;
if (!active)
@@ -251,6 +260,7 @@ static void null_set_stereo_mode(radio_stereo_mode_t mode)
radio_impl_ops_t null_impl_ops = {
.name = "null/mock radio",
+ .probe = null_probe,
.init = null_init,
.set_output = null_set_output,
.get_frequency = null_get_frequency,