Skip to content

Commit

Permalink
All test passing, no-op source needed pump to declare source
Browse files Browse the repository at this point in the history
  • Loading branch information
Hrick87 committed Feb 26, 2024
1 parent 5aada82 commit 9ba0159
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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_
23 changes: 17 additions & 6 deletions src/tests/roc_sndio/test_backend_sink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<ISink> backend_sink(backend_device->to_sink(), arena);
CHECK(backend_sink != NULL);
}
}

TEST(backend_sink, error) {
Expand Down
37 changes: 31 additions & 6 deletions src/tests/roc_sndio/test_backend_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<ISink> 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<ISource> backend_source(backend_device->to_source(), arena);
CHECK(backend_source != NULL);
}
}

TEST(backend_source, error) {
Expand Down

0 comments on commit 9ba0159

Please sign in to comment.