From 9ba0159cccd8c3352fcb6a8cfe92e482936aff0c Mon Sep 17 00:00:00 2001 From: Hunter Date: Mon, 26 Feb 2024 00:04:06 -0800 Subject: [PATCH] All test passing, no-op source needed pump to declare source --- .../roc_sndio/sndfile_extension_table.h | 7 ++-- src/tests/roc_sndio/test_backend_sink.cpp | 23 +++++++++--- src/tests/roc_sndio/test_backend_source.cpp | 37 ++++++++++++++++--- 3 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/internal_modules/roc_sndio/target_sndfile/roc_sndio/sndfile_extension_table.h b/src/internal_modules/roc_sndio/target_sndfile/roc_sndio/sndfile_extension_table.h index d3c86ebc0..96baa7d55 100644 --- a/src/internal_modules/roc_sndio/target_sndfile/roc_sndio/sndfile_extension_table.h +++ b/src/internal_modules/roc_sndio/target_sndfile/roc_sndio/sndfile_extension_table.h @@ -11,9 +11,9 @@ #ifndef ROC_SNDIO_SNDFILE_EXTENSION_TABLE_H_ #define ROC_SNDIO_SNDFILE_EXTENSION_TABLE_H_ -#ifndef ROC_SNDIO_SNDFILE_EXTENSION_TABLE_H_ -#define ROC_SNDIO_SNDFILE_EXTENSION_TABLE_H_ - +#ifndef ROC_SNDIO_SNDFILE_FILEMAP_H_ +#define ROC_SNDIO_SNDFILE_FILEMAP_H_ +#pragma once #include "sndfile.h" //! Sndfile driver map. @@ -31,5 +31,4 @@ static FileMap file_type_map[5] = { { SF_FORMAT_MAT4, "mat4", NULL }, { SF_FORMAT_NIST, "nist", NULL }, { SF_FORMAT_WAVEX, "wavex", NULL } }; #endif // ROC_SNDIO_SNDFILE_FILEMAP_H_ - #endif // ROC_SNDIO_SNDFILE_EXTENSION_TABLE_H_ diff --git a/src/tests/roc_sndio/test_backend_sink.cpp b/src/tests/roc_sndio/test_backend_sink.cpp index 2211a7cf5..d0658d07b 100644 --- a/src/tests/roc_sndio/test_backend_sink.cpp +++ b/src/tests/roc_sndio/test_backend_sink.cpp @@ -12,12 +12,12 @@ #include "roc_core/scoped_ptr.h" #include "roc_core/temp_file.h" #include "roc_sndio/backend_map.h" -//#ifdef ROC_TARGERT_SNDFILE +#ifdef ROC_TARGERT_SNDFILE #include "roc_sndio/sndfile_sink.h" -//#endif // ROC_TARGET_SNDFILE -//#ifdef ROC_TARGET_SOX +#endif // ROC_TARGET_SNDFILE +#ifdef ROC_TARGET_SOX #include "roc_sndio/sox_sink.h" -//#endif // ROC_TARGET_SOX +#endif // ROC_TARGET_SOX namespace roc { namespace sndio { @@ -59,8 +59,19 @@ TEST_GROUP(backend_sink) { }; TEST(backend_sink, noop) { - SndfileSink sndfile_sink(arena, sink_config); - SoxSink sox_sink(arena, sink_config); + for (size_t n_backend = 0; n_backend < BackendMap::instance().num_backends(); + n_backend++) { + IBackend& backend = BackendMap::instance().nth_backend(n_backend); + if (!supports_wav(backend)) { + continue; + } + core::TempFile file("test.wav"); + IDevice* backend_device = backend.open_device( + DeviceType_Sink, DriverType_File, NULL, file.path(), sink_config, arena); + CHECK(backend_device != NULL); + core::ScopedPtr backend_sink(backend_device->to_sink(), arena); + CHECK(backend_sink != NULL); + } } TEST(backend_sink, error) { diff --git a/src/tests/roc_sndio/test_backend_source.cpp b/src/tests/roc_sndio/test_backend_source.cpp index 9742cdfdc..b86cc5bc0 100644 --- a/src/tests/roc_sndio/test_backend_source.cpp +++ b/src/tests/roc_sndio/test_backend_source.cpp @@ -17,14 +17,14 @@ #include "roc_core/temp_file.h" #include "roc_sndio/backend_map.h" #include "roc_sndio/pump.h" -//#ifdef ROC_TARGET_SNDFILE +#ifdef ROC_TARGET_SNDFILE #include "roc_sndio/sndfile_sink.h" #include "roc_sndio/sndfile_source.h" -//#endif // ROC_TARGET_SNDFILE -//#ifdef ROC_TARGET_SOX +#endif // ROC_TARGET_SNDFILE +#ifdef ROC_TARGET_SOX #include "roc_sndio/sox_sink.h" #include "roc_sndio/sox_source.h" -//#endif // ROC_TARGET_SOX +#endif // ROC_TARGET_SOX namespace roc { namespace sndio { @@ -83,8 +83,33 @@ TEST_GROUP(backend_source) { }; TEST(backend_source, noop) { - SndfileSource sndfile_source(arena, source_config); - SoxSource sox_source(arena, source_config); + for (size_t n_backend = 0; n_backend < BackendMap::instance().num_backends(); + n_backend++) { + core::TempFile file("test.wav"); + IBackend& backend = BackendMap::instance().nth_backend(n_backend); + + if (!supports_wav(backend)) { + continue; + } + { + test::MockSource mock_source; + IDevice* backend_device = backend.open_device( + DeviceType_Sink, DriverType_File, NULL, file.path(), sink_config, arena); + CHECK(backend_device != NULL); + core::ScopedPtr backend_sink(backend_device->to_sink(), arena); + CHECK(backend_sink != NULL); + + Pump pump(buffer_factory, mock_source, NULL, *backend_sink, FrameDuration, + SampleSpecs, Pump::ModeOneshot); + CHECK(pump.is_valid()); + CHECK(pump.run()); + } + IDevice* backend_device = backend.open_device( + DeviceType_Source, DriverType_File, NULL, file.path(), source_config, arena); + CHECK(backend_device != NULL); + core::ScopedPtr backend_source(backend_device->to_source(), arena); + CHECK(backend_source != NULL); + } } TEST(backend_source, error) {