Merging from trunk
[ardour.git] / libs / ardour / ardour / io.h
index c67473dcc0e2f0dc0219ed4d52a6e0c01bdabf0c..8ae45fe65c1b42fa28bf1ef931e955f512828f0f 100644 (file)
 #include <sigc++/signal.h>
 #include <jack/jack.h>
 
-#include <pbd/lockmonitor.h>
+#include <glibmm/thread.h>
+
 #include <pbd/fastlog.h>
 #include <pbd/undo.h>
-#include <pbd/atomic.h>
+
 #include <midi++/controllable.h>
 
 #include <ardour/ardour.h>
@@ -198,19 +199,22 @@ class IO : public Stateful, public ARDOUR::StateManager
        /* Peak metering */
 
        float peak_input_power (uint32_t n) { 
-               if (n < std::max(_ninputs, _noutputs)) {
-                       float x = _stored_peak_power[n];
-                       if(x > 0.0) {
-                               return 20 * fast_log10(x);
-                       } else {
-                               return minus_infinity();
-                       }
+               if (n < std::max (_ninputs, _noutputs)) {
+                       return _visible_peak_power[n];
                } else {
                        return minus_infinity();
                }
        }
 
-       static sigc::signal<void> GrabPeakPower;
+    static void update_meters();
+
+private: 
+
+    static sigc::signal<void>   Meter;
+    static Glib::StaticMutex    m_meter_signal_lock;
+    sigc::connection            m_meter_connection;
+
+public:
 
        /* automation */
 
@@ -266,7 +270,7 @@ class IO : public Stateful, public ARDOUR::StateManager
        int ports_became_legal ();
 
   private:
-       mutable PBD::Lock io_lock;
+       mutable Glib::Mutex io_lock;
 
   protected:
        Session&            _session;
@@ -274,11 +278,11 @@ class IO : public Stateful, public ARDOUR::StateManager
        gain_t              _gain;
        gain_t              _effective_gain;
        gain_t              _desired_gain;
-       PBD::NonBlockingLock declick_lock;
+       Glib::Mutex         declick_lock;
        vector<Port*>       _outputs;
        vector<Port*>       _inputs;
        vector<float>       _peak_power;
-       vector<float>       _stored_peak_power;
+       vector<float>       _visible_peak_power;
        string              _name;
        Connection*         _input_connection;
        Connection*         _output_connection;
@@ -317,7 +321,6 @@ class IO : public Stateful, public ARDOUR::StateManager
 
        Change               restore_state (State&);
        StateManager::State* state_factory (std::string why) const;
-       void                 send_state_changed();
 
        bool get_midi_node_info (XMLNode * node, MIDI::eventType & ev, MIDI::channel_t & chan, MIDI::byte & additional);
        bool set_midi_node_info (XMLNode * node, MIDI::eventType ev, MIDI::channel_t chan, MIDI::byte additional);
@@ -327,7 +330,7 @@ class IO : public Stateful, public ARDOUR::StateManager
        jack_nframes_t last_automation_snapshot;
        static jack_nframes_t _automation_interval;
 
-        AutoState      _gain_automation_state;
+    AutoState      _gain_automation_state;
        AutoStyle      _gain_automation_style;
 
        bool     apply_gain_automation;
@@ -336,7 +339,7 @@ class IO : public Stateful, public ARDOUR::StateManager
        int  save_automation (const string&);
        int  load_automation (const string&);
        
-       PBD::NonBlockingLock automation_lock;
+       Glib::Mutex automation_lock;
 
        /* AudioTrack::deprecated_use_diskstream_connections() needs these */
 
@@ -394,7 +397,7 @@ class IO : public Stateful, public ARDOUR::StateManager
        int make_connections (const XMLNode&);
 
        void setup_peak_meters ();
-       void grab_peak_power ();
+       void meter ();
 
        bool ensure_inputs_locked (uint32_t, bool clear, void *src);
        bool ensure_outputs_locked (uint32_t, bool clear, void *src);