-AudioBuffer &
-AudioPort::get_audio_buffer( nframes_t nframes, nframes_t offset ) {
-
- if (_has_been_mixed_down)
- return *_buffer;
-
- if (_flags & IsInput) {
-
- if (_ext_port) {
- _buffer->read_from (dynamic_cast<BaseAudioPort*>(_ext_port)->get_audio_buffer (nframes, offset), nframes, offset);
-
- if (!_connections.empty()) {
- (*_mixdown) (_connections, _buffer, nframes, offset, false);
- }
-
- } else {
-
- if (_connections.empty()) {
- _buffer->silence (nframes, offset);
- } else {
- (*_mixdown) (_connections, _buffer, nframes, offset, true);
- }
- }
-
- } else {
-
- // XXX if we could get the output stage to not purely mix into, but also
- // to initially overwrite the buffer, we could avoid this silence step.
- if (_ext_port) {
- _buffer = & (dynamic_cast<BaseAudioPort*>(_ext_port)->get_audio_buffer( nframes, offset ));
- }
- if (nframes)
- _buffer->silence (nframes, offset);
+ /* Get a pointer to the audio data @ offset + _port_offset within the JACK port buffer and store
+ it in our _buffer member.
+
+ Note that offset is expected to be zero in almost all cases.
+ */
+
+ _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset + _port_offset, nframes);