latched rec-enable
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 19 Jan 2006 00:03:55 +0000 (00:03 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 19 Jan 2006 00:03:55 +0000 (00:03 +0000)
git-svn-id: svn://localhost/trunk/ardour2@277 d708f5d6-7413-0410-9779-e7cbd77b26cf

14 files changed:
gtk2_ardour/ardour.menus
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/ardour_ui_options.cc
gtk2_ardour/route_ui.cc
gtk2_ardour/streamview.cc
libs/ardour/ardour/configuration.h
libs/ardour/ardour/session.h
libs/ardour/configuration.cc
libs/ardour/session.cc
libs/ardour/session_midi.cc
libs/ardour/session_state.cc
libs/ardour/session_transport.cc

index 67d9aca46264479babc5a6ad2ea9daa02c2dc556..4874eddc2ad451f3e56c1748c1122621139f156a 100644 (file)
                <separator/>
                <menuitem action='StopPluginsWithTransport'/>
                <menuitem action='DoNotRunPluginsWhileRecording'/>
+               <menuitem action='LatchedRecordEnable'/>
                <separator/>
                <menuitem action='VerifyRemoveLastCapture'/>
                <menuitem action='StopRecordingOnXrun'/>
index de23ebdcc3981fda84db6ee8054000c6251e218f..686652c4eb9e055e6cebddc333749a5235d3ad3f 100644 (file)
@@ -1052,7 +1052,7 @@ ARDOUR_UI::transport_record ()
                        break;
                case Session::Recording:
                case Session::Enabled:
-                       session->disable_record ();
+                       session->disable_record (true);
                }
        }
 }
index e5f7f4d96e8e124b4bc97f791bed6d8ada18c15e..f0637ad535a77a0e27f04e6e54472218c358898e 100644 (file)
@@ -690,6 +690,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI
        void toggle_SoloViaBus();
        void toggle_AutomaticallyCreateCrossfades();
        void toggle_UnmuteNewFullCrossfades();
+       void toggle_LatchedRecordEnable ();
 
        void mtc_port_changed ();
        void map_some_session_state (const char* group, const char* action, bool (ARDOUR::Session::*get)() const);
index d10683ec9ed227607fe355fb54e76d2f41e9ee13..b065f55a063ae6deedae9c49a76d9296a878821d 100644 (file)
@@ -380,6 +380,8 @@ ARDOUR_UI::install_actions ()
        ActionManager::session_sensitive_actions.push_back (act);
        act = ActionManager::register_toggle_action (option_actions, X_("DoNotRunPluginsWhileRecording"), _("Do not run plugins while recording"), mem_fun (*this, &ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording));
        ActionManager::session_sensitive_actions.push_back (act);
+
+       ActionManager::register_toggle_action (option_actions, X_("LatchedRecordEnable"), _("Rec-enable stays engaged at stop"), mem_fun (*this, &ARDOUR_UI::toggle_LatchedRecordEnable));
        
        act = ActionManager::register_toggle_action (option_actions, X_("VerifyRemoveLastCapture"), _("Verify remove last capture"), mem_fun (*this, &ARDOUR_UI::toggle_VerifyRemoveLastCapture));
        ActionManager::session_sensitive_actions.push_back (act);
index 5a15bd7de3b9b5c8b42a580b7f5e6d97decec036..14b385e175da60cf463bc99207d488c05e45fd11 100644 (file)
@@ -239,6 +239,13 @@ ARDOUR_UI::toggle_StopPluginsWithTransport()
 {
        toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport);
 }
+
+void
+ARDOUR_UI::toggle_LatchedRecordEnable()
+{
+       toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable);
+}
+
 void
 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
 {
index ed93c55811dc5aedf0943d0621fa54f8f58134b9..e974b88a97f63aff45042b91a1f36287f521c429 100644 (file)
@@ -76,8 +76,7 @@ RouteUI::RouteUI (ARDOUR::Route& rt, ARDOUR::Session& sess, const char* m_name,
 
                get_diskstream()->record_enable_changed.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed));
 
-               _session.RecordEnabled.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed));
-               _session.RecordDisabled.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed));
+               _session.RecordStateChanged.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed));
 
                rec_enable_button = manage (new BindableToggleButton (& at->midi_rec_enable_control(), r_name ));
                rec_enable_button->set_bind_button_state (2, GDK_CONTROL_MASK);
index a8b7499644cc2d1163619364b998e8add9296483..e661b5d49c6fd4e33f854fd128159966e7590594 100644 (file)
@@ -82,8 +82,7 @@ StreamView::StreamView (AudioTimeAxisView& tv)
                _trackview.audio_track()->diskstream_changed.connect (mem_fun (*this, &StreamView::diskstream_changed));
                _trackview.session().TransportStateChange.connect (mem_fun (*this, &StreamView::transport_changed));
                _trackview.get_diskstream()->record_enable_changed.connect (mem_fun (*this, &StreamView::rec_enable_changed));
-               _trackview.session().RecordEnabled.connect (mem_fun (*this, &StreamView::sess_rec_enable_changed));
-               _trackview.session().RecordDisabled.connect (mem_fun (*this, &StreamView::sess_rec_enable_changed));
+               _trackview.session().RecordStateChanged.connect (mem_fun (*this, &StreamView::sess_rec_enable_changed));
        } 
 
        rec_updating = false;
index fd44d273292858255cd5f731957ab45e2066ab96..c0a1301318802ee31dcb900ef6e603dc315d90b4 100644 (file)
@@ -64,6 +64,9 @@ class Configuration : public Stateful
        XMLNode * get_keys() const;
        void set_keys(XMLNode *);
 
+       void set_latched_record_enable (bool yn);
+       bool get_latched_record_enable();
+
        void set_use_vst (bool yn);
        bool get_use_vst();
 
@@ -243,6 +246,8 @@ class Configuration : public Stateful
        bool          quieten_at_speed_is_user;
        uint32_t      midi_feedback_interval_ms;
        bool          midi_feedback_interval_ms_is_user;
+       bool          latched_record_enable;
+       bool          latched_record_enable_is_user;
 
        XMLNode *key_node;
        bool     user_configuration;
index 2bdd99c614c208001a4c47c59bbdcf499afa0ffd..297ce0d94a2e1bd651a41d1699bafa2c65084286 100644 (file)
@@ -317,7 +317,7 @@ class Session : public sigc::trackable, public Stateful
 
        bool record_enabling_legal () const;
        void maybe_enable_record ();
-       void disable_record ();
+       void disable_record (bool force = false);
        void step_back_from_record ();
        
        sigc::signal<void> going_away;
@@ -332,8 +332,7 @@ class Session : public sigc::trackable, public Stateful
        
        /* Record status signals */
 
-        sigc::signal<void> RecordEnabled;
-       sigc::signal<void> RecordDisabled;
+        sigc::signal<void> RecordStateChanged;
 
        /* Transport mechanism signals */
 
index 28f13aabb8442281a361ac5f06f4171379c2b87d..61d288ab51d1af1fcc751b8c7e38e31179f731fd 100644 (file)
@@ -291,6 +291,9 @@ Configuration::state (bool user_only)
                snprintf (buf, sizeof (buf), "%f", speed_quietning);
                node->add_child_nocopy(option_node("quieten-at-speed", buf));
        }
+       if (!user_only || latched_record_enable_is_user) {
+               node->add_child_nocopy(option_node("latched-record-enable", latched_record_enable?"yes":"no"));
+       }
 
        /* use-vst is always per-user */
        node->add_child_nocopy (option_node ("use-vst", use_vst?"yes":"no"));
@@ -431,6 +434,8 @@ Configuration::set_state (const XMLNode& root)
                                        }
                                } else if (option_name == "midi-feedback-interval-ms") {
                                        set_midi_feedback_interval_ms (atoi (option_value.c_str()));
+                               } else if (option_name == "latched-record-enable") {
+                                       set_latched_record_enable (option_value == "yes");
                                }
                        }
                        
@@ -526,6 +531,7 @@ Configuration::set_defaults ()
        timecode_source_is_synced_is_user = false;
        quieten_at_speed_is_user = false;
        midi_feedback_interval_ms_is_user = false;
+       latched_record_enable_is_user = false;
 }
 
 Configuration::MidiPortDescriptor::MidiPortDescriptor (const XMLNode& node)
@@ -1130,3 +1136,18 @@ Configuration::set_quieten_at_speed (float gain_coefficient)
                quieten_at_speed_is_user = true;
        }
 }
+
+void
+Configuration::set_latched_record_enable (bool yn)
+{
+       latched_record_enable = yn;
+       if (user_configuration) {
+               latched_record_enable_is_user = true;
+       }
+}
+
+bool
+Configuration::get_latched_record_enable ()
+{
+       return latched_record_enable;
+}
index bcc7c13bb5302d477c9647a10122a94f99405f1f..90458fa2fdab38b4c661a08c6231e8b1bc4ef2a6 100644 (file)
@@ -1249,21 +1249,30 @@ Session::enable_record ()
                        
                        for (DiskStreamList::iterator i = diskstreams.begin(); i != diskstreams.end(); ++i) {
                                if ((*i)->record_enabled ()) {
-                                       //cerr << "switching to input" << __FILE__ << __LINE__ << endl << endl;
                                        (*i)->monitor_input (true);   
                                }
                        }
                }
 
-               RecordEnabled ();
+               RecordStateChanged ();
        }
 }
 
 void
-Session::disable_record ()
+Session::disable_record (bool force)
 {
-       if (atomic_read (&_record_status) != Disabled) {
-               atomic_set (&_record_status, Disabled);
+       RecordState rs;
+
+       if ((rs = (RecordState) atomic_read (&_record_status)) != Disabled) {
+
+               if (!Config->get_latched_record_enable () || force) {
+                       atomic_set (&_record_status, Disabled);
+               } else {
+                       if (rs == Recording) {
+                               atomic_set (&_record_status, Enabled);
+                       }
+               }
+
                send_mmc_in_another_thread (MIDI::MachineControl::cmdRecordExit);
 
                if (Config->get_use_hardware_monitoring() && auto_input) {
@@ -1275,15 +1284,13 @@ Session::disable_record ()
                        
                        for (DiskStreamList::iterator i = diskstreams.begin(); i != diskstreams.end(); ++i) {
                                if ((*i)->record_enabled ()) {
-                                       //cerr << "switching from input" << __FILE__ << __LINE__ << endl << endl;
                                        (*i)->monitor_input (false);   
                                }
                        }
                }
                
-               RecordDisabled ();
+               RecordStateChanged (); /* emit signal */
                remove_pending_capture_state ();
-
        }
 }
 
@@ -1321,7 +1328,7 @@ Session::maybe_enable_record ()
                } 
        } else {
                send_mmc_in_another_thread (MIDI::MachineControl::cmdRecordPause);
-               RecordEnabled (); /* EMIT SIGNAL */
+               RecordStateChanged (); /* EMIT SIGNAL */
        }
 
        set_dirty();
index f793dba956ec36885c057d7e17efd264117c1f36..2b7afa354aa6cda898ff0544feb48d7397596bf4 100644 (file)
@@ -623,7 +623,7 @@ Session::mmc_record_strobe (MIDI::MachineControl &mmc)
                
                save_state ("", true);
                atomic_set (&_record_status, Enabled);
-               RecordEnabled (); /* EMIT SIGNAL */
+               RecordStateChanged (); /* EMIT SIGNAL */
                
                request_transport_speed (1.0);
 
index d580680f637d077e41a6e99a88b01bf526d5251a..09834fa27a99f6203979ed832409caa27e4cfe20 100644 (file)
@@ -1242,7 +1242,6 @@ Session::get_template()
        
        disable_record ();
 
-       cerr << "STart get template\n";
        return state(false);
 }
 
index 096267d0dd30f0a0c3e560dcb217dda1a295409f..e2a9f2389009f5a30e512211cff6cd1c9e6c2983 100644 (file)
@@ -386,8 +386,18 @@ Session::non_realtime_stop (bool abort)
        deliver_mmc (MIDI::MachineControl::cmdLocate, _transport_frame);
 
        if (did_record) {
-               atomic_set (&_record_status, Disabled);
-               RecordDisabled (); /* EMIT SIGNAL */
+
+               /* XXX its a little odd that we're doing this here
+                  when realtime_stop(), which has already executed,
+                  will have done this.
+               */
+
+               if (!Config->get_latched_record_enable()) {
+                       atomic_set (&_record_status, Disabled);
+               } else {
+                       atomic_set (&_record_status, Enabled);
+               }
+               RecordStateChanged (); /* emit signal */
        }
        
        if ((post_transport_work & PostTransportLocate) && get_record_enabled()) {