/*
- Copyright (C) 2006 Paul Davis
+ Copyright (C) 2006 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
#include <cassert>
-#include <ardour/audio_port.h>
-#include <ardour/audioengine.h>
-#include <ardour/data_type.h>
-#include <ardour/audio_buffer.h>
+
+#include "pbd/stacktrace.h"
+
+#include "ardour/audio_buffer.h"
+#include "ardour/audioengine.h"
+#include "ardour/audio_port.h"
+#include "ardour/data_type.h"
+#include "ardour/port_engine.h"
using namespace ARDOUR;
using namespace std;
-AudioPort::AudioPort (const std::string& name, Flags flags)
+#define port_engine AudioEngine::instance()->port_engine()
+
+AudioPort::AudioPort (const std::string& name, PortFlags flags)
: Port (name, DataType::AUDIO, flags)
- , _buffer_data_set (false)
, _buffer (new AudioBuffer (0))
{
assert (name.find_first_of (':') == string::npos);
}
void
-AudioPort::cycle_start (nframes_t nframes, nframes_t offset)
+AudioPort::cycle_start (pframes_t nframes)
{
/* caller must hold process lock */
- /* get_buffer() must only be run on outputs here in cycle_start().
+ Port::cycle_start (nframes);
- Inputs must be done in the correct processing order, which
- requires interleaving with route processing. that will
- happen when Port::get_buffer() is called.
- */
-
- if (sends_output() && !_buffer_data_set) {
-
- _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes);
- _buffer_data_set = true;
-
+ if (sends_output()) {
+ _buffer->prepare ();
}
+}
- if (receives_input()) {
- _buffer_data_set = false;
- } else {
- _buffer->silence (nframes, offset);
+void
+AudioPort::cycle_end (pframes_t nframes)
+{
+ if (sends_output() && !_buffer->written()) {
+ if (_buffer->capacity() >= nframes) {
+ _buffer->silence (nframes);
+ }
}
}
-AudioBuffer &
-AudioPort::get_audio_buffer (nframes_t nframes, nframes_t offset)
+void
+AudioPort::cycle_split ()
{
- /* caller must hold process lock */
-
- if (receives_input () && !_buffer_data_set) {
+}
- _buffer->set_data ((Sample *) jack_port_get_buffer (_jack_port, nframes) + offset, nframes);
-
- }
-
+AudioBuffer&
+AudioPort::get_audio_buffer (pframes_t nframes)
+{
+ /* caller must hold process lock */
+ _buffer->set_data ((Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes) +
+ _global_port_buffer_offset + _port_buffer_offset, nframes);
return *_buffer;
}
-void
-AudioPort::cycle_end (nframes_t nframes, nframes_t offset)
+Sample*
+AudioPort::engine_get_whole_audio_buffer ()
{
- _buffer_data_set = false;
+ /* caller must hold process lock */
+ return (Sample *) port_engine.get_buffer (_port_handle, _cycle_nframes);
}
+
+
+
+