From fe6314e11c88b53567bebb725b7de930bbab6aea Mon Sep 17 00:00:00 2001 From: FrancoisGrondin Date: Thu, 26 Oct 2017 12:19:52 -0400 Subject: [PATCH] Bugs fixed in sources and sinks. --- config/azimut_oma.cfg | 6 +++--- demo/parameters.c | 13 +++++++++---- src/general/format.c | 12 ++++++++++++ src/general/format.h | 2 ++ src/sink/snk_hops.c | 6 ++++++ src/sink/snk_pots.c | 13 +++++++++++++ src/sink/snk_pots.h | 2 ++ src/sink/snk_tracks.c | 13 +++++++++++++ src/sink/snk_tracks.h | 2 ++ src/source/src_hops.c | 41 ++++++++++++++++++++++++++++++++++++++--- 10 files changed, 100 insertions(+), 10 deletions(-) diff --git a/config/azimut_oma.cfg b/config/azimut_oma.cfg index a3cfa71..431272e 100644 --- a/config/azimut_oma.cfg +++ b/config/azimut_oma.cfg @@ -235,7 +235,7 @@ ssl: # Output to export potential sources potential: { - format = "json"; + format = "undefined"; interface: { type = "blackhole"; @@ -305,7 +305,7 @@ sst: # Output to export tracked sources tracked: { - format = "json"; + format = "undefined"; interface: { type = "blackhole"; @@ -382,7 +382,7 @@ classify: category: { - format = "json"; + format = "undefined"; interface: { type = "blackhole"; diff --git a/demo/parameters.c b/demo/parameters.c index b50e9c2..44cd487 100644 --- a/demo/parameters.c +++ b/demo/parameters.c @@ -166,7 +166,7 @@ } // +----------------------------------------------------------+ - // | Type | + // | Interface | // +----------------------------------------------------------+ tmpStr1 = parameters_lookup_string(fileConfig, "raw.interface.type"); @@ -689,12 +689,13 @@ if (strcmp(tmpStr1, "json") == 0) { cfg->format = format_construct_text_json(); } else if (strcmp(tmpStr1, "binary") == 0) { cfg->format = format_construct_binary_float(); } + else if (strcmp(tmpStr1, "undefined") == 0) { cfg->format = format_construct_undefined(); } else { printf("ssl.potential.format: Invalid format\n"); exit(EXIT_FAILURE); } free((void *) tmpStr1); // +----------------------------------------------------------+ - // | Type | + // | Interface | // +----------------------------------------------------------+ tmpStr1 = parameters_lookup_string(fileConfig, "ssl.potential.interface.type"); @@ -963,12 +964,13 @@ if (strcmp(tmpStr1, "json") == 0) { cfg->format = format_construct_text_json(); } else if (strcmp(tmpStr1, "binary") == 0) { cfg->format = format_construct_binary_float(); } + else if (strcmp(tmpStr1, "undefined") == 0) { cfg->format = format_construct_undefined(); } else { printf("sst.tracked.format: Invalid format\n"); exit(EXIT_FAILURE); } free((void *) tmpStr1); // +----------------------------------------------------------+ - // | Type | + // | Interface | // +----------------------------------------------------------+ tmpStr1 = parameters_lookup_string(fileConfig, "sst.tracked.interface.type"); @@ -1450,7 +1452,7 @@ } // +----------------------------------------------------------+ - // | Type | + // | Interface | // +----------------------------------------------------------+ tmpStr1 = parameters_lookup_string(fileConfig, "sss.separated.interface.type"); @@ -1458,6 +1460,7 @@ if (strcmp(tmpStr1, "blackhole") == 0) { cfg->interface = interface_construct_blackhole(); + cfg->format = format_construct_undefined(); } else if (strcmp(tmpStr1, "file") == 0) { @@ -1532,6 +1535,7 @@ if (strcmp(tmpStr1, "blackhole") == 0) { cfg->interface = interface_construct_blackhole(); + cfg->format = format_construct_undefined(); } else if (strcmp(tmpStr1, "file") == 0) { @@ -1676,6 +1680,7 @@ tmpStr1 = parameters_lookup_string(fileConfig, "classify.category.format"); if (strcmp(tmpStr1, "json") == 0) { cfg->format = format_construct_text_json(); } + else if (strcmp(tmpStr1, "undefined") == 0) { cfg->format = format_construct_undefined(); } else { printf("classify.category.format: Invalid format\n"); exit(EXIT_FAILURE); } free((void *) tmpStr1); diff --git a/src/general/format.c b/src/general/format.c index 2d14f7d..f2cab0c 100644 --- a/src/general/format.c +++ b/src/general/format.c @@ -13,6 +13,18 @@ } + format_obj * format_construct_undefined() { + + format_obj * obj; + + obj = (format_obj *) malloc(sizeof(format_obj)); + + obj->type = format_undefined; + + return obj; + + } + format_obj * format_construct_binary_int(const unsigned int nBits) { format_obj * obj; diff --git a/src/general/format.h b/src/general/format.h index e337944..95c3769 100644 --- a/src/general/format.h +++ b/src/general/format.h @@ -24,6 +24,8 @@ format_obj * format_construct(); + format_obj * format_construct_undefined(); + format_obj * format_construct_binary_int(const unsigned int nBits); format_obj * format_construct_binary_float(); diff --git a/src/sink/snk_hops.c b/src/sink/snk_hops.c index 190174d..b54b31d 100644 --- a/src/sink/snk_hops.c +++ b/src/sink/snk_hops.c @@ -211,6 +211,12 @@ break; + case format_undefined: + + snk_hops_process_format_undefined(obj); + + break; + default: printf("Sink hops: Invalid format type.\n"); diff --git a/src/sink/snk_pots.c b/src/sink/snk_pots.c index f6d91b4..b6b9885 100644 --- a/src/sink/snk_pots.c +++ b/src/sink/snk_pots.c @@ -218,6 +218,12 @@ break; + case format_undefined: + + snk_pots_process_format_undefined(obj); + + break; + default: printf("Sink pots: Invalid format type.\n"); @@ -341,6 +347,13 @@ } + void snk_pots_process_format_undefined(snk_pots_obj * obj) { + + obj->buffer[0] = 0x00; + obj->bufferSize = 0; + + } + snk_pots_cfg * snk_pots_cfg_construct(void) { snk_pots_cfg * cfg; diff --git a/src/sink/snk_pots.h b/src/sink/snk_pots.h index 64e09ed..a26bfdc 100644 --- a/src/sink/snk_pots.h +++ b/src/sink/snk_pots.h @@ -85,6 +85,8 @@ void snk_pots_process_format_text_json(snk_pots_obj * obj); + void snk_pots_process_format_undefined(snk_pots_obj * obj); + snk_pots_cfg * snk_pots_cfg_construct(void); void snk_pots_cfg_destroy(snk_pots_cfg * snk_pots_config); diff --git a/src/sink/snk_tracks.c b/src/sink/snk_tracks.c index ee0a3f8..fc3d840 100644 --- a/src/sink/snk_tracks.c +++ b/src/sink/snk_tracks.c @@ -211,6 +211,12 @@ break; + case format_undefined: + + snk_tracks_process_format_undefined(obj); + + break; + default: printf("Sink tracks: Invalid format type.\n"); @@ -331,6 +337,13 @@ } + void snk_tracks_process_format_undefined(snk_tracks_obj * obj) { + + obj->buffer[0] = 0x00; + obj->bufferSize = 0; + + } + snk_tracks_cfg * snk_tracks_cfg_construct(void) { snk_tracks_cfg * cfg; diff --git a/src/sink/snk_tracks.h b/src/sink/snk_tracks.h index 841b0a4..705b010 100644 --- a/src/sink/snk_tracks.h +++ b/src/sink/snk_tracks.h @@ -83,6 +83,8 @@ void snk_tracks_process_format_text_json(snk_tracks_obj * obj); + void snk_tracks_process_format_undefined(snk_tracks_obj * obj); + snk_tracks_cfg * snk_tracks_cfg_construct(void); void snk_tracks_cfg_destroy(snk_tracks_cfg * snk_tracks_config); diff --git a/src/source/src_hops.c b/src/source/src_hops.c index 687cf5a..4d9cc2c 100644 --- a/src/source/src_hops.c +++ b/src/source/src_hops.c @@ -245,6 +245,41 @@ int rtnValue; + switch(obj->format->type) { + + case format_binary_int08: + + src_hops_process_format_binary_int08(obj); + + break; + + case format_binary_int16: + + src_hops_process_format_binary_int16(obj); + + break; + + case format_binary_int24: + + src_hops_process_format_binary_int24(obj); + + break; + + case format_binary_int32: + + src_hops_process_format_binary_int32(obj); + + break; + + default: + + printf("Source hops: Invalid format type.\n"); + exit(EXIT_FAILURE); + + break; + + } + switch(obj->interface->type) { case interface_file: @@ -277,12 +312,12 @@ int src_hops_process_interface_file(src_hops_obj * obj) { - unsigned int nSamples; + unsigned int nBytesTotal; int rtnValue; - nSamples = fread(obj->buffer, sizeof(char), obj->bufferSize, obj->fp); + nBytesTotal = fread(obj->buffer, sizeof(char), obj->bufferSize, obj->fp); - if (nSamples == (obj->nChannels * obj->hopSize)) { + if (nBytesTotal == obj->bufferSize) { rtnValue = 0; -- 2.34.1