From df659e91f1ad8b5d71838abc130dce8eacdf7cc1 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 29 Aug 2017 17:23:19 +0200 Subject: Consolidate _realtime_pthread_create() into libpbd. --- libs/backends/coreaudio/coreaudio_backend.cc | 4 +- libs/backends/coreaudio/rt_thread.h | 55 ---------------------------- 2 files changed, 2 insertions(+), 57 deletions(-) delete mode 100644 libs/backends/coreaudio/rt_thread.h (limited to 'libs/backends/coreaudio') diff --git a/libs/backends/coreaudio/coreaudio_backend.cc b/libs/backends/coreaudio/coreaudio_backend.cc index f9dd15ea8d..3e4a38e7a3 100644 --- a/libs/backends/coreaudio/coreaudio_backend.cc +++ b/libs/backends/coreaudio/coreaudio_backend.cc @@ -27,11 +27,11 @@ #include #include "coreaudio_backend.h" -#include "rt_thread.h" #include "pbd/compose.h" #include "pbd/error.h" #include "pbd/file_utils.h" +#include "pbd/pthread_utils.h" #include "ardour/filesystem_paths.h" #include "ardour/port_manager.h" #include "pbd/i18n.h" @@ -859,7 +859,7 @@ CoreAudioBackend::create_process_thread (boost::function func) ThreadData* td = new ThreadData (this, func, stacksize); - if (_realtime_pthread_create (SCHED_FIFO, -22, stacksize, + if (pbd_realtime_pthread_create (SCHED_FIFO, -22, stacksize, &thread_id, coreaudio_process_thread, td)) { pthread_attr_init (&attr); pthread_attr_setstacksize (&attr, stacksize); diff --git a/libs/backends/coreaudio/rt_thread.h b/libs/backends/coreaudio/rt_thread.h deleted file mode 100644 index 3d2efe2063..0000000000 --- a/libs/backends/coreaudio/rt_thread.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2014 Robin Gareus - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __libbackend_alsa_rthread_h__ -#define __libbackend_alsa_rthread_h__ - -#include -#include - -static int -_realtime_pthread_create ( - const int policy, int priority, const size_t stacksize, - pthread_t *thread, - void *(*start_routine) (void *), - void *arg) -{ - int rv; - - pthread_attr_t attr; - struct sched_param parm; - - const int p_min = sched_get_priority_min (policy); - const int p_max = sched_get_priority_max (policy); - priority += p_max; - if (priority > p_max) priority = p_max; - if (priority < p_min) priority = p_min; - parm.sched_priority = priority; - - pthread_attr_init (&attr); - pthread_attr_setschedpolicy (&attr, policy); - pthread_attr_setschedparam (&attr, &parm); - pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM); - pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED); - pthread_attr_setstacksize (&attr, stacksize); - rv = pthread_create (thread, &attr, start_routine, arg); - pthread_attr_destroy (&attr); - return rv; -} - -#endif -- cgit v1.2.3