13
0

locations now follow session time domain, always (probably)

This commit is contained in:
Paul Davis 2023-07-21 15:34:23 -06:00
parent 0c9bdd817d
commit 1b9f4999df
6 changed files with 55 additions and 30 deletions

View File

@ -172,9 +172,9 @@ public:
int set_state (const XMLNode&, int version);
Temporal::TimeDomain position_time_domain() const { return _start.time_domain(); }
void set_position_time_domain (Temporal::TimeDomain ps);
void globally_change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to);
void change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to);
class ChangeSuspender {
public:
@ -228,6 +228,8 @@ private:
std::set<Signal> _postponed_signals;
std::shared_ptr<SceneChange> _scene_change;
void set_position_time_domain (Temporal::TimeDomain);
};
/** A collection of session locations including unique dedicated locations (loop, punch, etc) */
@ -302,6 +304,7 @@ public:
void find_all_between (timepos_t const & start, timepos_t const & end, LocationList&, Location::Flags);
void globally_change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to);
void change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to);
PBD::Signal1<void,Location*> current_changed;

View File

@ -2383,6 +2383,8 @@ private:
int tb_with_filled_slots;
void handle_slots_empty_status (std::weak_ptr<Route> const &);
void time_domain_changed ();
};

View File

@ -62,7 +62,6 @@ CONFIG_VARIABLE (samplecnt_t, timecode_offset, "timecode-offset", 0)
CONFIG_VARIABLE (bool, timecode_offset_negative, "timecode-offset-negative", true)
CONFIG_VARIABLE (std::string, slave_timecode_offset, "slave-timecode-offset", " 00:00:00:00")
CONFIG_VARIABLE (std::string, timecode_generator_offset, "timecode-generator-offset", " 00:00:00:00")
CONFIG_VARIABLE (bool, glue_new_markers_to_bars_and_beats, "glue-new-markers-to-bars-and-beats", false)
CONFIG_VARIABLE (bool, midi_copy_is_fork, "midi-copy-is-fork", true)
CONFIG_VARIABLE (bool, glue_new_regions_to_bars_and_beats, "glue-new-regions-to-bars-and-beats", false)
CONFIG_VARIABLE (bool, realtime_export, "realtime-export", false)

View File

@ -87,24 +87,26 @@ Location::Location (Session& s, timepos_t const & start, timepos_t const & end,
, _cue (cue_id)
, _signals_suspended (0)
{
/* Locations follow the global Session time domain */
/* it would be nice if the caller could ensure that the start and end
values simply use the correct domain, but that would involve
enforcing/checking that at every place where we create a
Location. So instead we centralize this here.
NUTEMPO: it might make sense to switch time domains when <something>
happens, but it's not clear what the <something> might be? Maybe
changing some setting of the tempo map.
*/
if (s.config.get_glue_new_markers_to_bars_and_beats()) {
set_position_time_domain (Temporal::BeatTime);
} else {
set_position_time_domain (Temporal::AudioTime);
}
set_position_time_domain (_session.time_domain());
}
void
Location::set_position_time_domain (TimeDomain domain)
{
if (_start.time_domain() == domain) {
return;
}
_start.set_time_domain (domain);
_end.set_time_domain (domain);
emit_signal (Domain); /* EMIT SIGNAL */
}
Location::Location (const Location& other)
: SessionHandleRef (other._session)
, StatefulDestructible()
@ -726,19 +728,6 @@ Location::set_state (const XMLNode& node, int version)
return 0;
}
void
Location::set_position_time_domain (TimeDomain domain)
{
if (_start.time_domain() == domain) {
return;
}
_start.set_time_domain (domain);
_end.set_time_domain (domain);
emit_signal (Domain); /* EMIT SIGNAL */
}
void
Location::lock ()
{
@ -784,6 +773,14 @@ Location::globally_change_time_domain (Temporal::TimeDomain from, Temporal::Time
}
}
void
Location::change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to)
{
if (_start.time_domain() == from) {
set_position_time_domain (to);
}
}
/*---------------------------------------------------------------------- */
Locations::Locations (Session& s)
@ -1883,3 +1880,14 @@ Locations::globally_change_time_domain (Temporal::TimeDomain from, Temporal::Tim
}
}
void
Locations::change_time_domain (Temporal::TimeDomain from, Temporal::TimeDomain to)
{
std::cerr << "change all locations to " << to << std::endl;
Glib::Threads::RWLock::WriterLock lm (_lock);
for (auto & l : locations) {
l->change_time_domain (from, to);
}
}

View File

@ -7787,3 +7787,15 @@ Session::foreach_route (void (Route::*method)())
}
}
void
Session::time_domain_changed ()
{
using namespace Temporal;
TimeDomainProvider::time_domain_changed ();
Temporal::TimeDomain to = time_domain();
Temporal::TimeDomain from = (to == AudioTime ? BeatTime : AudioTime);
_locations->change_time_domain (from, to);
}

View File

@ -4584,6 +4584,7 @@ Session::config_changed (std::string p, bool ours)
}
} else if (p == "default-time-domain") {
Temporal::TimeDomain td = config.get_default_time_domain ();
std::cerr << "Setting time domain\n";
set_time_domain (td);
}