From 665f3bea5a7b145636b6d85bb3623013e38f1819 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 7 Mar 2011 19:06:42 +0000 Subject: fix all manner of wrongness with port buffer offsets git-svn-id: svn://localhost/ardour2/branches/3.0@9098 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/audio_buffer.h | 6 +++++- libs/ardour/ardour/audio_port.h | 18 +++--------------- libs/ardour/ardour/buffer_set.h | 2 +- libs/ardour/ardour/midi_port.h | 8 ++++---- libs/ardour/ardour/port.h | 19 +++++++++++++++---- 5 files changed, 28 insertions(+), 25 deletions(-) (limited to 'libs/ardour/ardour') diff --git a/libs/ardour/ardour/audio_buffer.h b/libs/ardour/ardour/audio_buffer.h index 403a70232f..63eb7d7c20 100644 --- a/libs/ardour/ardour/audio_buffer.h +++ b/libs/ardour/ardour/audio_buffer.h @@ -49,6 +49,9 @@ public: assert(src.type() == DataType::AUDIO); assert(len <= _capacity); memcpy(_data + dst_offset, ((AudioBuffer&)src).data() + src_offset, sizeof(Sample) * len); + if (next_write_addr >= _data + _capacity) { + next_write_addr = _data; + } if (dst_offset == 0 && src_offset == 0 && len == _capacity) { _silent = src.silent(); } else { @@ -169,11 +172,12 @@ public: void prepare () { _written = false; } bool written() const { return _written; } + void set_marked_for_write (bool yn) { mfw = yn; } + private: bool _owns_data; bool _written; Sample* _data; ///< Actual buffer contents - }; diff --git a/libs/ardour/ardour/audio_port.h b/libs/ardour/ardour/audio_port.h index 748ef8263b..ffd1f8d9b0 100644 --- a/libs/ardour/ardour/audio_port.h +++ b/libs/ardour/ardour/audio_port.h @@ -41,22 +41,12 @@ class AudioPort : public Port size_t raw_buffer_size (pframes_t nframes) const; - Buffer& get_buffer (framecnt_t nframes, framecnt_t offset = 0) { - return get_audio_buffer (nframes, offset); + Buffer& get_buffer (framecnt_t nframes) { + return get_audio_buffer (nframes); } - AudioBuffer& get_audio_buffer (framecnt_t nframes, framecnt_t offset = 0); + AudioBuffer& get_audio_buffer (framecnt_t nframes); - static framecnt_t port_offset() { return _port_offset; } - - static void set_port_offset (framecnt_t off) { - _port_offset = off; - } - - static void increment_port_offset (framecnt_t n) { - _port_offset += n; - } - protected: friend class AudioEngine; @@ -64,8 +54,6 @@ class AudioPort : public Port private: AudioBuffer* _buffer; - - static framecnt_t _port_offset; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/buffer_set.h b/libs/ardour/ardour/buffer_set.h index f5ac1aee61..9ba44e9481 100644 --- a/libs/ardour/ardour/buffer_set.h +++ b/libs/ardour/ardour/buffer_set.h @@ -67,7 +67,7 @@ public: void clear(); void attach_buffers (PortSet& ports); - void get_jack_port_addresses (PortSet &, framecnt_t, framecnt_t); + void get_jack_port_addresses (PortSet &, framecnt_t); /* the capacity here is a size_t and has a different interpretation depending on the DataType of the buffers. for audio, its a frame count. for MIDI diff --git a/libs/ardour/ardour/midi_port.h b/libs/ardour/ardour/midi_port.h index 7a019e5a20..b7c80e0c01 100644 --- a/libs/ardour/ardour/midi_port.h +++ b/libs/ardour/ardour/midi_port.h @@ -41,16 +41,16 @@ class MidiPort : public Port { void cycle_end (pframes_t nframes); void cycle_split (); - void flush_buffers (pframes_t nframes, framepos_t time, framecnt_t offset = 0); + void flush_buffers (pframes_t nframes, framepos_t time); void transport_stopped (); size_t raw_buffer_size (pframes_t nframes) const; - Buffer& get_buffer (framecnt_t nframes, framecnt_t offset = 0) { - return get_midi_buffer (nframes, offset); + Buffer& get_buffer (framecnt_t nframes) { + return get_midi_buffer (nframes); } - MidiBuffer& get_midi_buffer (framecnt_t nframes, framecnt_t offset = 0); + MidiBuffer& get_midi_buffer (framecnt_t nframes); protected: friend class AudioEngine; diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index 3a45d010c7..300ecc24af 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -113,10 +113,8 @@ public: virtual void cycle_start (pframes_t) = 0; virtual void cycle_end (pframes_t) = 0; virtual void cycle_split () = 0; - virtual Buffer& get_buffer (framecnt_t nframes, framecnt_t offset = 0) = 0; - virtual void flush_buffers (pframes_t nframes, framepos_t /*time*/, framecnt_t offset = 0) { - assert (offset < nframes); - } + virtual Buffer& get_buffer (framecnt_t nframes) = 0; + virtual void flush_buffers (pframes_t nframes, framepos_t /*time*/) {} virtual void transport_stopped () {} bool physically_connected () const; @@ -125,6 +123,17 @@ public: PBD::Signal1 MonitorInputChanged; + + static framecnt_t port_offset() { return _port_offset; } + + static void set_port_offset (framecnt_t off) { + _port_offset = off; + } + + static void increment_port_offset (framecnt_t n) { + _port_offset += n; + } + protected: Port (std::string const &, DataType, Flags); @@ -133,6 +142,7 @@ protected: static pframes_t _buffer_size; static bool _connecting_blocked; + static framecnt_t _port_offset; static AudioEngine* _engine; ///< the AudioEngine @@ -150,6 +160,7 @@ private: /** ports that we are connected to, kept so that we can reconnect to JACK when required */ std::set _connections; + }; } -- cgit v1.2.3