triggerbox: steps toward sane trigger stopping API and design
This commit is contained in:
parent
0cfbf346e7
commit
ff89d998b2
|
@ -205,7 +205,7 @@ public:
|
|||
void set_disk_io_point (DiskIOPoint);
|
||||
DiskIOPoint disk_io_point() const { return _disk_io_point; }
|
||||
|
||||
void stop_trigger(bool now);
|
||||
void stop_triggers (bool now);
|
||||
|
||||
/* Processors */
|
||||
|
||||
|
|
|
@ -486,7 +486,6 @@ public:
|
|||
void reset_transport_speed (TransportRequestSource origin = TRS_UI);
|
||||
|
||||
void start_transport_from_trigger ();
|
||||
void stop_transport_from_trigger ();
|
||||
|
||||
void stop_all_triggers (bool now = true);
|
||||
|
||||
|
@ -1435,7 +1434,6 @@ private:
|
|||
bool _was_seamless;
|
||||
bool _under_nsm_control;
|
||||
unsigned int _xrun_count;
|
||||
bool transport_started_by_trigger;
|
||||
|
||||
std::string _missing_file_replacement;
|
||||
|
||||
|
|
|
@ -502,7 +502,8 @@ class LIBARDOUR_API TriggerBox : public Processor
|
|||
|
||||
DataType data_type() const { return _data_type; }
|
||||
|
||||
void request_stop_all ();
|
||||
void stop_all_immediately ();
|
||||
void stop_all_quantized ();
|
||||
|
||||
TriggerPtr currently_playing() const { return _currently_playing; }
|
||||
|
||||
|
@ -644,7 +645,6 @@ class LIBARDOUR_API TriggerBox : public Processor
|
|||
static void init_pool();
|
||||
|
||||
static std::atomic<int> active_trigger_boxes;
|
||||
static PBD::Signal0<void> StopAllTriggers;
|
||||
};
|
||||
|
||||
namespace Properties {
|
||||
|
|
|
@ -1729,10 +1729,16 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams*
|
|||
}
|
||||
|
||||
void
|
||||
Route::stop_trigger (bool now)
|
||||
Route::stop_triggers (bool now)
|
||||
{
|
||||
if (_triggerbox) {
|
||||
_triggerbox->request_stop_all(); //ToDo: stop now or at end of quant?
|
||||
if (now) {
|
||||
std::cerr << "stop immedaitely\n";
|
||||
_triggerbox->stop_all_immediately ();
|
||||
} else {
|
||||
std::cerr << "stop quantized\n";
|
||||
_triggerbox->stop_all_quantized();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3686,6 +3692,8 @@ Route::realtime_handle_transport_stopped ()
|
|||
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
|
||||
(*i)->realtime_handle_transport_stopped ();
|
||||
}
|
||||
|
||||
stop_triggers (true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -215,7 +215,6 @@ Session::Session (AudioEngine &eng,
|
|||
, _writable (false)
|
||||
, _under_nsm_control (false)
|
||||
, _xrun_count (0)
|
||||
, transport_started_by_trigger (false)
|
||||
, master_wait_end (0)
|
||||
, post_export_sync (false)
|
||||
, post_export_position (0)
|
||||
|
|
|
@ -954,11 +954,7 @@ Session::process_event (SessionEvent* ev)
|
|||
break;
|
||||
|
||||
case SessionEvent::EndRoll:
|
||||
if (transport_started_by_trigger) {
|
||||
TriggerBox::start_transport_stop (*this);
|
||||
} else {
|
||||
TFSM_STOP (ev->yes_or_no, ev->second_yes_or_no);
|
||||
}
|
||||
TFSM_STOP (ev->yes_or_no, ev->second_yes_or_no);
|
||||
break;
|
||||
|
||||
case SessionEvent::SetTransportMaster:
|
||||
|
|
|
@ -438,7 +438,7 @@ Session::stop_all_triggers (bool now)
|
|||
{
|
||||
boost::shared_ptr<RouteList> rl = routes.reader();
|
||||
for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
|
||||
(*i)->stop_trigger(now);
|
||||
(*i)->stop_triggers (now);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,19 +460,10 @@ Session::stop_transport (bool abort, bool clear_state)
|
|||
void
|
||||
Session::start_transport_from_trigger ()
|
||||
{
|
||||
transport_started_by_trigger = true;
|
||||
ENSURE_PROCESS_THREAD;
|
||||
TFSM_ROLL();
|
||||
}
|
||||
|
||||
/** Called from the process thread */
|
||||
void
|
||||
Session::stop_transport_from_trigger ()
|
||||
{
|
||||
ENSURE_PROCESS_THREAD;
|
||||
TFSM_STOP (false, false);
|
||||
}
|
||||
|
||||
/** Called from the process thread */
|
||||
void
|
||||
Session::start_transport (bool after_loop)
|
||||
|
|
|
@ -500,7 +500,7 @@ Trigger::maybe_compute_next_transition (samplepos_t start_sample, Temporal::Beat
|
|||
|
||||
if (q < Temporal::BBT_Offset (0, 0, 0)) {
|
||||
/* negative quantization == do not quantize */
|
||||
std::cerr << "negative quant, start right now\n";
|
||||
|
||||
transition_samples = start_sample;
|
||||
transition_beats = start;
|
||||
transition_time = timepos_t (start);
|
||||
|
@ -1726,7 +1726,6 @@ std::atomic<int32_t> TriggerBox::_pending_scene (-1);
|
|||
std::atomic<int32_t> TriggerBox::_active_scene (-1);
|
||||
std::atomic<int> TriggerBox::active_trigger_boxes (0);
|
||||
TriggerBoxThread* TriggerBox::worker = 0;
|
||||
PBD::Signal0<void> TriggerBox::StopAllTriggers;
|
||||
|
||||
void
|
||||
TriggerBox::init ()
|
||||
|
@ -1736,16 +1735,6 @@ TriggerBox::init ()
|
|||
init_pool ();
|
||||
}
|
||||
|
||||
void
|
||||
TriggerBox::start_transport_stop (Session& s)
|
||||
{
|
||||
if (active_trigger_boxes.load ()) {
|
||||
StopAllTriggers(); /* EMIT SIGNAL */
|
||||
} else {
|
||||
s.stop_transport_from_trigger ();
|
||||
}
|
||||
}
|
||||
|
||||
TriggerBox::TriggerBox (Session& s, DataType dt)
|
||||
: Processor (s, _("TriggerBox"), Temporal::BeatTime)
|
||||
, _data_type (dt)
|
||||
|
@ -1775,8 +1764,6 @@ TriggerBox::TriggerBox (Session& s, DataType dt)
|
|||
}
|
||||
|
||||
Config->ParameterChanged.connect_same_thread (*this, boost::bind (&TriggerBox::parameter_changed, this, _1));
|
||||
|
||||
StopAllTriggers.connect_same_thread (stop_all_connection, boost::bind (&TriggerBox::request_stop_all, this));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1975,7 +1962,7 @@ TriggerBox::~TriggerBox ()
|
|||
}
|
||||
|
||||
void
|
||||
TriggerBox::request_stop_all ()
|
||||
TriggerBox::stop_all_immediately ()
|
||||
{
|
||||
_requests.stop_all = true;
|
||||
}
|
||||
|
@ -2015,6 +2002,8 @@ TriggerBox::set_all_quantization (Temporal::BBT_Offset const& q)
|
|||
void
|
||||
TriggerBox::stop_all ()
|
||||
{
|
||||
/* Stops all triggers as soon as possible */
|
||||
|
||||
/* XXX needs to be done with mutex or via thread-safe queue */
|
||||
|
||||
DEBUG_TRACE (DEBUG::Triggers, "stop-all request received\n");
|
||||
|
@ -2028,6 +2017,14 @@ TriggerBox::stop_all ()
|
|||
explicit_queue.reset ();
|
||||
}
|
||||
|
||||
void
|
||||
TriggerBox::stop_all_quantized ()
|
||||
{
|
||||
for (uint32_t n = 0; n < all_triggers.size(); ++n) {
|
||||
all_triggers[n]->unbang ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TriggerBox::drop_triggers ()
|
||||
{
|
||||
|
@ -2323,7 +2320,7 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
|||
|
||||
/* transport must be active for triggers */
|
||||
|
||||
if (!_session.transport_state_rolling()) {
|
||||
if (!_session.transport_state_rolling() && !allstop) {
|
||||
_session.start_transport_from_trigger ();
|
||||
}
|
||||
|
||||
|
@ -2497,10 +2494,6 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
|||
if (!_currently_playing) {
|
||||
DEBUG_TRACE (DEBUG::Triggers, "nothing currently playing, consider stopping transport\n");
|
||||
_stop_all = false;
|
||||
if (active_trigger_boxes.fetch_sub (1) == 1) {
|
||||
/* last active trigger box */
|
||||
_session.stop_transport_from_trigger ();
|
||||
}
|
||||
}
|
||||
|
||||
/* audio buffer (channel) count determined by max of input and
|
||||
|
|
Loading…
Reference in New Issue
Block a user