13
0

advance track's play-position even if processing is locked

fixes
  * http://tracker.ardour.org/view.php?id=5628
  * http://tracker.ardour.org/view.php?id=5561
This commit is contained in:
Robin Gareus 2013-08-03 21:35:19 +02:00 committed by Paul Davis
parent b5845ea458
commit ee610da977
8 changed files with 59 additions and 1 deletions

View File

@ -152,6 +152,7 @@ class AudioDiskstream : public Diskstream
friend class AudioTrack;
int process (BufferSet&, framepos_t transport_frame, pframes_t nframes, framecnt_t &, bool need_disk_signal);
frameoffset_t calculate_playback_distance (pframes_t nframes);
bool commit (framecnt_t);
private:

View File

@ -193,6 +193,7 @@ class Diskstream : public SessionObject, public PublicDiskstream
friend class Track;
virtual int process (BufferSet&, framepos_t transport_frame, pframes_t nframes, framecnt_t &, bool need_disk_signal) = 0;
virtual frameoffset_t calculate_playback_distance (pframes_t nframes) = 0;
virtual bool commit (framecnt_t) = 0;
//private:

View File

@ -125,6 +125,7 @@ class MidiDiskstream : public Diskstream
friend class MidiTrack;
int process (BufferSet&, framepos_t transport_frame, pframes_t nframes, framecnt_t &, bool need_diskstream);
frameoffset_t calculate_playback_distance (pframes_t nframes);
bool commit (framecnt_t nframes);
static framecnt_t midi_readahead;

View File

@ -700,6 +700,31 @@ AudioDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t
return 0;
}
frameoffset_t
AudioDiskstream::calculate_playback_distance (pframes_t nframes)
{
frameoffset_t playback_distance = nframes;
if (record_enabled()) {
playback_distance = nframes;
} else if (_actual_speed != 1.0f && _actual_speed != -1.0f) {
interpolation.set_speed (_target_speed);
boost::shared_ptr<ChannelList> c = channels.reader();
int channel = 0;
for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan, ++channel) {
playback_distance = interpolation.interpolate (channel, nframes, NULL, NULL);
}
} else {
playback_distance = nframes;
}
if (_actual_speed < 0.0) {
return -playback_distance;
} else {
return playback_distance;
}
}
/** Update various things including playback_sample, read pointer on each channel's playback_buf
* and write pointer on each channel's capture_buf. Also wout whether the butler is needed.
* @return true if the butler is required.
@ -900,7 +925,7 @@ AudioDiskstream::internal_playback_seek (framecnt_t distance)
boost::shared_ptr<ChannelList> c = channels.reader();
for (chan = c->begin(); chan != c->end(); ++chan) {
(*chan)->playback_buf->increment_read_ptr (distance);
(*chan)->playback_buf->increment_read_ptr (llabs(distance));
}
if (first_recordable_frame < max_framepos) {

View File

@ -313,6 +313,12 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
if (!lm.locked()) {
boost::shared_ptr<AudioDiskstream> diskstream = audio_diskstream();
framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes);
if (can_internal_playback_seek(llabs(playback_distance))) {
/* TODO should declick */
internal_playback_seek(playback_distance);
}
return 0;
}

View File

@ -517,6 +517,20 @@ MidiDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t
return 0;
}
frameoffset_t
MidiDiskstream::calculate_playback_distance (pframes_t nframes)
{
frameoffset_t playback_distance = nframes;
/* XXX: should be doing varispeed stuff once it's implemented in ::process() above */
if (_actual_speed < 0.0) {
return -playback_distance;
} else {
return playback_distance;
}
}
bool
MidiDiskstream::commit (framecnt_t playback_distance)
{

View File

@ -319,6 +319,12 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
{
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
if (!lm.locked()) {
boost::shared_ptr<MidiDiskstream> diskstream = midi_diskstream();
framecnt_t playback_distance = diskstream->calculate_playback_distance(nframes);
if (can_internal_playback_seek(llabs(playback_distance))) {
/* TODO should declick, and/or note-off */
internal_playback_seek(playback_distance);
}
return 0;
}

View File

@ -477,6 +477,10 @@ Track::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*
{
Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
if (!lm.locked()) {
framecnt_t playback_distance = _diskstream->calculate_playback_distance(nframes);
if (can_internal_playback_seek(playback_distance)) {
internal_playback_seek(playback_distance);
}
return 0;
}