move open-on-write call for MIDI into mark_streaming_midi_write_started() so that...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 3 Mar 2011 03:54:28 +0000 (03:54 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 3 Mar 2011 03:54:28 +0000 (03:54 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9052 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/smf_source.cc

index c686ae3d27705e3ac86475bad6ff7a6bcdf3cfb3..5ad5c2b745bdf294e288275f215f01902d22e0bc 100644 (file)
@@ -221,11 +221,6 @@ SMFSource::read_unlocked (Evoral::EventSink<framepos_t>& destination, framepos_t
 framecnt_t
 SMFSource::write_unlocked (MidiRingBuffer<framepos_t>& source, framepos_t position, framecnt_t duration)
 {
-        if (!_open && open_for_write()) {
-                error << string_compose (_("cannot open MIDI file %1 for write"), _path) << endmsg;
-                return 0;
-        }
-
         if (!_writing) {
                 mark_streaming_write_started ();
         }
@@ -415,6 +410,12 @@ SMFSource::mark_streaming_midi_write_started (NoteMode mode)
 {
         /* CALLER MUST HOLD LOCK */
 
+        if (!_open && open_for_write()) {
+                error << string_compose (_("cannot open MIDI file %1 for write"), _path) << endmsg;
+                /* XXX should probably throw or return something */
+                return; 
+        }
+
        MidiSource::mark_streaming_midi_write_started (mode);
        Evoral::SMF::begin_write ();
        _last_ev_time_beats = 0.0;