r229@gwythaint (orig r769): fugalh | 2006-08-09 08:15:05 -0600
[ardour.git] / libs / ardour / track.cc
index 709e76f5e1ad174ae05c257c7cf28372fe6feca7..941524b54cf03b92477b84b9cc36f841c7d3a7f9 100644 (file)
@@ -31,6 +31,7 @@
 #include <ardour/audioplaylist.h>
 #include <ardour/panner.h>
 #include <ardour/utils.h>
+#include <ardour/connection.h>
 
 #include "i18n.h"
 
@@ -146,6 +147,18 @@ Track::record_enabled () const
 {
        return _diskstream->record_enabled ();
 }
+
+bool
+Track::can_record()
+{
+       bool will_record = true;
+       for (int i = 0; i < _inputs.size() && will_record; i++) {
+               if (!_inputs[i]->connected())
+                       will_record = false;
+       }
+
+       return will_record;
+}
        
 void
 Track::set_record_enable (bool yn, void *src)
@@ -159,8 +172,13 @@ Track::set_record_enable (bool yn, void *src)
                return;
        }
 
-       /* keep track of the meter point as it was before we rec-enabled */
+       // Do not set rec enabled if the track can't record.
+       if (yn && !can_record()) {
+               error << string_compose( _("Can not arm track '%1'. Check the input connections"), name() ) << endmsg;
+               return;
+       }
 
+       /* keep track of the meter point as it was before we rec-enabled */
        if (!_diskstream->record_enabled()) {
                _saved_meter_point = _meter_point;
        }