Fix up some inconsistencies in handling of region sync points.

git-svn-id: svn://localhost/ardour2/branches/3.0@7706 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-08-29 01:08:07 +00:00
parent 8f093b0eaa
commit bce90b1802
5 changed files with 16 additions and 14 deletions

View file

@ -620,7 +620,6 @@ Editor::build_region_boundary_cache ()
case SyncPoint: case SyncPoint:
rpos = r->sync_position (); rpos = r->sync_position ();
//r->adjust_to_sync (r->first_frame());
break; break;
default: default:
@ -713,7 +712,6 @@ Editor::find_next_region (framepos_t frame, RegionPoint point, int32_t dir, Trac
case SyncPoint: case SyncPoint:
rpos = r->sync_position (); rpos = r->sync_position ();
// r->adjust_to_sync (r->first_frame());
break; break;
} }
@ -884,7 +882,6 @@ Editor::cursor_to_region_point (EditorCursor* cursor, RegionPoint point, int32_t
case SyncPoint: case SyncPoint:
pos = r->sync_position (); pos = r->sync_position ();
// r->adjust_to_sync (r->first_frame());
break; break;
} }

View file

@ -656,7 +656,7 @@ EditorRegions::populate_row (boost::shared_ptr<Region> region, TreeModel::Row co
sprintf (end_str, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); sprintf (end_str, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
_session->timecode_time (region->length(), timecode); _session->timecode_time (region->length(), timecode);
sprintf (length_str, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); sprintf (length_str, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
_session->timecode_time (region->sync_position() + region->position(), timecode); _session->timecode_time (region->sync_position(), timecode);
sprintf (sync_str, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); sprintf (sync_str, "%02d:%02d:%02d:%02d", timecode.hours, timecode.minutes, timecode.seconds, timecode.frames);
if (audioRegion && !fades_in_seconds) { if (audioRegion && !fades_in_seconds) {
@ -675,7 +675,7 @@ EditorRegions::populate_row (boost::shared_ptr<Region> region, TreeModel::Row co
sprintf (end_str, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks); sprintf (end_str, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks);
_session->tempo_map().bbt_time (region->length(), bbt); _session->tempo_map().bbt_time (region->length(), bbt);
sprintf (length_str, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks); sprintf (length_str, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks);
_session->tempo_map().bbt_time (region->sync_position() + region->position(), bbt); _session->tempo_map().bbt_time (region->sync_position(), bbt);
sprintf (sync_str, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks); sprintf (sync_str, "%03d|%02d|%04d" , bbt.bars, bbt.beats, bbt.ticks);
if (audioRegion && !fades_in_seconds) { if (audioRegion && !fades_in_seconds) {
@ -716,7 +716,7 @@ EditorRegions::populate_row (boost::shared_ptr<Region> region, TreeModel::Row co
secs = left / (float) _session->frame_rate(); secs = left / (float) _session->frame_rate();
sprintf (length_str, "%02d:%02d:%06.3f", hrs, mins, secs); sprintf (length_str, "%02d:%02d:%06.3f", hrs, mins, secs);
left = region->sync_position() + region->position(); left = region->sync_position();
hrs = (int) floor (left / (_session->frame_rate() * 60.0f * 60.0f)); hrs = (int) floor (left / (_session->frame_rate() * 60.0f * 60.0f));
left -= (nframes_t) floor (hrs * _session->frame_rate() * 60.0f * 60.0f); left -= (nframes_t) floor (hrs * _session->frame_rate() * 60.0f * 60.0f);
mins = (int) floor (left / (_session->frame_rate() * 60.0f)); mins = (int) floor (left / (_session->frame_rate() * 60.0f));
@ -748,7 +748,7 @@ EditorRegions::populate_row (boost::shared_ptr<Region> region, TreeModel::Row co
snprintf (start_str, sizeof (start_str), "%" PRId64, region->position()); snprintf (start_str, sizeof (start_str), "%" PRId64, region->position());
snprintf (end_str, sizeof (end_str), "%" PRId64, (region->last_frame())); snprintf (end_str, sizeof (end_str), "%" PRId64, (region->last_frame()));
snprintf (length_str, sizeof (length_str), "%" PRId64, region->length()); snprintf (length_str, sizeof (length_str), "%" PRId64, region->length());
snprintf (sync_str, sizeof (sync_str), "%" PRId64, region->sync_position() + region->position()); snprintf (sync_str, sizeof (sync_str), "%" PRId64, region->sync_position());
if (audioRegion && !fades_in_seconds) { if (audioRegion && !fades_in_seconds) {
snprintf (fadein_str, sizeof (fadein_str), "%u", uint (audioRegion->fade_in()->back()->when)); snprintf (fadein_str, sizeof (fadein_str), "%u", uint (audioRegion->fade_in()->back()->when));
@ -804,9 +804,9 @@ EditorRegions::populate_row (boost::shared_ptr<Region> region, TreeModel::Row co
row[_columns.start] = start_str; row[_columns.start] = start_str;
row[_columns.end] = end_str; row[_columns.end] = end_str;
if (region->sync_position() == 0) { if (region->sync_position() == region->position()) {
row[_columns.sync] = _("Start"); row[_columns.sync] = _("Start");
} else if (region->sync_position() == region->length() - 1) { } else if (region->sync_position() == (region->position() + region->length() - 1)) {
row[_columns.sync] = _("End"); row[_columns.sync] = _("End");
} else { } else {
row[_columns.sync] = sync_str; row[_columns.sync] = sync_str;

View file

@ -346,6 +346,7 @@ class Region
PBD::Property<framepos_t> _start; PBD::Property<framepos_t> _start;
PBD::Property<framecnt_t> _length; PBD::Property<framecnt_t> _length;
PBD::Property<framepos_t> _position; PBD::Property<framepos_t> _position;
/** Sync position relative to the start of our file */
PBD::Property<framepos_t> _sync_position; PBD::Property<framepos_t> _sync_position;
PBD::Property<layer_t> _layer; PBD::Property<layer_t> _layer;
PBD::Property<framepos_t> _ancestral_start; PBD::Property<framepos_t> _ancestral_start;

View file

@ -1999,7 +1999,6 @@ Playlist::find_next_region (framepos_t frame, RegionPoint point, int dir)
break; break;
case SyncPoint: case SyncPoint:
pos = r->sync_position (); pos = r->sync_position ();
// r->adjust_to_sync (r->first_frame());
break; break;
} }

View file

@ -1013,9 +1013,13 @@ Region::set_position_locked (bool yn)
} }
} }
/** Set the region's sync point.
* @param absolute_pos Session time.
*/
void void
Region::set_sync_position (framepos_t absolute_pos) Region::set_sync_position (framepos_t absolute_pos)
{ {
/* position within our file */
framepos_t const file_pos = _start + (absolute_pos - _position); framepos_t const file_pos = _start + (absolute_pos - _position);
if (file_pos != _sync_position) { if (file_pos != _sync_position) {
@ -1040,11 +1044,10 @@ Region::clear_sync_position ()
} }
} }
/* @return the sync point relative the first frame of the region */
framepos_t framepos_t
Region::sync_offset (int& dir) const Region::sync_offset (int& dir) const
{ {
/* returns the sync point relative the first frame of the region */
if (sync_marked()) { if (sync_marked()) {
if (_sync_position > _start) { if (_sync_position > _start) {
dir = 1; dir = 1;
@ -1082,13 +1085,15 @@ Region::adjust_to_sync (framepos_t pos) const
return pos; return pos;
} }
/** @return Sync position in session time */
framepos_t framepos_t
Region::sync_position() const Region::sync_position() const
{ {
if (sync_marked()) { if (sync_marked()) {
return _sync_position; return _position - _start + _sync_position;
} else { } else {
return _start; /* if sync has not been marked, use the start of the region */
return _position;
} }
} }