13
0

correctly reset capture alignment at session load; for MIDI diskstreams, don't try to set capture alignment based on connectivity, always set _source_port ASAP and check _source_port when recording

git-svn-id: svn://localhost/ardour2/branches/3.0@9334 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2011-04-09 14:59:22 +00:00
parent ce35e913d0
commit 64022eebcb
4 changed files with 29 additions and 47 deletions

View File

@ -77,15 +77,14 @@ class Diskstream : public SessionObject, public PublicDiskstream
AlignStyle alignment_style() const { return _alignment_style; }
AlignChoice alignment_choice() const { return _alignment_choice; }
void set_align_style (AlignStyle);
void set_align_choice (AlignChoice a);
void set_align_style (AlignStyle, bool force=false);
void set_align_choice (AlignChoice a, bool force=false);
framecnt_t roll_delay() const { return _roll_delay; }
void set_roll_delay (framecnt_t);
bool record_enabled() const { return g_atomic_int_get (&_record_enabled); }
virtual void set_record_enabled (bool yn) = 0;
virtual void get_input_sources () = 0;
bool destructive() const { return _flags & Destructive; }
virtual int set_destructive (bool /*yn*/) { return -1; }

View File

@ -70,7 +70,8 @@ public:
virtual framepos_t current_capture_end () const = 0;
virtual void playlist_modified () = 0;
virtual int use_playlist (boost::shared_ptr<Playlist>) = 0;
virtual void set_align_style (AlignStyle) = 0;
virtual void set_align_style (AlignStyle, bool force=false) = 0;
virtual void set_align_choice (AlignChoice, bool force=false) = 0;
virtual int use_copy_playlist () = 0;
virtual int use_new_playlist () = 0;
virtual void adjust_playback_buffering () = 0;

View File

@ -280,26 +280,26 @@ Diskstream::set_capture_offset ()
void
Diskstream::set_align_style (AlignStyle a)
Diskstream::set_align_style (AlignStyle a, bool force)
{
if (record_enabled() && _session.actively_recording()) {
return;
}
if (a != _alignment_style) {
if ((a != _alignment_style) || force) {
_alignment_style = a;
AlignmentStyleChanged ();
}
}
void
Diskstream::set_align_choice (AlignChoice a)
Diskstream::set_align_choice (AlignChoice a, bool force)
{
if (record_enabled() && _session.actively_recording()) {
return;
}
if (a != _alignment_choice) {
if ((a != _alignment_choice) || force) {
_alignment_choice = a;
switch (_alignment_choice) {
@ -509,9 +509,9 @@ Diskstream::set_state (const XMLNode& node, int /*version*/)
}
if ((prop = node.property (X_("capture-alignment"))) != 0) {
_alignment_choice = AlignChoice (string_2_enum (prop->value(), _alignment_choice));
set_align_choice (AlignChoice (string_2_enum (prop->value(), _alignment_choice)), true);
} else {
_alignment_choice = Automatic;
set_align_choice (Automatic, true);
}
if ((prop = node.property ("playlist")) == 0) {

View File

@ -36,6 +36,7 @@
#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"
@ -162,17 +163,24 @@ MidiDiskstream::non_realtime_input_change ()
}
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 ();
}
@ -199,23 +207,6 @@ MidiDiskstream::non_realtime_input_change ()
_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)
{
@ -504,6 +495,10 @@ MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, bool can
return 0;
}
if (_source_port == 0) {
return 1;
}
Glib::Mutex::Lock sm (state_lock, Glib::TRY_LOCK);
if (!sm.locked()) {
@ -524,13 +519,12 @@ MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, bool can
}
}
if (can_record && !_last_capture_sources.empty()) {
_last_capture_sources.clear ();
}
if (nominally_recording || rec_nframes) {
// Pump entire port buffer into the ring buffer (FIXME: split cycles?)
MidiBuffer& buf = _source_port->get_midi_buffer(nframes);
for (MidiBuffer::iterator i = buf.begin(); i != buf.end(); ++i) {
@ -1375,27 +1369,15 @@ MidiDiskstream::monitor_input (bool yn)
void
MidiDiskstream::set_align_style_from_io ()
{
bool have_physical = false;
if (_alignment_choice != Automatic) {
return;
}
if (_io == 0) {
return;
}
/* XXX Not sure what, if anything we can do with MIDI
as far as capture alignment etc.
*/
get_input_sources ();
if (_source_port && _source_port->flags() & JackPortIsPhysical) {
have_physical = true;
}
if (have_physical) {
set_align_style (ExistingMaterial);
} else {
set_align_style (CaptureTime);
}
set_align_style (ExistingMaterial);
}