added patch by jmaurer, fixes #18

This commit is contained in:
darkeye 2007-04-26 08:22:45 +00:00
parent 4c1d27044d
commit a8f97b4bac
1 changed files with 24 additions and 32 deletions

View File

@ -1038,18 +1038,13 @@ DarkIce :: configFileCast ( const Config & config )
/*------------------------------------------------------------------------------
* Set POSIX real-time scheduling, if super-user
* Set POSIX real-time scheduling
*----------------------------------------------------------------------------*/
void
DarkIce :: setRealTimeScheduling ( void ) throw ( Exception )
{
// Only if the OS has the POSIX real-time scheduling functions implemented.
#if defined( HAVE_SCHED_GETSCHEDULER ) && defined( HAVE_SCHED_GETPARAM )
uid_t euid;
euid = geteuid();
if ( euid == 0 ) {
int high_priority;
struct sched_param param;
@ -1072,9 +1067,11 @@ DarkIce :: setRealTimeScheduling ( void ) throw ( Exception )
param.sched_priority = high_priority - 1;
if ( sched_setscheduler( 0, SCHED_FIFO, &param) == -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 */
if ( sched_getparam( 0, &param) == -1 ) {
throw Exception( __FILE__, __LINE__, "sched_getparam", errno);
@ -1083,11 +1080,6 @@ DarkIce :: setRealTimeScheduling ( void ) throw ( Exception )
reportEvent( 1,
"Using POSIX real-time scheduling, 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
reportEvent( 1, "POSIX scheduling not supported on this system, "