From 30c08ba655330232767554c48bda1975bfb5628c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 Aug 2006 03:24:57 +0000 Subject: - Changed IO's vector's to PortList - Added new Port classes, code to drive them - Added PortList, which is a filthy mess ATM (nevermind that, it's the interface that's important at this stage) - Added ChanCount, though it isn't very thoroughly used yet. That's the next step.... - Fixed a few bugs relating to loading sessions saved with trunk - Fixed a few random other bugs Slowly working towards type agnosticism while keeping all the former code/logic intact is the name of the game here Warning: Removing ports is currently (intentionally) broken due solely to laziness. git-svn-id: svn://localhost/ardour2/branches/midi@786 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/midi_playlist.cc | 62 ++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 45 deletions(-) (limited to 'libs/ardour/midi_playlist.cc') diff --git a/libs/ardour/midi_playlist.cc b/libs/ardour/midi_playlist.cc index 007856e3a7..db28c06f17 100644 --- a/libs/ardour/midi_playlist.cc +++ b/libs/ardour/midi_playlist.cc @@ -164,71 +164,43 @@ struct RegionSortByLayer } }; +/** FIXME: semantics of return value? */ jack_nframes_t -MidiPlaylist::read (unsigned char *buf, unsigned char *mixdown_buffer, char * workbuf, jack_nframes_t start, +MidiPlaylist::read (RawMidi *buf, RawMidi *mixdown_buffer, jack_nframes_t start, jack_nframes_t cnt, unsigned chan_n) { - jack_nframes_t ret = cnt; - jack_nframes_t end; - jack_nframes_t read_frames; - jack_nframes_t skip_frames; - - /* optimizing this memset() away involves a lot of conditionals - that may well cause more of a hit due to cache misses - and related stuff than just doing this here. - - it would be great if someone could measure this - at some point. - - one way or another, parts of the requested area - that are not written to by Region::region_at() - for all Regions that cover the area need to be - zeroed. - */ - - memset (buf, 0, sizeof (unsigned char) * cnt); - /* this function is never called from a realtime thread, so its OK to block (for short intervals). */ Glib::Mutex::Lock rm (region_lock); - end = start + cnt - 1; + jack_nframes_t ret = 0; + jack_nframes_t end = start + cnt - 1; + jack_nframes_t read_frames = 0; + jack_nframes_t skip_frames = 0; - read_frames = 0; - skip_frames = 0; _read_data_count = 0; - map > relevant_regions; - vector relevant_layers; + vector regs; // relevent regions overlapping start <--> end for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) { - if ((*i)->coverage (start, end) != OverlapNone) { - - relevant_regions[(*i)->layer()].push_back (*i); - relevant_layers.push_back ((*i)->layer()); + MidiRegion* const mr = dynamic_cast(*i); + if (mr && mr->coverage (start, end) != OverlapNone) { + regs.push_back(mr); } } - // RegionSortByLayer layer_cmp; - // relevant_regions.sort (layer_cmp); - - - for (vector::iterator l = relevant_layers.begin(); l != relevant_layers.end(); ++l) { - - // FIXME: Should be vector - vector& r (relevant_regions[*l]); - - for (vector::iterator i = r.begin(); i != r.end(); ++i) { - MidiRegion* const mr = dynamic_cast(*i); - assert(mr); - mr->read_at (buf, mixdown_buffer, workbuf, start, cnt, chan_n, read_frames, skip_frames); - _read_data_count += mr->read_data_count(); - } + RegionSortByLayer layer_cmp; + sort(regs.begin(), regs.end(), layer_cmp); + for (vector::iterator i = regs.begin(); i != regs.end(); ++i) { + (*i)->read_at (buf, mixdown_buffer, start, cnt, chan_n, read_frames, skip_frames); + ret += (*i)->read_data_count(); } + _read_data_count += ret; + return ret; } -- cgit v1.2.3