temporal: use correct implementation of timepos_t::operator+ (timecnt_t) (and +=)
If time domains differ, it is necessary to first convert the argument duration into a duration at the position of "this", in the correct time domain. Then we recursively call the operator again, but this time we will use the fast path that just adds two timepos_t values.
This commit is contained in:
parent
5925ee0b7c
commit
0acc1a3fec
@ -776,21 +776,42 @@ timepos_t::operator+= (Temporal::BBT_Offset const & offset)
|
|||||||
timepos_t
|
timepos_t
|
||||||
timepos_t::operator+(timecnt_t const & d) const
|
timepos_t::operator+(timecnt_t const & d) const
|
||||||
{
|
{
|
||||||
if (d.time_domain() == AudioTime) {
|
if (d.time_domain() == time_domain()) {
|
||||||
|
if (time_domain() == AudioTime) {
|
||||||
return operator+ (timepos_t::from_superclock (d.superclocks()));
|
return operator+ (timepos_t::from_superclock (d.superclocks()));
|
||||||
|
} else {
|
||||||
|
return operator+ (timepos_t::from_ticks (d.ticks()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return operator+ (timepos_t::from_ticks (d.ticks()));
|
TempoMap::SharedPtr tm (TempoMap::use());
|
||||||
|
|
||||||
|
timecnt_t dur_at_this = tm->convert_duration (d, *this, time_domain());
|
||||||
|
|
||||||
|
assert (dur_at_this.time_domain() == time_domain());
|
||||||
|
|
||||||
|
return operator+ (dur_at_this);
|
||||||
}
|
}
|
||||||
|
|
||||||
timepos_t &
|
timepos_t &
|
||||||
timepos_t::operator+=(timecnt_t const & d)
|
timepos_t::operator+=(timecnt_t const & d)
|
||||||
{
|
{
|
||||||
if (d.time_domain() == AudioTime) {
|
if (d.time_domain() == time_domain()) {
|
||||||
|
if (time_domain() == AudioTime) {
|
||||||
return operator+= (timepos_t::from_superclock (d.superclocks()));
|
return operator+= (timepos_t::from_superclock (d.superclocks()));
|
||||||
}
|
} else {
|
||||||
return operator+= (timepos_t::from_ticks (d.ticks()));
|
return operator+= (timepos_t::from_ticks (d.ticks()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TempoMap::SharedPtr tm (TempoMap::use());
|
||||||
|
|
||||||
|
timecnt_t dur_at_this = tm->convert_duration (d, *this, time_domain());
|
||||||
|
|
||||||
|
assert (dur_at_this.time_domain() == time_domain());
|
||||||
|
|
||||||
|
return operator+= (dur_at_this);
|
||||||
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user