From cb88f8cce97658ad3c990850104feca9fb0138ef Mon Sep 17 00:00:00 2001 From: Hans Baier Date: Tue, 6 May 2008 05:17:51 +0000 Subject: [PATCH] * fixed end of track at beginning-problem when writing MIDI files (also the EOT event was written multiple times) git-svn-id: svn://localhost/ardour2/branches/3.0@3317 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/midi_model.cc | 8 ++++---- libs/ardour/smf_source.cc | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc index 3e009bcb8f..8545e7cd95 100644 --- a/libs/ardour/midi_model.cc +++ b/libs/ardour/midi_model.cc @@ -483,8 +483,8 @@ void MidiModel::append(const MIDI::Event& ev) write_lock(); _edited = true; - /*cerr << "MidiModel append event type: " - << hex << "0x" << (int)ev.type() << endl;*/ + cerr << "MidiModel append event type: " + << hex << "0x" << (int)ev.type() << endl; assert(_notes.empty() || ev.time() >= _notes.back()->time()); assert(_writing); @@ -891,10 +891,10 @@ bool MidiModel::write_to(boost::shared_ptr source) const NoteMode old_note_mode = _note_mode; _note_mode = Sustained; - + for (const_iterator i = begin(); i != end(); ++i) source->append_event_unlocked(Frames, *i); - + _note_mode = old_note_mode; read_unlock(); diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index dadb919b17..4d1c78af9d 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -170,8 +170,7 @@ SMFSource::open() // Write a tentative header just to pad things out so writing happens in the right spot flush_header(); - write_footer(); - seek_to_end(); + flush_footer(); } return (_fd == 0) ? -1 : 0; @@ -226,7 +225,7 @@ SMFSource::flush_header() int SMFSource::flush_footer() { - fseek(_fd, 0, SEEK_END); + seek_to_end(); write_footer(); return 0; @@ -558,7 +557,7 @@ SMFSource::mark_streaming_midi_write_started (NoteMode mode, nframes_t start_fra { MidiSource::mark_streaming_midi_write_started (mode, start_frame); _last_ev_time = 0; - fseek(_fd, _header_size, 0); + fseek(_fd, _header_size, SEEK_SET); } void @@ -888,7 +887,7 @@ SMFSource::load_model(bool lock, bool force_reload) _model->start_write(); - fseek(_fd, _header_size, 0); + fseek(_fd, _header_size, SEEK_SET); uint64_t time = 0; /* in SMF ticks */ MIDI::Event ev;