added patch by jmaurer, fixes #18
This commit is contained in:
parent
4c1d27044d
commit
a8f97b4bac
|
@ -1038,18 +1038,13 @@ DarkIce :: configFileCast ( const Config & config )
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Set POSIX real-time scheduling, if super-user
|
* Set POSIX real-time scheduling
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
DarkIce :: setRealTimeScheduling ( void ) throw ( Exception )
|
DarkIce :: setRealTimeScheduling ( void ) throw ( Exception )
|
||||||
{
|
{
|
||||||
// Only if the OS has the POSIX real-time scheduling functions implemented.
|
// Only if the OS has the POSIX real-time scheduling functions implemented.
|
||||||
#if defined( HAVE_SCHED_GETSCHEDULER ) && defined( HAVE_SCHED_GETPARAM )
|
#if defined( HAVE_SCHED_GETSCHEDULER ) && defined( HAVE_SCHED_GETPARAM )
|
||||||
uid_t euid;
|
|
||||||
|
|
||||||
euid = geteuid();
|
|
||||||
|
|
||||||
if ( euid == 0 ) {
|
|
||||||
int high_priority;
|
int high_priority;
|
||||||
struct sched_param param;
|
struct sched_param param;
|
||||||
|
|
||||||
|
@ -1072,9 +1067,11 @@ DarkIce :: setRealTimeScheduling ( void ) throw ( Exception )
|
||||||
param.sched_priority = high_priority - 1;
|
param.sched_priority = high_priority - 1;
|
||||||
|
|
||||||
if ( sched_setscheduler( 0, SCHED_FIFO, ¶m) == -1 ) {
|
if ( sched_setscheduler( 0, SCHED_FIFO, ¶m) == -1 ) {
|
||||||
throw Exception( __FILE__, __LINE__, "sched_setscheduler", errno);
|
reportEvent( 1,
|
||||||
}
|
"Could not set POSIX real-time scheduling, "
|
||||||
|
"this may cause recording skips.\n"
|
||||||
|
"Try to run darkice as the super-user.");
|
||||||
|
} else {
|
||||||
/* ask the new priortiy and report it */
|
/* ask the new priortiy and report it */
|
||||||
if ( sched_getparam( 0, ¶m) == -1 ) {
|
if ( sched_getparam( 0, ¶m) == -1 ) {
|
||||||
throw Exception( __FILE__, __LINE__, "sched_getparam", errno);
|
throw Exception( __FILE__, __LINE__, "sched_getparam", errno);
|
||||||
|
@ -1083,11 +1080,6 @@ DarkIce :: setRealTimeScheduling ( void ) throw ( Exception )
|
||||||
reportEvent( 1,
|
reportEvent( 1,
|
||||||
"Using POSIX real-time scheduling, priority",
|
"Using POSIX real-time scheduling, priority",
|
||||||
param.sched_priority );
|
param.sched_priority );
|
||||||
} else {
|
|
||||||
reportEvent( 1,
|
|
||||||
"Not running as super-user, unable to use POSIX real-time scheduling" );
|
|
||||||
reportEvent( 1,
|
|
||||||
"It is recommended that you run this program as super-user");
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
reportEvent( 1, "POSIX scheduling not supported on this system, "
|
reportEvent( 1, "POSIX scheduling not supported on this system, "
|
||||||
|
|
Loading…
Reference in New Issue