From 0c7b7216efc71e9b3851f1b43f2191a99619ff25 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 1 May 2007 23:26:14 +0000 Subject: [PATCH] initial fixes to get build to work without new JACK MIDI, and to get it running with an older session, at least somewhat git-svn-id: svn://localhost/ardour2/branches/midi@1773 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/gain_meter.cc | 8 ++-- libs/ardour/ardour/audioengine.h | 5 ++- libs/ardour/audioengine.cc | 53 +++++++++++++---------- libs/ardour/audioregion.cc | 2 +- libs/ardour/meter.cc | 2 +- libs/ardour/midi_port.cc | 4 +- libs/ardour/midi_region.cc | 3 +- libs/ardour/panner.cc | 6 +-- libs/ardour/session.cc | 2 - libs/midi++2/jack_midiport.cc | 1 + libs/midi++2/midi++/jackcompat.h | 74 ++++++++++++++++++++++++++++++++ 11 files changed, 122 insertions(+), 38 deletions(-) create mode 100644 libs/midi++2/midi++/jackcompat.h diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 74e7c53a95..fa13234c46 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -138,12 +138,12 @@ GainMeter::GainMeter (boost::shared_ptr 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; diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 48a3426d53..0263f83230 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -46,6 +46,8 @@ class Port; class AudioEngine : public sigc::trackable { public: + typedef std::set 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 Ports; SerializedRCUManager ports; int process_callback (nframes_t nframes); diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index 0bfa18be72..273829fa75 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -304,26 +304,13 @@ AudioEngine::process_callback (nframes_t nframes) return 0; } - boost::shared_ptr 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 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); } } diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 68b77a1199..61ae3ca073 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -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; diff --git a/libs/ardour/meter.cc b/libs/ardour/meter.cc index 1812fbf053..d571a9006c 100644 --- a/libs/ardour/meter.cc +++ b/libs/ardour/meter.cc @@ -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) { diff --git a/libs/ardour/midi_port.cc b/libs/ardour/midi_port.cc index 8fbccf17f7..dc8b18a390 100644 --- a/libs/ardour/midi_port.cc +++ b/libs/ardour/midi_port.cc @@ -17,9 +17,11 @@ */ #include +#include + #include #include -#include +#include using namespace ARDOUR; using namespace std; diff --git a/libs/ardour/midi_region.cc b/libs/ardour/midi_region.cc index cc914cac38..47234d48d4 100644 --- a/libs/ardour/midi_region.cc +++ b/libs/ardour/midi_region.cc @@ -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; diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index e12857da93..cb4faec148 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -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); } } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 024820dd1f..8f02904fb1 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -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; } diff --git a/libs/midi++2/jack_midiport.cc b/libs/midi++2/jack_midiport.cc index 4b2808a698..3db96a214c 100644 --- a/libs/midi++2/jack_midiport.cc +++ b/libs/midi++2/jack_midiport.cc @@ -24,6 +24,7 @@ #include #include #include +#include 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 index 0000000000..f1b748ea66 --- /dev/null +++ b/libs/midi++2/midi++/jackcompat.h @@ -0,0 +1,74 @@ +/* JACK MIDI API compatibility hacks. + * Copyright (C) 2007 Nedko Arnaudov + * + * 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 */ -- 2.30.2