- src_data.data_out = output;
-
- if (!src_data.end_of_input) {
- src_data.output_frames = nframes / source->channels();
- } else {
- src_data.output_frames = std::min ((framecnt_t) src_data.input_frames, nframes / source->channels());
+ _src_data.data_out = output;
+ _src_data.output_frames = nframes / source->channels();
+
+ if (_end_of_input && _src_data.input_frames * _src_data.src_ratio <= _src_data.output_frames) {
+ /* only set src_data.end_of_input for the last cycle.
+ *
+ * The flag only affects writing out remaining data in the
+ * internal buffer of src_state.
+ * SRC is not aware of data bufered here in _src_data.input
+ * which needs to be processed first.
+ */
+ _src_data.end_of_input = true;