diff --git a/.clang-format b/.clang-format
index 62b427f8..8bae651a 100644
--- a/.clang-format
+++ b/.clang-format
@@ -10,6 +10,7 @@ IndentExternBlock: NoIndent
IndentWidth: '4'
NamespaceIndentation: Inner
+BinPackParameters: 'false'
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: 'true'
diff --git a/meson.build b/meson.build
index c1a6fa3a..2b7f4663 100644
--- a/meson.build
+++ b/meson.build
@@ -250,8 +250,8 @@ linux_platform_src = ['platform/targets/linux/emulator/emulator.c',
'platform/mcu/x86_64/drivers/delays.c',
'platform/mcu/x86_64/drivers/rtc.c',
'platform/drivers/baseband/radio_linux.cpp',
- 'platform/drivers/audio/audio_linux.c',
- 'platform/drivers/audio/inputStream_linux.c',
+ 'platform/drivers/audio/audio_linux.cpp',
+ 'platform/drivers/audio/inputStream_linux.cpp',
'platform/drivers/audio/outputStream_linux.c',
'platform/targets/linux/platform.c',
'platform/drivers/CPS/cps_io_libc.c']
@@ -670,8 +670,13 @@ cps_test = executable('cps_test',
sources : unit_test_src + ['tests/unit/cps.c'],
kwargs : unit_test_opts)
+linux_inputStream_test = executable('linux_inputStream_test',
+ sources : unit_test_src + ['tests/unit/linux_inputStream_test.cpp'],
+ kwargs : unit_test_opts)
+
test('M17 Golay Unit Test', m17_golay_test)
test('M17 Viterbi Unit Test', m17_viterbi_test)
test('M17 Demodulator Test', m17_demodulator_test)
test('M17 RRC Test', m17_rrc_test)
test('Codeplug Test', cps_test)
+test('Linux InputStream Test', linux_inputStream_test)
diff --git a/platform/drivers/audio/audio_linux.c b/platform/drivers/audio/audio_linux.cpp
similarity index 100%
rename from platform/drivers/audio/audio_linux.c
rename to platform/drivers/audio/audio_linux.cpp
diff --git a/platform/drivers/audio/inputStream_linux.c b/platform/drivers/audio/inputStream_linux.c
deleted file mode 100644
index c8f356c3..00000000
--- a/platform/drivers/audio/inputStream_linux.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2021 - 2022 by Federico Amedeo Izzo IU2NUO, *
- * Niccolò Izzo IU2KIN *
- * Frederik Saraci IU2NRO *
- * Silvano Seva IU2KWO *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 3 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, see *
- ***************************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-static stream_sample_t *buffer = NULL;
-static size_t bufferLength = 0;
-static bool first_half = true;
-static FILE *baseband_file = NULL;
-
-streamId inputStream_start(const enum AudioSource source,
- const enum AudioPriority prio,
- stream_sample_t * const buf,
- const size_t bufLength,
- const enum BufMode mode,
- const uint32_t sampleRate)
-{
- (void) source;
- (void) prio;
- (void) mode;
- (void) sampleRate;
-
- buffer = buf;
- bufferLength = bufLength;
-
- baseband_file = fopen("./tests/unit/assets/M17_test_baseband_dc.raw", "rb");
- if (!baseband_file)
- {
- perror("Error while reading file\n");
- }
-
- return -1;
-}
-
-dataBlock_t inputStream_getData(streamId id)
-{
- (void) id;
-
- dataBlock_t block;
-
- block.len = bufferLength / 2;
-
- if (first_half)
- {
- first_half = false;
- block.data = buffer;
- }
- else
- {
- first_half = true;
- block.data = buffer + (bufferLength / 2);
- }
-
- size_t read_items = fread(block.data, 2, block.len, baseband_file);
-
- if (read_items != block.len)
- {
- block.data = NULL;
- return block;
- }
-
- return block;
-}
-
-void inputStream_stop(streamId id)
-{
- (void) id;
- if(baseband_file == NULL) return;
- fclose(baseband_file);
- baseband_file = NULL;
-}
diff --git a/platform/drivers/audio/inputStream_linux.cpp b/platform/drivers/audio/inputStream_linux.cpp
new file mode 100644
index 00000000..96821db0
--- /dev/null
+++ b/platform/drivers/audio/inputStream_linux.cpp
@@ -0,0 +1,339 @@
+/***************************************************************************
+ * Copyright (C) 2022 by Alain Carlucci *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, see *
+ ***************************************************************************/
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include