Only make record button solid red (and big clock red) when things are actually being...
authorCarl Hetherington <carl@carlh.net>
Wed, 29 Apr 2009 17:30:35 +0000 (17:30 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 29 Apr 2009 17:30:35 +0000 (17:30 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@5012 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
libs/ardour/ardour/session.h
libs/ardour/session.cc

index 838588487b3d609d4f139c1265e9a982a902f892..ce435c4ad540717bd266f31d40835bc7a9feaf88 100644 (file)
@@ -1957,23 +1957,20 @@ ARDOUR_UI::transport_rec_enable_blink (bool onoff)
        if (session == 0) {
                return;
        }
+
+       Session::RecordState const r = session->record_status ();
+       bool const h = session->have_rec_enabled_diskstream ();
        
-       switch (session->record_status()) {
-       case Session::Enabled:
+       if (r == Session::Enabled || (r == Session::Recording && !h)) {
                if (onoff) {
                        rec_button.set_visual_state (2);
                } else {
                        rec_button.set_visual_state (0);
                }
-               break;
-
-       case Session::Recording:
+       } else if (r == Session::Recording && h) {
                rec_button.set_visual_state (1);
-               break;
-
-       default:
+       } else {
                rec_button.set_visual_state (0);
-               break;
        }
 }
 
@@ -3175,13 +3172,13 @@ ARDOUR_UI::record_state_changed ()
                return;
        }
 
-       switch (session->record_status()) {
-       case Session::Recording:
+       Session::RecordState const r = session->record_status ();
+       bool const h = session->have_rec_enabled_diskstream ();
+       
+       if (r == Session::Recording && h)  {
                big_clock.set_widget_name ("BigClockRecording");
-               break;
-       default:
+        } else {
                big_clock.set_widget_name ("BigClockNonRecording");
-               break;
        }
 }
 
index ce299284689c68c1a24455fbf30f50b94d652f67..ce238fbc2e1858efd28a112d844f2b5b10d2364e 100644 (file)
@@ -292,6 +292,7 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        void add_diskstream (boost::shared_ptr<Diskstream>);
        boost::shared_ptr<Diskstream> diskstream_by_id (const PBD::ID& id);
        boost::shared_ptr<Diskstream> diskstream_by_name (string name);
+       bool have_rec_enabled_diskstream () const;
 
        bool have_captured() const { return _have_captured; }
 
@@ -1742,6 +1743,9 @@ class Session : public PBD::StatefulDestructible, public boost::noncopyable
        SessionMetadata * _metadata;
 
        mutable bool have_looped; ///< Used in ::audible_frame(*)
+
+       void update_have_rec_enabled_diskstream ();
+       gint _have_rec_enabled_diskstream;
 };
 
 } // namespace ARDOUR
index fdb396d902a992cce5583b6743d3060f748e8002..c5904de869835dc49ad9493bb7cf835331f67e79 100644 (file)
@@ -140,7 +140,8 @@ Session::Session (AudioEngine &eng,
          click_data (0),
          click_emphasis_data (0),
          main_outs (0),
-         _metadata (new SessionMetadata())
+         _metadata (new SessionMetadata()),
+         _have_rec_enabled_diskstream (false)
 
 {
        bool new_session;
@@ -223,7 +224,8 @@ Session::Session (AudioEngine &eng,
          click_data (0),
          click_emphasis_data (0),
          main_outs (0),
-         _metadata (new SessionMetadata())
+         _metadata (new SessionMetadata()),
+         _have_rec_enabled_diskstream (false)
 {
        bool new_session;
 
@@ -2141,6 +2143,8 @@ Session::add_diskstream (boost::shared_ptr<Diskstream> dstream)
        /* this will connect to future changes, and check the current length */
        diskstream_playlist_changed (dstream);
 
+       dstream->RecordEnableChanged.connect (mem_fun (*this, &Session::update_have_rec_enabled_diskstream));
+
        dstream->prepare ();
 
 }
@@ -4325,3 +4329,28 @@ Session::sync_order_keys (const char* base)
 }
 
 
+/** @return true if there is at least one record-enabled diskstream, otherwise false */
+bool
+Session::have_rec_enabled_diskstream () const
+{
+       return g_atomic_int_get (&_have_rec_enabled_diskstream) == 1;
+}
+
+/** Update the state of our rec-enabled diskstreams flag */
+void
+Session::update_have_rec_enabled_diskstream ()
+{
+       boost::shared_ptr<DiskstreamList> dsl = diskstreams.reader ();
+       DiskstreamList::iterator i = dsl->begin ();
+       while (i != dsl->end () && (*i)->record_enabled () == false) {
+               ++i;
+       }
+
+       int const old = g_atomic_int_get (&_have_rec_enabled_diskstream);
+
+       g_atomic_int_set (&_have_rec_enabled_diskstream, i != dsl->end () ? 1 : 0);
+
+       if (g_atomic_int_get (&_have_rec_enabled_diskstream) != old) {
+               RecordStateChanged (); /* EMIT SIGNAL */
+       }
+}