diff options
author | Scott Murray <scottm@ghidorah.spiteful.org> | 2018-05-28 21:16:23 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2018-06-05 21:17:14 -0400 |
commit | 9f5ed322b54f12c1055d2a124d687965083d4dee (patch) | |
tree | 4d8d115bd3683d3e2ff01379d55e04ff9f9e6579 /binding/radio-binding.c | |
parent | 127da1228b47486de500424e4a2ab3f0f5f0ec4a (diff) |
Rework output to directly support 4Aflounder_5.99.1flounder/5.99.15.99.1
When building for 4A, switch to new gstreamer-based ALSA output for
the RTL-SDR backend, and the Kingfisher backend now uses a gstreamer
pipeline for its loopback to either an ALSA or Pulse sink depending
on 4A or not. Using gstreamer instead of direct ALSA output has the
benefit of transparently handling resampling to the M3ULCB hardware's
required 48 KHz sample rate for the RTL-SDR backend.
Change-Id: I2bfbf924927bb461cce88b04aba0e626f8d71215
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Diffstat (limited to 'binding/radio-binding.c')
-rw-r--r-- | binding/radio-binding.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/binding/radio-binding.c b/binding/radio-binding.c index 8efe3bd..4db34db 100644 --- a/binding/radio-binding.c +++ b/binding/radio-binding.c @@ -466,22 +466,53 @@ static const struct afb_verb_v2 verbs[]= { static int init() { int rc; + char *output = NULL; + +#ifdef HAVE_4A_FRAMEWORK + json_object *response; + + json_object *jsonData = json_object_new_object(); + json_object_object_add(jsonData, "audio_role", json_object_new_string("Radio")); + json_object_object_add(jsonData, "endpoint_type", json_object_new_string("sink")); + rc = afb_service_call_sync("ahl-4a", "stream_open", jsonData, &response); + if(!rc) { + json_object *valJson = NULL; + json_object *val = NULL; + + rc = json_object_object_get_ex(response, "response", &valJson); + if(rc) { + rc = json_object_object_get_ex(valJson, "device_uri", &val); + if(rc) { + const char *jres_pcm = json_object_get_string(val); + char *p; + if((p = strchr(jres_pcm, ':'))) { + output = strdup(p + 1); + } + } + } + } else { + AFB_ERROR("afb_service_call_sync failed\n"); + return rc; + } +#endif + // Initialize event structures freq_event = afb_daemon_make_event("frequency"); scan_event = afb_daemon_make_event("station_found"); // Look for RTL-SDR USB adapter radio_impl_ops = &rtlsdr_impl_ops; - rc = radio_impl_ops->init(); + rc = radio_impl_ops->init(output); if(rc != 0) { // Look for Kingfisher Si4689 radio_impl_ops = &kf_impl_ops; - rc = radio_impl_ops->init(); + rc = radio_impl_ops->init(output); } if(rc == 0) { printf("%s found\n", radio_impl_ops->name); radio_impl_ops->set_frequency_callback(freq_callback, NULL); } + free(output); return rc; } |