Mercurial > hg > svapp
changeset 182:58b64dbb49c6
* Set scheduling priority for PortAudio on POSIX systems if possible
author | Chris Cannam |
---|---|
date | Mon, 21 Sep 2009 12:46:20 +0000 |
parents | b35c7af2e1d0 |
children | da514e36839a |
files | audioio/AudioPortAudioTarget.cpp audioio/AudioPortAudioTarget.h |
diffstat | 2 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/audioio/AudioPortAudioTarget.cpp Fri Sep 11 15:42:32 2009 +0000 +++ b/audioio/AudioPortAudioTarget.cpp Mon Sep 21 12:46:20 2009 +0000 @@ -22,6 +22,10 @@ #include <cassert> #include <cmath> +#ifndef _WIN32 +#include <pthread.h> +#endif + //#define DEBUG_AUDIO_PORT_AUDIO_TARGET 1 AudioPortAudioTarget::AudioPortAudioTarget(AudioCallbackPlaySource *source) : @@ -30,6 +34,7 @@ m_bufferSize(0), m_sampleRate(0), m_latency(0), + m_prioritySet(false), m_done(false) { PaError err; @@ -54,7 +59,7 @@ op.device = Pa_GetDefaultOutputDevice(); op.channelCount = 2; op.sampleFormat = paFloat32; - op.suggestedLatency = 0.2; + op.suggestedLatency = 1.0; op.hostApiSpecificStreamInfo = 0; err = Pa_OpenStream(&m_stream, 0, &op, m_sampleRate, paFramesPerBufferUnspecified, @@ -194,6 +199,19 @@ return 0; } + if (!m_prioritySet) { +#ifndef _WIN32 + sched_param param; + param.sched_priority = 20; + if (pthread_setschedparam(pthread_self(), SCHED_RR, ¶m)) { + std::cerr << "AudioPortAudioTarget: NOTE: couldn't set RT scheduling class" << std::endl; + } else { + std::cerr << "AudioPortAudioTarget: NOTE: successfully set RT scheduling class" << std::endl; + } +#endif + m_prioritySet = true; + } + float *output = (float *)outputBuffer; assert(nframes <= m_bufferSize);