* 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
This commit is contained in:
Hans Baier 2008-05-06 05:17:51 +00:00
parent e55e3fde7c
commit cb88f8cce9
2 changed files with 8 additions and 9 deletions

View file

@ -483,8 +483,8 @@ void MidiModel::append(const MIDI::Event& ev)
write_lock(); write_lock();
_edited = true; _edited = true;
/*cerr << "MidiModel append event type: " cerr << "MidiModel append event type: "
<< hex << "0x" << (int)ev.type() << endl;*/ << hex << "0x" << (int)ev.type() << endl;
assert(_notes.empty() || ev.time() >= _notes.back()->time()); assert(_notes.empty() || ev.time() >= _notes.back()->time());
assert(_writing); assert(_writing);
@ -891,10 +891,10 @@ bool MidiModel::write_to(boost::shared_ptr<MidiSource> source)
const NoteMode old_note_mode = _note_mode; const NoteMode old_note_mode = _note_mode;
_note_mode = Sustained; _note_mode = Sustained;
for (const_iterator i = begin(); i != end(); ++i) for (const_iterator i = begin(); i != end(); ++i)
source->append_event_unlocked(Frames, *i); source->append_event_unlocked(Frames, *i);
_note_mode = old_note_mode; _note_mode = old_note_mode;
read_unlock(); read_unlock();

View file

@ -170,8 +170,7 @@ SMFSource::open()
// Write a tentative header just to pad things out so writing happens in the right spot // Write a tentative header just to pad things out so writing happens in the right spot
flush_header(); flush_header();
write_footer(); flush_footer();
seek_to_end();
} }
return (_fd == 0) ? -1 : 0; return (_fd == 0) ? -1 : 0;
@ -226,7 +225,7 @@ SMFSource::flush_header()
int int
SMFSource::flush_footer() SMFSource::flush_footer()
{ {
fseek(_fd, 0, SEEK_END); seek_to_end();
write_footer(); write_footer();
return 0; 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); MidiSource::mark_streaming_midi_write_started (mode, start_frame);
_last_ev_time = 0; _last_ev_time = 0;
fseek(_fd, _header_size, 0); fseek(_fd, _header_size, SEEK_SET);
} }
void void
@ -888,7 +887,7 @@ SMFSource::load_model(bool lock, bool force_reload)
_model->start_write(); _model->start_write();
fseek(_fd, _header_size, 0); fseek(_fd, _header_size, SEEK_SET);
uint64_t time = 0; /* in SMF ticks */ uint64_t time = 0; /* in SMF ticks */
MIDI::Event ev; MIDI::Event ev;