* Quick Fix: assertion converted into warning in MidiModel::write_to
authorHans Baier <hansfbaier@googlemail.com>
Mon, 12 May 2008 11:42:41 +0000 (11:42 +0000)
committerHans Baier <hansfbaier@googlemail.com>
Mon, 12 May 2008 11:42:41 +0000 (11:42 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@3337 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/midi_model.cc
libs/ardour/smf_source.cc

index 168516fcc45de2a197f848e8bf88b7bf97f44b48..a85d00f49e2df75ff0e3335b565423807927c63e 100644 (file)
@@ -879,8 +879,8 @@ XMLNode& MidiModel::DeltaCommand::get_state()
 
 struct EventTimeComparator {
        typedef const MIDI::Event* value_type;
-       inline bool operator()(const MIDI::Event* a, const MIDI::Event* b) const {
-               return a->time() >= b->time();
+       inline bool operator()(const MIDI::Event& a, const MIDI::Event& b) const {
+               return a.time() >= b.time();
        }
 };
 
@@ -893,14 +893,34 @@ struct EventTimeComparator {
  */
 bool MidiModel::write_to(boost::shared_ptr<MidiSource> source)
 {
+       /*
+       EventTimeComparator comp;
+       typedef std::priority_queue<
+                               const MIDI::Event*, 
+                               std::deque<MIDI::Event>,
+                               EventTimeComparator> MidiEvents;
+       
+       MidiEvents events(comp);
+       */
+       
        read_lock();
 
        const NoteMode old_note_mode = _note_mode;
        _note_mode = Sustained;
        
        for (const_iterator i = begin(); i != end(); ++i) {
+               //events.push(*i);
                source->append_event_unlocked(Frames, *i);
        }
+       
+       /*
+       // TODO: As of now, this is still necessary, because there are some events appended whose
+       // times are earlier than the preceding events
+       while(!events.empty()) {
+               source->append_event_unlocked(Frames, events.top());
+               events.pop();
+       }
+       */
                
        _note_mode = old_note_mode;
        
index 389224eb3bc20cd176e361290cd0390015bdd102..5ab3a5df13f383e74161267bab33375458bfe26b 100644 (file)
@@ -507,7 +507,11 @@ SMFSource::append_event_unlocked(EventTimeUnit unit, const MIDI::Event& ev)
        printf("\n");
        
        assert(ev.time() >= 0);
-       assert(ev.time() >= _last_ev_time);
+       
+       if (ev.time() < _last_ev_time) {
+               cerr << "SMFSource: Warning: Skipping event with ev.time() < _last_ev_time" << endl;
+               return;
+       }
        
        uint32_t delta_time = 0;