13
0

get sdio branch working with MIDI tracks

This commit is contained in:
Paul Davis 2017-06-12 15:38:59 -04:00
parent 480b6b81cd
commit 26b13ed5f1
4 changed files with 61 additions and 18 deletions

View 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)); }

View 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 ();

View 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;
}

View 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;
}