From e08548a343c63e42a980077604ac4b55bafe6a42 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Mon, 7 Sep 2015 10:17:02 +0200 Subject: [PATCH] labcomm2014_decode_one now sets the LABCOMM2014_IS_SAMPLE (highest non-sign bit) when a sample is returned. --- lib/c/2014/labcomm2014.h | 4 ++++ lib/c/2014/labcomm2014_decoder.c | 2 +- lib/c/2014/test/test_labcomm.c | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/c/2014/labcomm2014.h b/lib/c/2014/labcomm2014.h index 5931e83..ca490cc 100644 --- a/lib/c/2014/labcomm2014.h +++ b/lib/c/2014/labcomm2014.h @@ -30,11 +30,15 @@ #else #include <stdint.h> #include <unistd.h> + #include <limits.h> #endif #include "labcomm2014_error.h" #include "labcomm2014_scheduler.h" +/* Bits set in result of labcomm_decode_one */ +#define LABCOMM2014_IS_SAMPLE (INT_MAX - (INT_MAX>>1)) + /* Forward declaration */ struct labcomm2014_encoder; struct labcomm2014_decoder; diff --git a/lib/c/2014/labcomm2014_decoder.c b/lib/c/2014/labcomm2014_decoder.c index b38de40..e270afc 100644 --- a/lib/c/2014/labcomm2014_decoder.c +++ b/lib/c/2014/labcomm2014_decoder.c @@ -387,7 +387,7 @@ static int do_decode_one(struct labcomm2014_decoder *d) DECODER_DEBUG_FPRINTF(stderr, "SKIP %d %d\n", remote_index, length); result = decoder_skip(d, length, remote_index); } else { - result = decode_and_handle(d, d, remote_index); + result = decode_and_handle(d, d, remote_index) | LABCOMM2014_IS_SAMPLE; } out: return result; diff --git a/lib/c/2014/test/test_labcomm.c b/lib/c/2014/test/test_labcomm.c index 81cc07b..9f093f2 100644 --- a/lib/c/2014/test/test_labcomm.c +++ b/lib/c/2014/test/test_labcomm.c @@ -229,6 +229,11 @@ static void test_encode_decode(struct labcomm2014_encoder *encoder, writer.pos, expected); exit(1); } + if ((err & LABCOMM2014_IS_SAMPLE) == 0) { + fprintf(stderr, "Expected %x set in %x\n", + LABCOMM2014_IS_SAMPLE, err); + exit(1); + } } static int do_test(int argc, char *argv[]) -- GitLab