summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-06-13 16:26:19 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-06-13 16:26:19 +0200
commit1bc07f860fa7f01763586f45b7fb2e53cd1c2557 (patch)
treef11e1ffa18f57b5d12b479e99975a2bac9995075 /src
parentaa4528af0f813d604f62ce1b6e3a6ca92f127993 (diff)
Initialise the zita resampler correctly to avoid latency.
Diffstat (limited to 'src')
-rw-r--r--src/chresampler.cc20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/chresampler.cc b/src/chresampler.cc
index c3c19bf..94737c6 100644
--- a/src/chresampler.cc
+++ b/src/chresampler.cc
@@ -76,9 +76,20 @@ void CHResampler::setup(double input_fs, double output_fs)
DEBUG(resampler, "Using zita-resampler (%d -> %d)", (int)input_fs,
(int)output_fs);
- int hlen = 72; // 16 ≤ hlen ≤ 96
// delay is 2 * hlen, 72 corresponds to delay introduced by SRC.
+ int hlen = 72; // 16 ≤ hlen ≤ 96
+
+ prv->zita.reset();
prv->zita.setup(input_fs, output_fs, nchan, hlen);
+
+ std::size_t null_size = prv->zita.inpsize() / 2 - 1;
+ prv->zita.inp_data = nullptr;
+ prv->zita.inp_count = null_size;
+
+ prv->zita.out_data = nullptr;
+ prv->zita.out_count = 1024 * 1024;
+
+ prv->zita.process();
#elif defined(USE_SRC)
DEBUG(resampler, "Using libsamplerate (%d -> %d)", (int)input_fs,
(int)output_fs);
@@ -141,8 +152,13 @@ void CHResampler::process()
std::size_t CHResampler::getLatency() const
{
+ if (input_fs == output_fs)
+ {
+ return 0;
+ }
+
#if defined(USE_ZITA)
- return prv->zita.inpdist();
+ return 0;
#elif defined(USE_SRC)
return 0; // TODO?
#endif