From a0e2b9398a06ca2ea164c2ffd6fd89f713b93598 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 3 Aug 2018 20:02:04 +0200 Subject: Add support for partial buffers in cache and rendering engine - fixes dropouts on framesize changes for example when looping. --- test/dgreftest/compareoutputengine.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'test/dgreftest/compareoutputengine.cc') 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 -- cgit v1.2.3