- if (sends_output() && !_buffer->written()) {
- /* we can't use nframes here because the current buffer capacity may
- be shorter than the full buffer size if we split the cycle.
- */
- _buffer->silence (_buffer->capacity());
+ if (sends_output() && !_buffer->written() && _port_handle) {
+ if (!_buffer->data (0)) {
+ get_audio_buffer (nframes);
+ }
+ if (_buffer->capacity() >= nframes) {
+ _buffer->silence (nframes);
+ }
+ }
+
+ if (sends_output() && _port_handle) {
+
+ if (!externally_connected ()) {
+ /* ardour internal port, data goes nowhere, skip resampling */
+ // TODO reset resampler only once
+ _src.reset ();
+ return;
+ }
+
+ _src.inp_count = _cycle_nframes;
+ _src.out_count = nframes;
+ _src.set_rratio (nframes / (double)_cycle_nframes);
+ _src.inp_data = _data;
+ _src.out_data = (float*)port_engine.get_buffer (_port_handle, nframes);
+ _src.process ();
+ while (_src.out_count > 0) {
+ *_src.out_data = _src.out_data[-1];
+ ++_src.out_data;
+ --_src.out_count;
+ }