#include "pbd/memento_command.h"
#include "pbd/enumwriter.h"
#include "pbd/stateful_diff_command.h"
+#include "pbd/stacktrace.h"
#include "ardour/ardour.h"
#include "ardour/audioengine.h"
, _frames_written_to_ringbuffer(0)
, _frames_read_from_ringbuffer(0)
{
- /* prevent any write sources from being created */
-
in_set_state = true;
init ();
if (_write_source) {
_write_source->set_timeline_position (position);
}
- seek(position, false);
+ seek (position, false);
}
}
if (input_change_pending.type & IOChange::ConfigurationChanged) {
- if (_io->n_ports().n_midi() != _n_channels.n_midi()) {
+ uint32_t ni = _io->n_ports().n_midi();
+
+ if (ni != _n_channels.n_midi()) {
error << string_compose (_("%1: I/O configuration change %4 requested to use %2, but channel setup is %3"),
name(),
_io->n_ports(),
_n_channels, input_change_pending.type)
<< endmsg;
}
+
+ if (ni == 0) {
+ _source_port = 0;
+ } else {
+ _source_port = _io->midi(0);
+ }
}
if (input_change_pending.type & IOChange::ConnectionsChanged) {
- get_input_sources ();
set_capture_offset ();
set_align_style_from_io ();
}
_last_flush_frame = _session.transport_frame();
}
-void
-MidiDiskstream::get_input_sources ()
-{
- uint32_t ni = _io->n_ports().n_midi();
-
- if (ni == 0) {
- return;
- }
-
- // This is all we do for now at least
- assert(ni == 1);
-
- _source_port = _io->midi(0);
-
- // do... stuff?
-}
-
int
MidiDiskstream::find_and_use_playlist (const string& name)
{
return 0;
}
+ if (_source_port == 0) {
+ return 1;
+ }
+
Glib::Mutex::Lock sm (state_lock, Glib::TRY_LOCK);
if (!sm.locked()) {
}
}
-
if (can_record && !_last_capture_sources.empty()) {
_last_capture_sources.clear ();
}
// << frames_written - frames_read << endl;
to_read = (framecnt_t) min ((framecnt_t) to_read, (framecnt_t) (max_framepos - file_frame));
-
+
if (read (file_frame, to_read, reversed)) {
ret = -1;
}
_write_source.reset();
}
}
-
+
mark_write_completed = true;
}
{
list<boost::shared_ptr<Source> > ret;
- /* put some data on the disk, even if its just a header for an empty file.
- XXX should we not have a more direct method for doing this? Maybe not
- since we don't want to mess around with the model/disk relationship
- that the Source has to pay attention to.
- */
-
- boost::dynamic_pointer_cast<MidiSource>(_write_source)->session_saved ();
+ /* put some data on the disk, even if its just a header for an empty file */
+ boost::dynamic_pointer_cast<SMFSource> (_write_source)->ensure_disk_file ();
/* never let it go away */
_write_source->mark_nonremovable ();
void
MidiDiskstream::set_align_style_from_io ()
{
- bool have_physical = false;
-
if (_alignment_choice != Automatic) {
return;
}
- if (_io == 0) {
- return;
- }
-
- get_input_sources ();
-
- if (_source_port && _source_port->flags() & JackPortIsPhysical) {
- have_physical = true;
- }
+ /* XXX Not sure what, if anything we can do with MIDI
+ as far as capture alignment etc.
+ */
- if (have_physical) {
- set_align_style (ExistingMaterial);
- } else {
- set_align_style (CaptureTime);
- }
+ set_align_style (ExistingMaterial);
}
#ifndef NDEBUG
DEBUG_TRACE (DEBUG::MidiDiskstreamIO, string_compose (
- "%1 MDS pre-read read from %2 write to %3\n", _name,
+ "%1 MDS pre-read read from %2 write to %3\n", _name,
_playback_buf->get_read_ptr(), _playback_buf->get_write_ptr()));
// cerr << "================\n";
// _playback_buf->dump (cerr);
g_atomic_int_add(&_frames_read_from_ringbuffer, frames_read);
}
+bool
+MidiDiskstream::set_name (string const & name)
+{
+ Diskstream::set_name (name);
+
+ /* get a new write source so that its name reflects the new diskstream name */
+ use_new_write_source (0);
+
+ return true;
+}
+