summaryrefslogtreecommitdiff
path: root/test/dgreftest/compareoutputengine.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2018-08-03 20:02:04 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2018-08-05 16:19:57 +0200
commita0e2b9398a06ca2ea164c2ffd6fd89f713b93598 (patch)
treef070de47673f32903eae30ddbc57232e2b13db4e /test/dgreftest/compareoutputengine.cc
parentea743668192e0921ab46d5e863df5b754ce82656 (diff)
Add support for partial buffers in cache and rendering engine - fixes dropouts on framesize changes for example when looping.
Diffstat (limited to 'test/dgreftest/compareoutputengine.cc')
-rw-r--r--test/dgreftest/compareoutputengine.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/test/dgreftest/compareoutputengine.cc b/test/dgreftest/compareoutputengine.cc
index 33dfe2a..04145b0 100644
--- a/test/dgreftest/compareoutputengine.cc
+++ b/test/dgreftest/compareoutputengine.cc
@@ -33,6 +33,7 @@ CompareOutputEngine::CompareOutputEngine()
, info{}
, file{"output"}
{
+ info = {};
info.samplerate = 44100;
info.channels = 1;
info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
@@ -44,9 +45,9 @@ CompareOutputEngine::~CompareOutputEngine()
sf_close(handle);
}
-bool CompareOutputEngine::init(const Channels& data)
+bool CompareOutputEngine::init(const Channels& channels)
{
- info.channels = data.size();
+ info.channels = channels.size();
handle = sf_open(file.c_str(), SFM_READ, &info);
if(handle == nullptr)
@@ -116,8 +117,11 @@ void CompareOutputEngine::run(int ch, sample_t* samples, size_t nsamples)
void CompareOutputEngine::post(size_t nsamples)
{
- sample_t ref_buffer[sizeof(buffer) / sizeof(sample_t)];
- sf_readf_float(handle, ref_buffer, nsamples);
+ nsamples = sf_readf_float(handle, ref_buffer, nsamples);
+ if(nsamples == 0)
+ {
+ return;
+ }
for(std::size_t i = 0; i < nsamples; ++i)
{
@@ -126,10 +130,17 @@ void CompareOutputEngine::post(size_t nsamples)
if(buffer[i * info.channels + ch] != ref_buffer[i * info.channels + ch])
{
++diff_samples;
+
+ // Use this to quit on first bad sample.
+ //std::cerr << "ch: " << ch << ", pos: " << pos + i <<
+ // " expected: " << ref_buffer[i * info.channels + ch] <<
+ // " got: " << buffer[i * info.channels + ch] << std::endl;
+ //exit(1);
+
}
}
}
-
+ pos += nsamples;
}
size_t CompareOutputEngine::getSamplerate() const