diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-12-12 15:23:25 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2019-12-13 15:21:35 -0800 |
commit | b0cdc2b0ab623be1841ba4b60d1755f5bf706283 (patch) | |
tree | eabbebcd373bfc9ce7250420aa5e7cfd9cf46915 /binding | |
parent | 404f3d662374404c9f5484a78ea2b8da9ba8656f (diff) |
radio: check for corking from PipeWire
Check if PipeWire is corking the audio stream and if so don't
process signal-composer events till uncorked
Bug-AGL: SPEC-3023
Change-Id: I1a4623022bbe28658bc97b5fe0cda58863f20d8c
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r-- | binding/radio-binding.c | 4 | ||||
-rw-r--r-- | binding/radio_impl.h | 2 | ||||
-rw-r--r-- | binding/radio_impl_kingfisher.c | 27 |
3 files changed, 33 insertions, 0 deletions
diff --git a/binding/radio-binding.c b/binding/radio-binding.c index 72f36ff..0de45a6 100644 --- a/binding/radio-binding.c +++ b/binding/radio-binding.c @@ -522,6 +522,10 @@ static void onevent(afb_api_t api, const char *event, struct json_object *object if (strncmp(uid, "event.media.", 12)) return; + if (radio_impl_ops->get_corking_state && + radio_impl_ops->get_corking_state()) + return; + json_object_object_get_ex(object, "value", &tmp); if (tmp == NULL) return; diff --git a/binding/radio_impl.h b/binding/radio_impl.h index 0216f69..009df9b 100644 --- a/binding/radio_impl.h +++ b/binding/radio_impl.h @@ -64,6 +64,8 @@ typedef struct { uint32_t (*get_frequency_step)(radio_band_t band); + bool (*get_corking_state)(void); + void (*start)(void); void (*stop)(void); diff --git a/binding/radio_impl_kingfisher.c b/binding/radio_impl_kingfisher.c index 24c547f..8455ade 100644 --- a/binding/radio_impl_kingfisher.c +++ b/binding/radio_impl_kingfisher.c @@ -53,6 +53,7 @@ static fm_band_plan_t known_fm_band_plans[5] = { }; static unsigned int bandplan = 0; +static bool corking = false; static bool present = false; static uint32_t current_frequency; static int scan_valid_snr_threshold = 128; @@ -69,6 +70,24 @@ static void *freq_callback_data; static uint32_t kf_get_min_frequency(radio_band_t band); static void kf_scan_stop(void); +static gboolean handle_message(GstBus *bus, GstMessage *msg, __attribute__((unused)) void *ptr) +{ + GstState state; + + if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_REQUEST_STATE) { + + gst_message_parse_request_state(msg, &state); + + if (state == GST_STATE_PAUSED) + corking = true; + else if (state == GST_STATE_PLAYING) + corking = false; + + } + + return TRUE; +} + static int kf_init(void) { GKeyFile* conf_file; @@ -183,6 +202,8 @@ static int kf_init(void) // Start pipeline in paused state gst_element_set_state(pipeline, GST_STATE_PAUSED); + gst_bus_add_watch(gst_element_get_bus(pipeline), (GstBusFunc) handle_message, NULL); + present = true; return 0; } @@ -310,6 +331,11 @@ static uint32_t kf_get_frequency_step(radio_band_t band) return ret; } +static bool kf_get_corking_state(void) +{ + return corking; +} + static void kf_start(void) { if(!present) @@ -432,6 +458,7 @@ radio_impl_ops_t kf_impl_ops = { .get_min_frequency = kf_get_min_frequency, .get_max_frequency = kf_get_max_frequency, .get_frequency_step = kf_get_frequency_step, + .get_corking_state = kf_get_corking_state, .start = kf_start, .stop = kf_stop, .scan_start = kf_scan_start, |