This is a patch that allows to set a different realtime priority for
cdrecord.
Is usefull if other realtime processes are running.

-Hanspeter
diff -ru cdrtools-2.00.3.orig/cdrecord/cdrecord.1 cdrtools-2.00.3/cdrecord/cdrecord.1
--- cdrtools-2.00.3.orig/cdrecord/cdrecord.1    Tue Dec 24 16:28:40 2002
+++ cdrtools-2.00.3/cdrecord/cdrecord.1 Fri Dec 12 22:26:42 2003
@@ -1379,6 +1379,15 @@
 will allow you to write at the full RAW encoding speed a single CPU supports.
 This will create high potential of buffer underruns. Use with care.
 .TP
+.B CDR_RTPRIORITY
+If this environment variable is set on a system supporting realtime scheduling,
+.B cdrecord
+will try to set it's realtime priority according to
+.BR CDR_RTPRIORITY .
+If set to -1,
+.B cdrecord
+will run with nice priority only.
+.TP
 .B RSH
 If the 
 .B RSH
diff -ru cdrtools-2.00.3.orig/cdrecord/cdrecord.c cdrtools-2.00.3/cdrecord/cdrecord.c
--- cdrtools-2.00.3.orig/cdrecord/cdrecord.c    Wed May 28 14:06:37 2003
+++ cdrtools-2.00.3/cdrecord/cdrecord.c Fri Dec 12 21:48:50 2003
@@ -3699,6 +3699,8 @@
        int pri;
 {
        struct sched_param scp;
+       char    *envvar;
+       int     cdrec_priority;
 
        /*
         * Verify that scheduling is available
@@ -3711,6 +3713,13 @@
 #endif
        fillbytes(&scp, sizeof(scp), '\0');
        scp.sched_priority = sched_get_priority_max(SCHED_RR) - pri;
+       if ((envvar = getenv("CDR_RTPRIORITY")) != NULL) {
+               cdrec_priority = atoi(envvar);
+               if (cdrec_priority >= sched_get_priority_min(SCHED_RR))
+                       scp.sched_priority = cdrec_priority - pri;
+               else
+                       return (-1);
+       }
        if (sched_setscheduler(0, SCHED_RR, &scp) < 0) {
                errmsg("WARNING: Cannot set RR-scheduler\n");
                return (-1);

Reply via email to