Move _port_offset up to AudioPort, as MidiPort does not use it.
authorCarl Hetherington <carl@carlh.net>
Fri, 13 Aug 2010 02:13:12 +0000 (02:13 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 13 Aug 2010 02:13:12 +0000 (02:13 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7614 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audio_port.h
libs/ardour/ardour/port.h
libs/ardour/audio_port.cc
libs/ardour/audioengine.cc
libs/ardour/midi_port.cc
libs/ardour/port.cc
libs/ardour/session_process.cc

index 0c08795819099b3000b2f17a061167357f83a277..895cae99a645384e44d47290ad8a685713a8df75 100644 (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
index 3a677d293f3cb85af1a633fb425c130e43f713e4..8b2b3dcbd3f873f1fc923ae92e23e347242f6196 100644 (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;
         
index 71ec7c6289f201160d75c49d708761ea52a42279..c7e920dfb69663068c07ef4010cb4944330396de 100644 (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))
index 3453deea5c700db8ab027651c05e823b0bfd5223..301b3e3ce23e944ab6a6113fa0056430fe8c3d22 100644 (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 */
index 807fd5ba0dc9bf1e8404901e1356e909135a77cb..1e5cecfb10a12184488d4871797a2493a2d3ea0a 100644 (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+_port_offset));
+                       assert (ev.time() < (nframes + 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;
                         }
                }
        }
index 8bf08a7dff3d25105fdf6786f788372f9dbffb24..efdd297f5e9bd531f5efa84e28a88f132d6048fc 100644 (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;
 
index 6889e714fda67bdd69dfd303dbf901b7f0c3d32f..596f656fbc870dd2679fe7024f755c35c5f4cc21 100644 (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) {