From: Deborah Brouwer <deborahbrouwer3563@gmail.com>
To: linux-media@vger.kernel.org
Cc: hverkuil@xs4all.nl, Deborah Brouwer <deborahbrouwer3563@gmail.com>
Subject: [PATCH v3 2/2] cec-follower: detect the cessation of Audio Rate Control messages
Date: Mon, 26 Apr 2021 20:29:48 -0700 [thread overview]
Message-ID: <0d36c30492c0136ea3b00985d91aa4ff1bef4b91.1619492378.git.deborahbrouwer3563@gmail.com> (raw)
In-Reply-To: <cover.1619492378.git.deborahbrouwer3563@gmail.com>
In-Reply-To: <cover.1619492378.git.deborahbrouwer3563@gmail.com>
If the controlling device simply stops sending audio rate messages, give
the cec-follower the ability to detect that it has not received an audio
rate message within 2 seconds as required. The cec-follower will quit the
audio rate controlled mode. Eliminate the need to measure an interval
between two audio rate messages.
Signed-off-by: Deborah Brouwer <deborahbrouwer3563@gmail.com>
---
utils/cec-follower/cec-processing.cpp | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp
index fcb55df2..c76ec54e 100644
--- a/utils/cec-follower/cec-processing.cpp
+++ b/utils/cec-follower/cec-processing.cpp
@@ -233,18 +233,21 @@ static __u8 current_power_state(struct node *node)
return CEC_OP_POWER_STATUS_TO_STANDBY;
}
-static void aud_rate_msg_interval_check(__u64 ts_new, __u64 ts_old)
+static void aud_rate_msg_interval_check(struct node *node, __u64 ts_new)
{
/*
- * The interval between messages is not relevant if this is the
- * first audio rate control message or if the previous message
- * turned off the audio rate control.
+ * The interval since the last audio rate message is only relevant
+ * if the Source is currently in audio rate controlled mode
+ * (i.e. state.last_aud_rate_rx_ts != 0).
*/
+ __u64 ts_old = node->state.last_aud_rate_rx_ts;
+
if (ts_old) {
__u64 interval = ts_new - ts_old;
+
if (interval > MAX_AUD_RATE_MSG_INTERVAL_NS) {
- warn("The interval between Audio Rate Control messages was greater\n");
- warn("than the Maxiumum Audio Rate Message Interval (2s).\n");
+ warn("The interval since the last Audio Rate Control message was > 2s.\n");
+ node->state.last_aud_rate_rx_ts = 0;
}
}
}
@@ -802,7 +805,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me)
switch (msg.msg[2]) {
case CEC_OP_AUD_RATE_OFF:
- aud_rate_msg_interval_check(msg.rx_ts, node->state.last_aud_rate_rx_ts);
+ aud_rate_msg_interval_check(node, msg.rx_ts);
node->state.last_aud_rate_rx_ts = 0;
return;
case CEC_OP_AUD_RATE_WIDE_STD:
@@ -811,7 +814,7 @@ static void processMsg(struct node *node, struct cec_msg &msg, unsigned me)
case CEC_OP_AUD_RATE_NARROW_STD:
case CEC_OP_AUD_RATE_NARROW_FAST:
case CEC_OP_AUD_RATE_NARROW_SLOW:
- aud_rate_msg_interval_check(msg.rx_ts, node->state.last_aud_rate_rx_ts);
+ aud_rate_msg_interval_check(node, msg.rx_ts);
node->state.last_aud_rate_rx_ts = msg.rx_ts;
return;
default:
@@ -1033,6 +1036,9 @@ void testProcessing(struct node *node, bool wallclock)
node->state.rc_state = NOPRESS;
}
}
+
+ if (node->has_aud_rate)
+ aud_rate_msg_interval_check(node, ts_now);
}
mode = CEC_MODE_INITIATOR;
doioctl(node, CEC_S_MODE, &mode);
--
2.17.1
prev parent reply other threads:[~2021-04-27 3:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 3:29 [PATCH v3 0/2] cec-follower: increase accuracy Audio Rate Control Deborah Brouwer
2021-04-27 3:29 ` [PATCH v3 1/2] cec-follower: increase precision of Audio Rate Control active sensing Deborah Brouwer
2021-04-27 3:29 ` Deborah Brouwer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0d36c30492c0136ea3b00985d91aa4ff1bef4b91.1619492378.git.deborahbrouwer3563@gmail.com \
--to=deborahbrouwer3563@gmail.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).