forked from roc-streaming/roc-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Passes all unit tests, moved test_pump/test_helpers, moved extension …
…detector to sndfile_sink
- Loading branch information
Showing
8 changed files
with
606 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2015 Roc Streaming authors | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#include <CppUTest/TestHarness.h> | ||
|
||
#include "roc_core/heap_arena.h" | ||
#include "roc_core/temp_file.h" | ||
#include "roc_sndio/sndfile_sink.h" | ||
|
||
namespace roc { | ||
namespace sndio { | ||
|
||
namespace { | ||
|
||
enum { FrameSize = 500, SampleRate = 44100, ChMask = 0x3 }; | ||
|
||
core::HeapArena arena; | ||
|
||
} // namespace | ||
|
||
TEST_GROUP(sndfile_sink) { | ||
Config sink_config; | ||
|
||
void setup() { | ||
sink_config.sample_spec = audio::SampleSpec( | ||
SampleRate, audio::ChanLayout_Surround, audio::ChanOrder_Smpte, ChMask); | ||
|
||
sink_config.frame_length = FrameSize * core::Second | ||
/ core::nanoseconds_t(sink_config.sample_spec.sample_rate() | ||
* sink_config.sample_spec.num_channels()); | ||
} | ||
}; | ||
|
||
TEST(sndfile_sink, noop) { | ||
SndfileSink sndfile_sink(arena, sink_config); | ||
} | ||
|
||
TEST(sndfile_sink, error) { | ||
|
||
SndfileSink sndfile_sink(arena, sink_config); | ||
|
||
CHECK(!sndfile_sink.open(NULL, "/bad/file")); | ||
} | ||
|
||
TEST(sndfile_sink, has_clock) { | ||
|
||
SndfileSink sndfile_sink(arena, sink_config); | ||
|
||
core::TempFile file("test.wav"); | ||
CHECK(sndfile_sink.open(NULL, file.path())); | ||
CHECK(!sndfile_sink.has_clock()); | ||
} | ||
|
||
TEST(sndfile_sink, sample_rate_auto) { | ||
|
||
sink_config.sample_spec.set_sample_rate(0); | ||
SndfileSink sndfile_sink(arena, sink_config); | ||
|
||
core::TempFile file("test.wav"); | ||
CHECK(sndfile_sink.open(NULL, file.path())); | ||
CHECK(sndfile_sink.sample_spec().sample_rate() != 0); | ||
} | ||
|
||
TEST(sndfile_sink, sample_rate_force) { | ||
|
||
sink_config.sample_spec.set_sample_rate(SampleRate); | ||
SndfileSink sndfile_sink(arena, sink_config); | ||
|
||
core::TempFile file("test.wav"); | ||
CHECK(sndfile_sink.open(NULL, file.path())); | ||
CHECK(sndfile_sink.sample_spec().sample_rate() == SampleRate); | ||
} | ||
|
||
} // namespace sndio | ||
} // namespace roc |
Oops, something went wrong.