From 63fa85a6ae00672a4d4b3bf7ad1a25f7fca7fc82 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Fri, 7 Feb 2014 15:32:01 +0100 Subject: [PATCH] libv4l2rds: update the list of AFs if the number of AFs changes If the number of alternate frequencies changes, then the internal list of such frequencies should be cleared. Signed-off-by: Hans Verkuil --- lib/libv4l2rds/libv4l2rds.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/libv4l2rds/libv4l2rds.c b/lib/libv4l2rds/libv4l2rds.c index 71c6299..616dc46 100644 --- a/lib/libv4l2rds/libv4l2rds.c +++ b/lib/libv4l2rds/libv4l2rds.c @@ -637,6 +637,7 @@ static bool rds_add_af_to_list(struct v4l2_rds_af_set *af_set, uint8_t af, bool { /* convert the frequency to Hz, skip on errors */ uint32_t freq = rds_decode_af(af, is_vhf); + if (freq == 0) return false; @@ -649,7 +650,7 @@ static bool rds_add_af_to_list(struct v4l2_rds_af_set *af_set, uint8_t af, bool return false; } /* it's a new AF, add it to the list */ - af_set->af[(af_set->size)++] = freq; + af_set->af[af_set->size++] = freq; return true; } @@ -677,9 +678,14 @@ static bool rds_add_af(struct rds_private_state *priv_state) c_lsb = 0; /* invalidate */ } /* 224..249: announcement of AF count (224=0, 249=25) */ - if (c_msb >= 224 && c_msb <= 249) + if (c_msb >= 224 && c_msb <= 249) { + if (af_set->announced_af != c_msb - 224) { + updated_af = true; + af_set->size = 0; + } af_set->announced_af = c_msb - 224; - /* check if the data represents an AF (for 1 =< val <= 204 the + } + /* check if the data represents an AF (for 1 <= val <= 204 the * value represents an AF) */ if (c_msb < 205) if (rds_add_af_to_list(af_set, c_msb, true)) -- 2.7.4