From 2d60a69c2d3e1efa8fa4e5bdff151f1923f1aec7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 5 Aug 2017 01:27:41 +0200 Subject: Consolidate ctrl surface code --- libs/ardour/midi_ui.cc | 9 +-------- libs/surfaces/cc121/cc121.cc | 9 +-------- libs/surfaces/faderport/faderport.cc | 9 +-------- libs/surfaces/faderport8/faderport8.cc | 9 +-------- libs/surfaces/mackie/mackie_control_protocol.cc | 9 +-------- libs/surfaces/push2/push2.cc | 9 +-------- libs/surfaces/tranzport/init.cc | 8 ++------ 7 files changed, 8 insertions(+), 54 deletions(-) (limited to 'libs') diff --git a/libs/ardour/midi_ui.cc b/libs/ardour/midi_ui.cc index eaacde2969..11ab77a851 100644 --- a/libs/ardour/midi_ui.cc +++ b/libs/ardour/midi_ui.cc @@ -144,19 +144,12 @@ MidiControlUI::reset_ports () void MidiControlUI::thread_init () { - struct sched_param rtparam; - pthread_set_name (X_("midiUI")); PBD::notify_event_loops_about_thread_creation (pthread_self(), X_("midiUI"), 2048); SessionEvent::create_per_thread_pool (X_("midiUI"), 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 (); reset_ports (); } diff --git a/libs/surfaces/cc121/cc121.cc b/libs/surfaces/cc121/cc121.cc index b00fbbb541..8a8cfb6597 100644 --- a/libs/surfaces/cc121/cc121.cc +++ b/libs/surfaces/cc121/cc121.cc @@ -268,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 diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 4984c73b06..72190c1e8a 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -286,19 +286,12 @@ FaderPort::stop () void FaderPort::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 diff --git a/libs/surfaces/faderport8/faderport8.cc b/libs/surfaces/faderport8/faderport8.cc index 9b35578255..0ba8ae422a 100644 --- a/libs/surfaces/faderport8/faderport8.cc +++ b/libs/surfaces/faderport8/faderport8.cc @@ -210,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 diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 3d011c1bb6..064d763d1e 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -184,19 +184,12 @@ MackieControlProtocol::~MackieControlProtocol() void MackieControlProtocol::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 diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index d884869048..b14513b30b 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -849,19 +849,12 @@ Push2::handle_midi_pitchbend_message (MIDI::Parser&, MIDI::pitchbend_t pb) void Push2::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 diff --git a/libs/surfaces/tranzport/init.cc b/libs/surfaces/tranzport/init.cc index 1e284b5831..96ff493c0e 100644 --- a/libs/surfaces/tranzport/init.cc +++ b/libs/surfaces/tranzport/init.cc @@ -43,16 +43,12 @@ TranzportControlProtocol::~TranzportControlProtocol () int TranzportControlProtocol::rtpriority_set(int priority) { - struct sched_param rtparam; - int err; char *a = (char*) alloca(4096*2); a[0] = 'a'; a[4096] = 'b'; - memset (&rtparam, 0, sizeof (rtparam)); - rtparam.sched_priority = priority; /* XXX should be relative to audio (JACK) thread */ // Note - try SCHED_RR with a low limit // - we don't care if we can't write everything this ms // and it will help if we lose the device - if ((err = pthread_setschedparam (pthread_self(), SCHED_FIFO, &rtparam)) != 0) { - PBD::info << string_compose (_("%1: thread not running with realtime scheduling (%2)"), name(), strerror (errno)) << endmsg; + if (set_thread_priority (SCHED_FIFO, priority)) { + PBD::info << string_compose (_("%1: thread not running with realtime scheduling."), name(), strerror (errno)) << endmsg; return 1; } return 0; -- cgit v1.2.3