initial fixes to get build to work without new JACK MIDI, and to get it running with...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 1 May 2007 23:26:14 +0000 (23:26 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 1 May 2007 23:26:14 +0000 (23:26 +0000)
git-svn-id: svn://localhost/ardour2/branches/midi@1773 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/gain_meter.cc
libs/ardour/ardour/audioengine.h
libs/ardour/audioengine.cc
libs/ardour/audioregion.cc
libs/ardour/meter.cc
libs/ardour/midi_port.cc
libs/ardour/midi_region.cc
libs/ardour/panner.cc
libs/ardour/session.cc
libs/midi++2/jack_midiport.cc
libs/midi++2/midi++/jackcompat.h [new file with mode: 0644]

index 74e7c53a95548d755d8fe783f8e166ebda260c63..fa13234c467a9ad627d54e743611e608aeb333a1 100644 (file)
@@ -138,12 +138,12 @@ GainMeter::GainMeter (boost::shared_ptr<IO> io, Session& s)
        fader_vbox->pack_start (*fader_centering_box, false, false, 0);
 
        hbox.set_spacing (2);
-       hbox.pack_start (*fader_vbox, true, true);
 
-       if (_io->default_type() == ARDOUR::DataType::AUDIO)
-               hbox.pack_start (*fader_vbox, false, false, 2);
+       if (_io->default_type() == ARDOUR::DataType::AUDIO) {
+               hbox.pack_start (*fader_vbox, true, true);
+       }
        
-       set_width(Narrow);
+       set_width (Narrow);
 
        Route* r;
 
index 48a3426d53d9858ab0d03a7ec5f292c9ac8cfd53..0263f83230edea8f3fa9f13ab3e471771b489f02 100644 (file)
@@ -46,6 +46,8 @@ class Port;
 class AudioEngine : public sigc::trackable
 {
    public:
+       typedef std::set<Port*> Ports;
+
        AudioEngine (std::string client_name);
        virtual ~AudioEngine ();
        
@@ -66,6 +68,8 @@ class AudioEngine : public sigc::trackable
        int start ();
        bool running() const { return _running; }
 
+       int run_process_cycle (ARDOUR::Session*, jack_nframes_t nframes);
+
        Glib::Mutex& process_lock() { return _process_lock; }
 
        nframes_t frame_rate();
@@ -211,7 +215,6 @@ class AudioEngine : public sigc::trackable
        bool                  reconnect_on_halt;
        int                  _usecs_per_cycle;
 
-       typedef std::set<Port*> Ports;
        SerializedRCUManager<Ports> ports;
 
        int    process_callback (nframes_t nframes);
index 0bfa18be72fc03319dceb0b806e105096bef1b87..273829fa7565d6cf56d95dc2c6071ee55bfce878 100644 (file)
@@ -304,26 +304,13 @@ AudioEngine::process_callback (nframes_t nframes)
                return 0;
        }
 
-       boost::shared_ptr<Ports> p = ports.reader();
-
-       // Prepare ports (ie read data if necessary)
-       for (Ports::iterator i = p->begin(); i != p->end(); ++i)
-               (*i)->cycle_start(nframes);
-       
-       session->process (nframes);
-
-       if (!_running) {
+       if (run_process_cycle (session, nframes)) {
                /* we were zombified, maybe because a ladspa plugin took
                   too long, or jackd exited, or something like that.
                */
-               
                _processed_frames = next_processed_frames;
                return 0;
        }
-       
-       // Finalize ports (ie write data if necessary)
-       for (Ports::iterator i = p->begin(); i != p->end(); ++i)
-               (*i)->cycle_end();
 
        if (last_monitor_check + monitor_check_interval < next_processed_frames) {
 
@@ -349,6 +336,28 @@ AudioEngine::process_callback (nframes_t nframes)
        return 0;
 }
 
+int
+AudioEngine::run_process_cycle (Session* s, jack_nframes_t nframes)
+{
+       boost::shared_ptr<Ports> p = ports.reader();
+
+       // Prepare ports (ie read data if necessary)
+       for (Ports::iterator i = p->begin(); i != p->end(); ++i)
+               (*i)->cycle_start (nframes);
+       
+       s->process (nframes);
+
+       if (!_running) {
+               return -1;
+       }
+       
+       // Finalize ports (ie write data if necessary)
+       for (Ports::iterator i = p->begin(); i != p->end(); ++i)
+               (*i)->cycle_end ();
+
+       return 0;
+}
+
 int
 AudioEngine::_sample_rate_callback (nframes_t nframes, void *arg)
 {
@@ -447,14 +456,14 @@ AudioEngine::set_session (Session *s)
                   can before we really start running.
                */
                
-               session->process (blocksize);
-               session->process (blocksize);
-               session->process (blocksize);
-               session->process (blocksize);
-               session->process (blocksize);
-               session->process (blocksize);
-               session->process (blocksize);
-               session->process (blocksize);
+               run_process_cycle (session, blocksize);
+               run_process_cycle (session, blocksize);
+               run_process_cycle (session, blocksize);
+               run_process_cycle (session, blocksize);
+               run_process_cycle (session, blocksize);
+               run_process_cycle (session, blocksize);
+               run_process_cycle (session, blocksize);
+               run_process_cycle (session, blocksize);
        }
 }
 
index 68b77a1199185327e7a1455d9661ea8d210c1d4b..61ae3ca0736cbce4dbec97828c0ba51d4f50360e 100644 (file)
@@ -326,7 +326,7 @@ AudioRegion::_read_at (const SourceList& srcs, Sample *buf, Sample *mixdown_buff
                       nframes_t position, nframes_t cnt, 
                       uint32_t chan_n, nframes_t read_frames, nframes_t skip_frames) const
 {
-       cerr << _name << "._read_at(" << position << ") - " << _position << endl;
+       // cerr << _name << "._read_at(" << position << ") - " << _position << endl;
 
        nframes_t internal_offset;
        nframes_t buf_offset;
index 1812fbf05365f2637a4abed0cc1890e129903a91..d571a9006c748a7c918f64b53acadac98ae2847e 100644 (file)
@@ -72,7 +72,7 @@ PeakMeter::setup (const ChanCount& in)
        while (_peak_power.size() > limit) {
                _peak_power.pop_back();
                _visible_peak_power.pop_back();
-               _max_peak_power.push_back(minus_infinity());
+               _max_peak_power.pop_back();
        }
 
        while (_peak_power.size() < limit) {
index 8fbccf17f7a39d65103fe79a6b92c3c3657cc8d0..dc8b18a39085e24a5f4d424c4ec544f6de7d03ba 100644 (file)
 */
 
 #include <cassert>
+#include <iostream>
+
 #include <ardour/midi_port.h>
 #include <ardour/data_type.h>
-#include <iostream>
+#include <midi++/jackcompat.h>
 
 using namespace ARDOUR;
 using namespace std;
index cc914cac3867e10d2e67e10939d793ddcfa26785..47234d48d4cea4f5ad6b6a8e499d4d7d90793df2 100644 (file)
@@ -128,8 +128,7 @@ MidiRegion::_read_at (const SourceList& srcs, MidiRingBuffer& dst,
                       jack_nframes_t position, jack_nframes_t dur, 
                       uint32_t chan_n, jack_nframes_t read_frames, jack_nframes_t skip_frames) const
 {
-
-       cerr << _name << "._read_at(" << position << ") - " << _position << endl;
+       // cerr << _name << "._read_at(" << position << ") - " << _position << endl;
 
        jack_nframes_t internal_offset = 0;
        jack_nframes_t src_offset      = 0;
index e12857da93d643daad3bda85c46a3d753e79a183..cb4faec148e07a28120b32eeb579be5914175b50 100644 (file)
@@ -1386,9 +1386,6 @@ Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes
 
                return;
        }
-
-       // More than 1 output, we should have 1 panner for each input
-       assert(size() == inbufs.count().get(DataType::AUDIO));
        
        /* the terrible silence ... */
        for (BufferSet::audio_iterator i = outbufs.audio_begin(); i != outbufs.audio_end(); ++i) {
@@ -1396,7 +1393,8 @@ Panner::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, nframes
        }
 
        BufferSet::audio_iterator i = inbufs.audio_begin();
-       for (iterator pan = begin(); pan != end(); ++pan, ++i) {
+
+       for (iterator pan = begin(); pan != end() && i != inbufs.audio_end(); ++pan, ++i) {
                (*pan)->distribute (*i, outbufs, gain_coeff, nframes);
        }
 }
index 024820dd1f29019a4f1d4a15d89c5a3e86d02c2d..8f02904fb1f985764113a942cd3cc2474946d914 100644 (file)
@@ -534,9 +534,7 @@ Session::destroy ()
                tmp = i;
                ++tmp;
 
-               cerr << "dropping refs on a region (" << i->second->name() << " @ " << i->second << ") with UC = " << i->second.use_count() << endl;
                i->second->drop_references ();
-               cerr << "AFTER: UC = " << i->second.use_count() << endl;
 
                i = tmp;
        }
index 4b2808a6986a431cff0f2940d22d2406b653d85c..3db96a214cf602ba4f13d99af35ab9cbe34bfbb7 100644 (file)
@@ -24,6 +24,7 @@
 #include <midi++/types.h>
 #include <midi++/jack.h>
 #include <midi++/port_request.h>
+#include <midi++/jackcompat.h>
 
 using namespace std;
 using namespace MIDI;
diff --git a/libs/midi++2/midi++/jackcompat.h b/libs/midi++2/midi++/jackcompat.h
new file mode 100644 (file)
index 0000000..f1b748e
--- /dev/null
@@ -0,0 +1,74 @@
+/* JACK MIDI API compatibility hacks.
+ * Copyright (C) 2007 Nedko Arnaudov <nedko@arnaudov.name>
+ *
+ * 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
+ * the Free Software Foundation; version 2 of the License
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef JACK_COMPAT_H
+#define JACK_COMPAT_H
+
+#define JACK_MIDI_NEEDS_NFRAMES
+
+#if defined(JACK_MIDI_NEEDS_NFRAMES)
+
+static jack_nframes_t
+jack_midi_get_event_count_compat(
+  void * port_buffer)
+{
+#if defined(HAVE_OLD_JACK_MIDI)
+  return jack_midi_port_get_info(port_buffer, 0)->event_count;
+#else
+  return jack_midi_get_event_count(port_buffer, 0);
+#endif
+}
+
+#define jack_midi_get_event_count jack_midi_get_event_count_compat
+
+static int
+jack_midi_event_get_compat(
+  jack_midi_event_t * event,
+  void * port_buffer,
+  jack_nframes_t event_index)
+{
+  return jack_midi_event_get(event, port_buffer, event_index, 0);
+}
+
+static int
+jack_midi_event_write_compat(void                   *port_buffer,
+                            jack_nframes_t          time,
+                            const jack_midi_data_t *data,
+                            size_t                  data_size)
+{
+       return jack_midi_event_write (port_buffer, time, data, data_size, 0);
+}
+
+static void 
+jack_midi_clear_buffer_compat(void* buf)
+{
+       jack_midi_clear_buffer (buf, 0);
+}
+
+#define jack_midi_event_get jack_midi_event_get_compat
+#define jack_midi_event_write jack_midi_event_write_compat
+#define jack_midi_clear_buffer jack_midi_clear_buffer_compat
+
+#else
+
+#if defined(HAVE_OLD_JACK_MIDI)
+#error "Old (0.102.20) JACK MIDI API needs nframes (autotools probably gone mad)"
+#endif
+
+#endif  /* #if defined(JACK_MIDI_NEEDS_NFRAMES) */
+
+#endif /* JACK_COMPAT_H */