optimization for track with zero audio channels should not short-circuit MIDI disk...
[ardour.git] / libs / ardour / audio_port.cc
index 6a86360b6937522333d77d84daa0fe5c3f0322cb..70943e35a308ef47a475372cb08b86d4fad821ef 100644 (file)
@@ -56,14 +56,14 @@ AudioPort::cycle_start (pframes_t nframes)
 }
 
 void
-AudioPort::cycle_end (pframes_t)
+AudioPort::cycle_end (pframes_t nframes)
 {
-        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.
-                */
-               if (_buffer->capacity () > 0) {
-                       _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);
                }
        }
 }
@@ -77,15 +77,17 @@ AudioBuffer&
 AudioPort::get_audio_buffer (pframes_t nframes)
 {
        /* caller must hold process lock */
+       assert (_port_handle);
        _buffer->set_data ((Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes) +
                           _global_port_buffer_offset + _port_buffer_offset, nframes);
        return *_buffer;
 }
 
-Sample* 
+Sample*
 AudioPort::engine_get_whole_audio_buffer ()
 {
        /* caller must hold process lock */
+       assert (_port_handle);
        return (Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes);
 }