X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fcc121%2Fcc121.cc;h=8a8cfb6597d443d4f3c837be9c38d2216c92cd85;hb=ba5c14036d8a9ecb0b23400ce556612de2209149;hp=800605c9f7a31089614263318d28f80838a86883;hpb=279b19258b9e83fdfca490b44bf9964fdad8ab3b;p=ardour.git diff --git a/libs/surfaces/cc121/cc121.cc b/libs/surfaces/cc121/cc121.cc index 800605c9f7..8a8cfb6597 100644 --- a/libs/surfaces/cc121/cc121.cc +++ b/libs/surfaces/cc121/cc121.cc @@ -115,8 +115,6 @@ CC121::CC121 (Session& s) ); - StripableSelectionChanged.connect (selection_connection, MISSING_INVALIDATOR, boost::bind (&CC121::gui_track_selection_changed, this, _1), this); - /* Catch port connections and disconnections */ ARDOUR::AudioEngine::instance()->PortConnectedOrDisconnected.connect (port_connection, MISSING_INVALIDATOR, boost::bind (&CC121::connection_handler, this, _1, _2, _3, _4, _5), this); buttons.insert (std::make_pair (EButton, Button (*this, _("EButton"), EButton))); @@ -270,19 +268,12 @@ CC121::stop () void CC121::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 (); } void @@ -366,7 +357,7 @@ CC121::button_release_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb) boost::shared_ptr gain = _current_stripable->gain_control (); if (gain) { framepos_t now = session->engine().sample_time(); - gain->stop_touch (true, now); + gain->stop_touch (now); } } break; @@ -410,8 +401,8 @@ CC121::encoder_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb) if (_current_stripable) { /* Get amount of change (encoder clicks) * (change per click)*/ /*Create an exponential curve*/ - float curve = sign * pow(adj, (1.0 + 10.0) / 10.0); - adj = curve * (31 / 1000.0); + float curve = sign * powf (adj, (1.f + 10.f) / 10.f); + adj = curve * (31.f / 1000.f); ardour_pan_azimuth (adj); } break; @@ -778,13 +769,12 @@ CC121::set_state (const XMLNode& node, int version) for (XMLNodeList::const_iterator n = node.children().begin(); n != node.children().end(); ++n) { if ((*n)->name() == X_("Button")) { - XMLProperty const * prop = (*n)->property (X_("id")); - if (!prop) { + int32_t xid; + if (!node.get_property ("id", xid)) { continue; } - int xid = atoi (prop->value()); ButtonMap::iterator b = buttons.find (ButtonID (xid)); - if (b == buttons.end()) { + if (b == buttons.end ()) { continue; } b->second.set_state (**n); @@ -979,13 +969,8 @@ CC121::Button::set_led_state (boost::shared_ptr port, bool onoff) int CC121::Button::set_state (XMLNode const& node) { - const XMLProperty* prop = node.property ("id"); - if (!prop) { - return -1; - } - - int xid = atoi (prop->value()); - if (xid != id) { + int32_t xid; + if (node.get_property ("id", xid) && xid != id) { return -1; } @@ -995,16 +980,17 @@ CC121::Button::set_state (XMLNode const& node) state_pairs.push_back (make_pair (string ("plain"), ButtonState (0))); for (vector::const_iterator sp = state_pairs.begin(); sp != state_pairs.end(); ++sp) { - string propname; + string prop_name; + string prop_value; - propname = sp->first + X_("-press"); - if ((prop = node.property (propname)) != 0) { - set_action (prop->value(), true, sp->second); + prop_name = sp->first + X_("-press"); + if (node.get_property (prop_name.c_str(), prop_value)) { + set_action (prop_value, true, sp->second); } - propname = sp->first + X_("-release"); - if ((prop = node.property (propname)) != 0) { - set_action (prop->value(), false, sp->second); + prop_name = sp->first + X_("-release"); + if (node.get_property (prop_name.c_str(), prop_value)) { + set_action (prop_value, false, sp->second); } } @@ -1015,10 +1001,8 @@ XMLNode& CC121::Button::get_state () const { XMLNode* node = new XMLNode (X_("Button")); - char buf[16]; - snprintf (buf, sizeof (buf), "%d", id); - node->add_property (X_("id"), buf); + node->set_property (X_("id"), (int32_t)id); ToDoMap::const_iterator x; ToDo null; @@ -1032,13 +1016,13 @@ CC121::Button::get_state () const for (vector::const_iterator sp = state_pairs.begin(); sp != state_pairs.end(); ++sp) { if ((x = on_press.find (sp->second)) != on_press.end()) { if (x->second.type == NamedAction) { - node->add_property (string (sp->first + X_("-press")).c_str(), x->second.action_name); + node->set_property (string (sp->first + X_("-press")).c_str(), x->second.action_name); } } if ((x = on_release.find (sp->second)) != on_release.end()) { if (x->second.type == NamedAction) { - node->add_property (string (sp->first + X_("-release")).c_str(), x->second.action_name); + node->set_property (string (sp->first + X_("-release")).c_str(), x->second.action_name); } } } @@ -1047,15 +1031,9 @@ CC121::Button::get_state () const } void -CC121::gui_track_selection_changed (StripableNotificationListPtr stripables) +CC121::stripable_selection_changed () { - boost::shared_ptr r; - - if (!stripables->empty()) { - r = stripables->front().lock(); - } - - set_current_stripable (r); + set_current_stripable (first_selected_stripable()); } void