diff options
| author | Carl Hetherington <cth@carlh.net> | 2017-05-21 19:48:14 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2017-05-21 19:48:14 +0100 |
| commit | fa4d2529d63bcfa7cf7c516b7227e20a1b6dec7e (patch) | |
| tree | 1ac1107370c7384fbce6cc67ee3e3aa6475f807e /src/lib/resampler.cc | |
| parent | 5bcbd6821a6ff1419f9069cf9e1a94c8557a992c (diff) | |
Do resampling in AudioDecoder rather than Player.
This fixes the problem where the decoder's position would not take
into account that all samples pushed into the resampler do not
always immediately come out. This would result in Player thinking
that there would be gaps when there are not.
Diffstat (limited to 'src/lib/resampler.cc')
| -rw-r--r-- | src/lib/resampler.cc | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/lib/resampler.cc b/src/lib/resampler.cc index e991591c2..553180f08 100644 --- a/src/lib/resampler.cc +++ b/src/lib/resampler.cc @@ -67,19 +67,9 @@ Resampler::set_fast () } } -pair<shared_ptr<const AudioBuffers>, Frame> -Resampler::run (shared_ptr<const AudioBuffers> in, Frame frame) +shared_ptr<const AudioBuffers> +Resampler::run (shared_ptr<const AudioBuffers> in) { - if (!_next_in || !_next_out || _next_in.get() != frame) { - /* Either there was a discontinuity in the input or this is the first input; - reset _next_out. - */ - _next_out = lrintf (frame * _out_rate / _in_rate); - } - - /* Expected next input frame */ - _next_in = frame + in->frames (); - int in_frames = in->frames (); int in_offset = 0; int out_offset = 0; @@ -154,15 +144,10 @@ Resampler::run (shared_ptr<const AudioBuffers> in, Frame frame) delete[] data.data_out; } - Frame out_frame = _next_out.get (); - - /* Expected next output frame */ - _next_out = _next_out.get() + resampled->frames(); - - return make_pair (resampled, out_frame); + return resampled; } -pair<shared_ptr<const AudioBuffers>, Frame> +shared_ptr<const AudioBuffers> Resampler::flush () { shared_ptr<AudioBuffers> out (new AudioBuffers (_channels, 0)); @@ -200,7 +185,7 @@ Resampler::flush () out->set_frames (out_offset); delete[] buffer; - return make_pair (out, _next_out.get ()); + return out; } void |
