use constructor syntax
[ardour.git] / libs / surfaces / faderport8 / faderport8.cc
index a812e1a4d753b8d3f9af181d7549840e4a7c869d..c3e4a20a9a4192e4315d6533264d8c9ce9335d8b 100644 (file)
@@ -155,6 +155,7 @@ FaderPort8::~FaderPort8 ()
 
        if (_input_port) {
                DEBUG_TRACE (DEBUG::FaderPort8, string_compose ("unregistering input port %1\n", boost::shared_ptr<ARDOUR::Port>(_input_port)->name()));
+               Glib::Threads::Mutex::Lock em (AudioEngine::instance()->process_lock());
                AudioEngine::instance()->unregister_port (_input_port);
                _input_port.reset ();
        }
@@ -164,6 +165,7 @@ FaderPort8::~FaderPort8 ()
        if (_output_port) {
                _output_port->drain (10000,  250000); /* check every 10 msecs, wait up to 1/4 second for the port to drain */
                DEBUG_TRACE (DEBUG::FaderPort8, string_compose ("unregistering output port %1\n", boost::shared_ptr<ARDOUR::Port>(_output_port)->name()));
+               Glib::Threads::Mutex::Lock em (AudioEngine::instance()->process_lock());
                AudioEngine::instance()->unregister_port (_output_port);
                _output_port.reset ();
        }
@@ -208,19 +210,12 @@ FaderPort8::stop ()
 void
 FaderPort8::thread_init ()
 {
-       struct sched_param rtparam;
-
        pthread_set_name (event_loop_name().c_str());
 
        PBD::notify_event_loops_about_thread_creation (pthread_self(), event_loop_name(), 2048);
        ARDOUR::SessionEvent::create_per_thread_pool (event_loop_name(), 128);
 
-       memset (&rtparam, 0, sizeof (rtparam));
-       rtparam.sched_priority = 9; /* XXX should be relative to audio (JACK) thread */
-
-       if (pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam) != 0) {
-               // do we care? not particularly.
-       }
+       set_thread_priority ();
 }
 
 bool
@@ -235,7 +230,7 @@ FaderPort8::periodic ()
                _timecode = Timecode::timecode_format_time(TC);
 
                char buf[16];
-               Timecode::BBT_Time BBT = session->tempo_map ().bbt_at_frame (session->transport_frame ());
+               Timecode::BBT_Time BBT = session->tempo_map ().bbt_at_sample (session->transport_sample ());
                snprintf (buf, sizeof (buf),
                                " %02" PRIu32 "|%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32,
                                BBT.bars % 100, BBT.beats %100,
@@ -484,7 +479,7 @@ FaderPort8::midi_input_handler (Glib::IOCondition ioc, boost::weak_ptr<ARDOUR::A
 #ifdef VERBOSE_DEBUG
                DEBUG_TRACE (DEBUG::FaderPort8, string_compose ("data available on %1\n", boost::shared_ptr<MIDI::Port>(port)->name()));
 #endif
-               framepos_t now = session->engine().sample_time();
+               samplepos_t now = session->engine().sample_time();
                port->parse (now);
        }
 
@@ -1638,6 +1633,18 @@ FaderPort8::select_strip (boost::weak_ptr<Stripable> ws)
                return;
        }
 #if 1 /* single exclusive selection by default, toggle via shift */
+
+# if 1 /* selecting a selected strip -> move fader to unity */
+       if (s == first_selected_stripable () && !shift_mod ()) {
+               if (_ctrls.fader_mode () == ModeTrack) {
+                       boost::shared_ptr<AutomationControl> ac = s->gain_control ();
+                       ac->start_touch (ac->session().transport_sample());
+                       ac->set_value (ac->normal (), PBD::Controllable::UseGroup);
+               }
+               return;
+       }
+# endif
+
        if (shift_mod ()) {
                ToggleStripableSelection (s);
        } else {