[DEV] update thread set priority

This commit is contained in:
Edouard DUPIN 2015-03-20 21:07:58 +01:00
parent e873a44615
commit 102a4e5ca5
6 changed files with 9 additions and 34 deletions

View File

@ -13,6 +13,7 @@
#include <airtaudio/Interface.h>
#include <airtaudio/debug.h>
#include <etk/stdTools.h>
#include <etk/thread/tools.h>
#include <limits.h>
#include <airtaudio/api/Alsa.h>
@ -827,33 +828,7 @@ bool airtaudio::api::Alsa::probeDeviceOpenName(const std::string& _deviceName,
ATA_ERROR("creating callback thread!");
goto error;
}
int retcode;
int policy;
pthread_t threadID = (pthread_t) m_private->thread->native_handle();
struct sched_param param;
if ((retcode = pthread_getschedparam(threadID, &policy, &param)) != 0) {
ATA_ERROR("pthread_getschedparam " << retcode);
} else {
ATA_WARNING("INHERITED: ");
ATA_WARNING(" policy=" << ((policy == SCHED_FIFO) ? "SCHED_FIFO" :
(policy == SCHED_RR) ? "SCHED_RR" :
(policy == SCHED_OTHER) ? "SCHED_OTHER" :
"???") );
ATA_WARNING(" priority=" << param.sched_priority);
}
policy = SCHED_FIFO;
param.sched_priority = 6;
if ((retcode = pthread_setschedparam(threadID, policy, &param)) != 0) {
ATA_ERROR("pthread_setschedparam " << retcode);
} else {
ATA_WARNING("Change: ");
ATA_WARNING(" policy=" << ((policy == SCHED_FIFO) ? "SCHED_FIFO" :
(policy == SCHED_RR) ? "SCHED_RR" :
(policy == SCHED_OTHER) ? "SCHED_OTHER" :
"???") );
ATA_WARNING(" priority=" << param.sched_priority);
}
etk::thread::setPriority(*m_private->thread, -6);
}
return true;
error:
@ -1069,7 +1044,7 @@ void airtaudio::api::Alsa::alsaCallbackEvent(void *_userData) {
}
void airtaudio::api::Alsa::callbackEvent() {
etk::log::setThreadName("Alsa IO-" + m_name);
etk::thread::setName("Alsa IO-" + m_name);
while (m_private->threadRunning == true) {
callbackEventOneCycle();
}

View File

@ -1003,7 +1003,7 @@ enum airtaudio::error airtaudio::api::Core::abortStream() {
// callbackEvent() function probably should return before the AudioDeviceStop()
// function is called.
void airtaudio::api::Core::coreStopStream(void *_userData) {
etk::log::setThreadName("CoreAudio_stopStream");
etk::thread::setName("CoreAudio_stopStream");
airtaudio::api::Core* myClass = reinterpret_cast<airtaudio::api::Core*>(_userData);
myClass->stopStream();
}

View File

@ -1328,7 +1328,7 @@ unlock:
}
void airtaudio::api::Ds::dsCallbackEvent(void *_userData) {
etk::log::setThreadName("DS IO-" + m_name);
etk::thread::setName("DS IO-" + m_name);
airtaudio::api::Ds* myClass = reinterpret_cast<airtaudio::api::Ds*>(_userData);
while (myClass->m_private->threadRunning == true) {
myClass->callbackEvent();

View File

@ -231,7 +231,7 @@ int32_t airtaudio::api::Jack::jackCallbackHandler(jack_nframes_t _nframes, void*
// it this way because the jackShutdown() function must return before
// the jack_deactivate() function (in closeStream()) will return.
void airtaudio::api::Jack::jackCloseStream(void* _userData) {
etk::log::setThreadName("Jack_closeStream");
etk::thread::setName("Jack_closeStream");
airtaudio::api::Jack* myClass = reinterpret_cast<airtaudio::api::Jack*>(_userData);
myClass->closeStream();
}
@ -623,7 +623,7 @@ enum airtaudio::error airtaudio::api::Jack::abortStream() {
// callbackEvent() function must return before the jack_deactivate()
// function will return.
static void jackStopStream(void* _userData) {
etk::log::setThreadName("Jack_stopStream");
etk::thread::setName("Jack_stopStream");
airtaudio::api::Jack* myClass = reinterpret_cast<airtaudio::api::Jack*>(_userData);
myClass->stopStream();
}

View File

@ -818,7 +818,7 @@ unlock:
}
static void ossCallbackHandler(void* _userData) {
etk::log::setThreadName("OSS callback-" + m_name);
etk::thread::setName("OSS callback-" + m_name);
airtaudio::api::Alsa* myClass = reinterpret_cast<airtaudio::api::Oss*>(_userData);
while (myClass->m_private->threadRunning == true) {
myClass->callbackEvent();

View File

@ -106,7 +106,7 @@ static void pulseaudio_callback(void* _userData) {
}
void airtaudio::api::Pulse::callbackEvent() {
etk::log::setThreadName("Pulse IO-" + m_name);
etk::thread::setName("Pulse IO-" + m_name);
while (m_private->threadRunning == true) {
callbackEventOneCycle();
}