Move _port_offset up to AudioPort, as MidiPort does not use it.

git-svn-id: svn://localhost/ardour2/branches/3.0@7614 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington
2010-08-13 02:13:12 +00:00
parent 8502e50377
commit 3364fda3de
7 changed files with 23 additions and 27 deletions

View File

@@ -47,6 +47,16 @@ class AudioPort : public Port
AudioBuffer& get_audio_buffer (nframes_t nframes, nframes_t offset = 0);
static nframes_t port_offset() { return _port_offset; }
static void set_port_offset (nframes_t off) {
_port_offset = off;
}
static void increment_port_offset (nframes_t n) {
_port_offset += n;
}
protected:
friend class AudioEngine;
@@ -55,6 +65,7 @@ class AudioPort : public Port
private:
AudioBuffer* _buffer;
static nframes_t _port_offset;
};
} // namespace ARDOUR

View File

@@ -45,14 +45,6 @@ public:
virtual ~Port ();
static nframes_t port_offset() { return _port_offset; }
static void set_port_offset (nframes_t off) {
_port_offset = off;
}
static void increment_port_offset (nframes_t n) {
_port_offset += n;
}
static void set_buffer_size (nframes_t sz) {
_buffer_size = sz;
}
@@ -63,7 +55,6 @@ public:
return _connecting_blocked;
}
/** @return Port short name */
std::string name () const {
return _name;
@@ -135,7 +126,6 @@ protected:
jack_port_t* _jack_port; ///< JACK port
static nframes_t _port_offset;
static nframes_t _buffer_size;
static bool _connecting_blocked;

View File

@@ -25,6 +25,8 @@
using namespace ARDOUR;
using namespace std;
nframes_t AudioPort::_port_offset = 0;
AudioPort::AudioPort (const std::string& name, Flags flags)
: Port (name, DataType::AUDIO, flags)
, _buffer (new AudioBuffer (0))

View File

@@ -401,7 +401,7 @@ AudioEngine::split_cycle (nframes_t offset)
{
/* caller must hold process lock */
Port::increment_port_offset (offset);
AudioPort::increment_port_offset (offset);
/* tell all Ports that we're going to start a new (split) cycle */
@@ -484,7 +484,7 @@ AudioEngine::process_callback (nframes_t nframes)
/* tell all relevant objects that we're starting a new cycle */
Delivery::CycleStart (nframes);
Port::set_port_offset (0);
AudioPort::set_port_offset (0);
InternalReturn::CycleStart (nframes);
/* tell all Ports that we're starting a new cycle */

View File

@@ -67,8 +67,6 @@ MidiPort::get_midi_buffer (nframes_t nframes, nframes_t offset)
into our MidiBuffer
*/
nframes_t off = offset + _port_offset;
for (nframes_t i = 0; i < event_count; ++i) {
jack_midi_event_t ev;
@@ -80,10 +78,10 @@ MidiPort::get_midi_buffer (nframes_t nframes, nframes_t offset)
continue;
}
if (ev.time >= off && ev.time < off+nframes) {
if (ev.time > offset && ev.time < (offset + nframes)) {
_buffer->push_back (ev);
} else {
cerr << "Dropping incoming MIDI at time " << ev.time << "; offset=" << off << " limit=" << (off + nframes) << "\n";
cerr << "Dropping incoming MIDI at time " << ev.time << "; offset=" << offset << " limit=" << (offset + nframes) << "\n";
}
}
@@ -139,18 +137,14 @@ MidiPort::flush_buffers (nframes_t nframes, nframes64_t time, nframes_t offset)
// event times are in frames, relative to cycle start
// XXX split cycle start or cycle start?
assert (ev.time() < (nframes + offset));
assert(ev.time() < (nframes+offset+_port_offset));
if (ev.time() >= offset + _port_offset) {
if (ev.time() >= offset) {
if (jack_midi_event_write (jack_buffer, (jack_nframes_t) ev.time(), ev.buffer(), ev.size()) != 0) {
cerr << "write failed, drop flushed note off on the floor, time " << ev.time() << " > " << offset << " + " << _port_offset
<< endl;
cerr << "write failed, drop flushed note off on the floor, time " << ev.time() << " > " << offset << endl;
}
} else {
cerr << "drop flushed note off on the floor, time " << ev.time() << " > " << offset << " + " << _port_offset
<< endl;
cerr << "drop flushed event on the floor, time " << ev.time() << " < " << offset << endl;
}
}
}

View File

@@ -34,7 +34,6 @@ using namespace std;
using namespace ARDOUR;
AudioEngine* Port::_engine = 0;
nframes_t Port::_port_offset = 0;
nframes_t Port::_buffer_size = 0;
bool Port::_connecting_blocked = false;

View File

@@ -37,7 +37,7 @@
#include "ardour/slave.h"
#include "ardour/timestamps.h"
#include "ardour/graph.h"
#include "ardour/port.h"
#include "ardour/audio_port.h"
#include "midi++/manager.h"
#include "midi++/mmc.h"
@@ -884,7 +884,7 @@ Session::maybe_sync_start (nframes_t& nframes)
no_roll (sync_offset);
nframes -= sync_offset;
Port::increment_port_offset (sync_offset);
AudioPort::increment_port_offset (sync_offset);
waiting_for_sync_offset = false;
if (nframes == 0) {