aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-03-13 13:45:05 (GMT)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-03-13 13:45:05 (GMT)
commitf71fde5156ec8d08f863b3c3d21f9634d042966a (patch)
tree8a81f789dca3c70bdfbacca823f72dddd39f367b
parent5621909288fafdb74b65180c9c0f615d594d4e0b (diff)
v4l2-info.cpp: fix bufferflags2s: could end with ', '
If after clearing the timestamp-related flags the value was 0, then the string would end with ", ". That is ugly, so rework the code. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/common/v4l2-info.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/utils/common/v4l2-info.cpp b/utils/common/v4l2-info.cpp
index c49e23c..212c1a0 100644
--- a/utils/common/v4l2-info.cpp
+++ b/utils/common/v4l2-info.cpp
@@ -686,33 +686,38 @@ static const flag_def buffer_flags_def[] = {
std::string bufferflags2s(__u32 flags)
{
- std::string s;
+ const unsigned ts_mask = V4L2_BUF_FLAG_TIMESTAMP_MASK | V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ std::string s = flags2s(flags & ~ts_mask, buffer_flags_def);
+
+ if (s.length())
+ s += ", ";
switch (flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) {
case V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN:
- s = "ts-unknown, ";
- flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
+ s += "ts-unknown";
break;
case V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC:
- s = "ts-monotonic, ";
- flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
+ s += "ts-monotonic";
break;
case V4L2_BUF_FLAG_TIMESTAMP_COPY:
- s = "ts-copy, ";
- flags &= ~V4L2_BUF_FLAG_TIMESTAMP_MASK;
+ s += "ts-copy";
+ break;
+ default:
+ s += "ts-invalid";
break;
}
switch (flags & V4L2_BUF_FLAG_TSTAMP_SRC_MASK) {
case V4L2_BUF_FLAG_TSTAMP_SRC_EOF:
- s += "ts-src-eof, ";
- flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ s += ", ts-src-eof";
break;
case V4L2_BUF_FLAG_TSTAMP_SRC_SOE:
- s += "ts-src-soe, ";
- flags &= ~V4L2_BUF_FLAG_TSTAMP_SRC_MASK;
+ s += ", ts-src-soe";
+ break;
+ default:
+ s += ", ts-src-invalid";
break;
}
- return s + flags2s(flags, buffer_flags_def);
+ return s;
}
static const flag_def vbi_def[] = {

Privacy Policy