From ca51307ada3bd0e33b84708b345f4f49c7d60899 Mon Sep 17 00:00:00 2001 From: 0xseantasker <0xseantasker@gmail.com> Date: Tue, 3 Sep 2024 21:48:04 +1000 Subject: [PATCH] - Added option to dump raw input to a file using `raw` configuration --- config/odaslive/azimut_oma.cfg | 2 +- config/odaslive/beam.cfg | 2 +- config/odaslive/delta1010lt.cfg | 2 +- config/odaslive/matrix_creator.cfg | 2 +- config/odaslive/matrix_voice.cfg | 2 +- config/odaslive/minidsp.cfg | 2 +- config/odaslive/pepper.cfg | 2 +- config/odaslive/pseye.cfg | 2 +- config/odaslive/respeaker.cfg | 2 +- config/odaslive/respeaker_4_mic_array.cfg | 2 +- config/odaslive/respeaker_6_mic_array.cfg | 2 +- config/odaslive/respeaker_usb_4_mic_array.cfg | 2 +- config/odaslive/xmos.cfg | 2 +- demo/odaslive/parameters.c | 13 ++++++++ include/odas/source/src_hops.h | 3 +- src/source/src_hops.c | 32 +++++++++++++++++++ 16 files changed, 60 insertions(+), 14 deletions(-) diff --git a/config/odaslive/azimut_oma.cfg b/config/odaslive/azimut_oma.cfg index 7044c9c1..a3bbdc33 100644 --- a/config/odaslive/azimut_oma.cfg +++ b/config/odaslive/azimut_oma.cfg @@ -17,7 +17,7 @@ raw: type = "file"; path = "input_oma.raw"; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/beam.cfg b/config/odaslive/beam.cfg index af93715a..ad008549 100644 --- a/config/odaslive/beam.cfg +++ b/config/odaslive/beam.cfg @@ -17,7 +17,7 @@ raw: type = "file"; path = "micsBeam.raw"; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/delta1010lt.cfg b/config/odaslive/delta1010lt.cfg index 2886eaff..085acbe0 100644 --- a/config/odaslive/delta1010lt.cfg +++ b/config/odaslive/delta1010lt.cfg @@ -69,7 +69,7 @@ raw: type = "soundcard_name"; devicename = "multi_capture"; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/matrix_creator.cfg b/config/odaslive/matrix_creator.cfg index 65ed718a..97fe0de7 100644 --- a/config/odaslive/matrix_creator.cfg +++ b/config/odaslive/matrix_creator.cfg @@ -18,7 +18,7 @@ raw: card = 2; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/matrix_voice.cfg b/config/odaslive/matrix_voice.cfg index 90b0c79f..4d9a9d84 100644 --- a/config/odaslive/matrix_voice.cfg +++ b/config/odaslive/matrix_voice.cfg @@ -18,7 +18,7 @@ raw: card = 2; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/minidsp.cfg b/config/odaslive/minidsp.cfg index d47d321f..1b078a48 100644 --- a/config/odaslive/minidsp.cfg +++ b/config/odaslive/minidsp.cfg @@ -18,7 +18,7 @@ raw: card = 2; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/pepper.cfg b/config/odaslive/pepper.cfg index f24e1004..2a60b8d8 100644 --- a/config/odaslive/pepper.cfg +++ b/config/odaslive/pepper.cfg @@ -17,7 +17,7 @@ raw: type = "soundcard_name"; devicename = "AD1989A_inputs"; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/pseye.cfg b/config/odaslive/pseye.cfg index 03ae31c9..57699fce 100644 --- a/config/odaslive/pseye.cfg +++ b/config/odaslive/pseye.cfg @@ -18,7 +18,7 @@ raw: card = 2; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/respeaker.cfg b/config/odaslive/respeaker.cfg index 69d6d0d7..e57f7487 100644 --- a/config/odaslive/respeaker.cfg +++ b/config/odaslive/respeaker.cfg @@ -18,7 +18,7 @@ raw: card = 3; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/respeaker_4_mic_array.cfg b/config/odaslive/respeaker_4_mic_array.cfg index 07625cdc..e1ced691 100644 --- a/config/odaslive/respeaker_4_mic_array.cfg +++ b/config/odaslive/respeaker_4_mic_array.cfg @@ -18,7 +18,7 @@ raw: card = 1; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/respeaker_6_mic_array.cfg b/config/odaslive/respeaker_6_mic_array.cfg index 39468afc..0261363c 100644 --- a/config/odaslive/respeaker_6_mic_array.cfg +++ b/config/odaslive/respeaker_6_mic_array.cfg @@ -19,7 +19,7 @@ raw: card = 1; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/respeaker_usb_4_mic_array.cfg b/config/odaslive/respeaker_usb_4_mic_array.cfg index 0d4c07e7..7ac24911 100644 --- a/config/odaslive/respeaker_usb_4_mic_array.cfg +++ b/config/odaslive/respeaker_usb_4_mic_array.cfg @@ -18,7 +18,7 @@ raw: card = 1; device = 0; } - + output_dump_file = ""; } # Mapping diff --git a/config/odaslive/xmos.cfg b/config/odaslive/xmos.cfg index c92efae2..04b4c3fd 100644 --- a/config/odaslive/xmos.cfg +++ b/config/odaslive/xmos.cfg @@ -17,7 +17,7 @@ raw: type = "file"; path = "meeting_recorded_raw_16.raw"; } - + output_dump_file = ""; } # Mapping diff --git a/demo/odaslive/parameters.c b/demo/odaslive/parameters.c index 365d04d9..5a2958e0 100644 --- a/demo/odaslive/parameters.c +++ b/demo/odaslive/parameters.c @@ -223,6 +223,19 @@ exit(EXIT_FAILURE); } + // +----------------------------------------------------------+ + // | Debug dump | + // +----------------------------------------------------------+ + + tmpStr1 = parameters_lookup_string(fileConfig, "raw.output_dump_file"); + + if (strcmp(tmpStr1, "") != 0) { + + cfg->output_dump_filename = (char *) malloc(sizeof(char) * (strlen(tmpStr1)+1)); + strcpy(cfg->output_dump_filename, tmpStr1); + } + + free((void *) tmpStr1); return cfg; diff --git a/include/odas/source/src_hops.h b/include/odas/source/src_hops.h index 9e41ca9a..e2bd0b75 100644 --- a/include/odas/source/src_hops.h +++ b/include/odas/source/src_hops.h @@ -57,6 +57,7 @@ typedef struct src_hops_obj { interface_obj *interface; FILE * fp; + FILE * output_dump_file; snd_pcm_t * ch; pa_simple * pa; pa_sample_spec ss; @@ -78,7 +79,7 @@ typedef struct src_hops_cfg { format_obj * format; interface_obj * interface; pa_channel_map * channel_map; - + char* output_dump_filename; } src_hops_cfg; src_hops_obj * src_hops_construct(const src_hops_cfg * src_hops_config, const msg_hops_cfg * msg_hops_config); diff --git a/src/source/src_hops.c b/src/source/src_hops.c index 99e6e5d2..717b631e 100644 --- a/src/source/src_hops.c +++ b/src/source/src_hops.c @@ -43,6 +43,18 @@ src_hops_obj * src_hops_construct(const src_hops_cfg * src_hops_config, const ms obj->format = format_clone(src_hops_config->format); obj->interface = interface_clone(src_hops_config->interface); + if (src_hops_config->output_dump_filename!=NULL) + { + obj->output_dump_file = fopen(src_hops_config->output_dump_filename, "wb"); + + if (obj->output_dump_file == NULL) { + printf("Cannot open raw dump file %s\n", src_hops_config->output_dump_filename); + exit(EXIT_FAILURE); + } + }else + { + obj->output_dump_file = NULL; + } if (src_hops_config->channel_map != NULL) { // Will not be null if in pulseaudio mode @@ -99,6 +111,11 @@ void src_hops_destroy(src_hops_obj * obj) { free((void *) obj->buffer); format_destroy(obj->format); interface_destroy(obj->interface); + + if (obj->output_dump_file != NULL) + { + fclose(obj->output_dump_file); + } free((void *) obj); } @@ -354,6 +371,11 @@ void src_hops_close(src_hops_obj * obj) { break; } + if (obj->output_dump_file) + { + fclose(obj->output_dump_file); + obj->output_dump_file = NULL; + } } void src_hops_close_interface_file(src_hops_obj * obj) { @@ -456,6 +478,11 @@ int src_hops_process(src_hops_obj * obj) { obj->timeStamp++; obj->out->timeStamp = obj->timeStamp; + if(obj->output_dump_file != NULL) + { + fwrite(obj->buffer, sizeof(char), obj->bufferSize, obj->output_dump_file); + } + return rtnValue; } @@ -659,6 +686,7 @@ src_hops_cfg * src_hops_cfg_construct(void) { cfg->format = (format_obj *) NULL; cfg->interface = (interface_obj *) NULL; + cfg->output_dump_filename = NULL; return cfg; } @@ -676,6 +704,10 @@ void src_hops_cfg_destroy(src_hops_cfg * src_hops_config) { free((void *) src_hops_config->channel_map); } + if (src_hops_config->output_dump_filename != NULL) { + free((void *) src_hops_config->output_dump_filename); + } + free((void *) src_hops_config); }