Add utility functions in PortaudioBackend for re/setting MMCSS thread characteristics
This commit is contained in:
parent
77ce989dfa
commit
b288a40220
@ -699,6 +699,41 @@ PortAudioBackend::name_to_id(std::string device_name) const {
|
||||
return device_id;
|
||||
}
|
||||
|
||||
bool
|
||||
PortAudioBackend::set_mmcss_pro_audio (HANDLE* task_handle)
|
||||
{
|
||||
bool mmcss_success = mmcss::set_thread_characteristics ("Pro Audio", task_handle);
|
||||
|
||||
if (!mmcss_success) {
|
||||
PBD::warning << get_error_string(SettingAudioThreadPriorityError) << endmsg;
|
||||
return false;
|
||||
} else {
|
||||
DEBUG_THREADS("Thread characteristics set to Pro Audio\n");
|
||||
}
|
||||
|
||||
bool mmcss_priority =
|
||||
mmcss::set_thread_priority(*task_handle, mmcss::AVRT_PRIORITY_NORMAL);
|
||||
|
||||
if (!mmcss_priority) {
|
||||
PBD::warning << get_error_string(SettingAudioThreadPriorityError) << endmsg;
|
||||
return false;
|
||||
} else {
|
||||
DEBUG_THREADS("Thread priority set to AVRT_PRIORITY_NORMAL\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PortAudioBackend::reset_mmcss (HANDLE task_handle)
|
||||
{
|
||||
if (!mmcss::revert_thread_characteristics(task_handle)) {
|
||||
DEBUG_THREADS("Unable to reset process thread characteristics\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void *
|
||||
PortAudioBackend::portaudio_process_thread (void *arg)
|
||||
{
|
||||
|
@ -334,6 +334,9 @@ class PortAudioBackend : public AudioBackend {
|
||||
bool engine_halted ();
|
||||
bool running ();
|
||||
|
||||
static bool set_mmcss_pro_audio (HANDLE* task_handle);
|
||||
static bool reset_mmcss (HANDLE task_handle);
|
||||
|
||||
private:
|
||||
std::string _instance_name;
|
||||
PortAudioIO *_pcmio;
|
||||
|
Loading…
Reference in New Issue
Block a user