get sdio branch working with MIDI tracks
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 12 Jun 2017 19:38:59 +0000 (15:38 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 18 Sep 2017 15:40:53 +0000 (11:40 -0400)
libs/ardour/ardour/disk_writer.h
libs/ardour/disk_io.cc
libs/ardour/disk_writer.cc
libs/ardour/midi_track.cc

index 6d2683780b08fd7a9243b8ef6518a1deda8683cc..34a53a5a25abb3561c410d13458864bc9cf0a1be 100644 (file)
@@ -77,7 +77,7 @@ class LIBARDOUR_API DiskWriter : public DiskIOProcessor
 
        boost::shared_ptr<SMFSource> midi_write_source () { return _midi_write_source; }
 
-       virtual std::string steal_write_source_name () { return std::string(); }
+       virtual std::string steal_write_source_name ();
        int use_new_write_source (DataType, uint32_t n = 0);
        void reset_write_sources (bool, bool force = false);
 
@@ -91,6 +91,8 @@ class LIBARDOUR_API DiskWriter : public DiskIOProcessor
        void set_input_latency (framecnt_t);
        framecnt_t input_latency () const { return _input_latency; }
 
+       bool configure_io (ChanCount in, ChanCount out);
+
        std::list<boost::shared_ptr<Source> >& last_capture_sources () { return _last_capture_sources; }
 
        bool         record_enabled() const { return g_atomic_int_get (const_cast<gint*>(&_record_enabled)); }
index 587ba19ed05a79c1cfaba85ba02ec9ff9aa85b27..40f97cba0a2ab48523a5b60388dc0f0113cd06d2 100644 (file)
@@ -136,10 +136,8 @@ DiskIOProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& o
                return false;
        }
 
-       if (in != out) {
-               /* currently no way to deliver different channels that we receive */
-               return false;
-       }
+       /* currently no way to deliver different channels that we receive */
+       out = in;
 
        return true;
 }
@@ -332,6 +330,7 @@ DiskIOProcessor::use_playlist (DataType dt, boost::shared_ptr<Playlist> playlist
         DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: set to use playlist %2 (%3)\n", name(), playlist->name(), dt.to_string()));
 
         if (playlist == _playlists[dt]) {
+               DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1: already using that playlist\n", name()));
                return 0;
         }
 
@@ -349,7 +348,7 @@ DiskIOProcessor::use_playlist (DataType dt, boost::shared_ptr<Playlist> playlist
         playlist->DropReferences.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_deleted, this, boost::weak_ptr<Playlist>(playlist)));
         playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&DiskIOProcessor::playlist_ranges_moved, this, _1, _2));
 
-       DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1 now use playlist %1 (%2)\n", name(), playlist->name(), playlist->id()));
+       DEBUG_TRACE (DEBUG::DiskIO, string_compose ("%1 now using playlist %1 (%2)\n", name(), playlist->name(), playlist->id()));
 
        PlaylistChanged (dt); /* EMIT SIGNAL */
        _session.set_dirty ();
index 4a1c24c1fdbec0b2f215806faa78d9680fb01529..c3d6039f109fbdf2eea24636246d31842564929c 100644 (file)
@@ -1041,18 +1041,20 @@ DiskWriter::reset_write_sources (bool mark_write_complete, bool /*force*/)
                        Source::Lock lm(_midi_write_source->mutex());
                        _midi_write_source->mark_streaming_write_completed (lm);
                }
+       }
 
+       if (_playlists[DataType::MIDI]) {
                use_new_write_source (DataType::MIDI);
+       }
 
-               if (destructive() && !c->empty ()) {
+       if (destructive() && !c->empty ()) {
 
-                       /* we now have all our write sources set up, so create the
-                          playlist's single region.
-                       */
+               /* we now have all our write sources set up, so create the
+                  playlist's single region.
+               */
 
-                       if (_playlists[DataType::MIDI]->empty()) {
-                               setup_destructive_playlist ();
-                       }
+               if (_playlists[DataType::MIDI]->empty()) {
+                       setup_destructive_playlist ();
                }
        }
 }
@@ -1507,7 +1509,7 @@ DiskWriter::transport_stopped_wallclock (struct tm& /*when*/, time_t /*twhen*/,
 
        }
 
-       use_new_write_source (0);
+       reset_write_sources ();
 
        for (ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
                delete *ci;
@@ -1682,3 +1684,44 @@ DiskWriter::set_name (string const & str)
 
        return true;
 }
+
+std::string
+DiskWriter::steal_write_source_name ()
+{
+       if (_playlists[DataType::MIDI]) {
+               string our_old_name = _midi_write_source->name();
+
+               /* this will bump the name of the current write source to the next one
+                * (e.g. "MIDI 1-1" gets renamed to "MIDI 1-2"), thus leaving the
+                * current write source name (e.g. "MIDI 1-1" available). See the
+                * comments in Session::create_midi_source_by_stealing_name() about why
+                * we do this.
+                */
+
+               try {
+                       string new_path = _session.new_midi_source_path (name());
+
+                       if (_midi_write_source->rename (new_path)) {
+                               return string();
+                       }
+               } catch (...) {
+                       return string ();
+               }
+
+               return our_old_name;
+       }
+
+       return std::string();
+}
+
+bool
+DiskWriter::configure_io (ChanCount in, ChanCount out)
+{
+       if (!DiskIOProcessor::configure_io (in, out)) {
+               return false;
+       }
+
+       reset_write_sources (false, true);
+
+       return true;
+}
index 4e666b7c0a358bb95d888cf74eb182aa22389f74..777db1d91d864b04eed98170dd5239f8c77e7664 100644 (file)
@@ -79,10 +79,6 @@ MidiTrack::MidiTrack (Session& sess, string name, TrackMode mode)
        , _input_active (true)
 {
        _session.SessionLoaded.connect_same_thread (*this, boost::bind (&MidiTrack::restore_controls, this));
-
-       _disk_writer->set_note_mode (_note_mode);
-       _disk_reader->reset_tracker ();
-
 }
 
 MidiTrack::~MidiTrack ()
@@ -98,6 +94,9 @@ MidiTrack::init ()
 
        _input->changed.connect_same_thread (*this, boost::bind (&MidiTrack::track_input_active, this, _1, _2));
 
+       _disk_writer->set_note_mode (_note_mode);
+       _disk_reader->reset_tracker ();
+
        return 0;
 }