How do I run pulseaudio with realtime priority in Ubuntu 9.04?

9,603

Make sure you have a realtime kernel installed:

dpkg -l | grep linux-rt

If that doesn't list anything, you'll need to install one:

sudo apt-get install linux-rt linux-headers-rt

Ubuntu Studio uses the realtime kernel by default; I'm not sure it uses the same apt repositories as standard Ubuntu. If you're running standard, but want some of the features of Ubuntu Studio, read through this page. A section on installing and configuring Real Time Kernel is about halfway down the page. Also check the Real-Time Support section:

After you've got the kernel you still need to set up real-time access for your applications.

All you have to do for this is give your audio group permissions to access the rtprio, nice, and memlock limits. To do this, you just need to run these commands, which will add some lines to the file /etc/security/limits.conf:

sudo su -c 'echo @audio - rtprio 99 >> /etc/security/limits.conf'
sudo su -c 'echo @audio - nice -19 >> /etc/security/limits.conf'
sudo su -c 'echo @audio - memlock unlimited >> /etc/security/limits.conf'
Share:
9,603

Related videos on Youtube

CTarczon
Author by

CTarczon

Yet another developer. All my code samples you could find here are given freely to the public domain on an "as is" basis, but no warranty is given (implied or assumed).

Updated on September 17, 2022

Comments

  • CTarczon
    CTarczon almost 2 years

    Sometimes I get choppy sound so I was thinking about running pulseaudio with realtime priority. But when I try to do this, Ubuntu just won't let me.

    $ pulseaudio -vvv --start --realtime=1
    D: main.c: Started as real root: no, suid root: yes
    I: main.c: PolicyKit refuses acquire-high-priority privilege.
    I: main.c: PolicyKit refuses acquire-real-time privilege.
    I: main.c: Called SUID root and real-time and/or high-priority scheduling
       was requested in the configuration. However, we lack the necessary privileges:
    I: main.c: We are not in group 'pulse-rt', PolicyKit refuse to grant us the 
       requested privileges and we have no increase RLIMIT_NICE/RLIMIT_RTPRIO 
       resource limits.
    I: main.c: For enabling real-time/high-priority scheduling please acquire 
       the appropriate PolicyKit privileges, or become a member of 'pulse-rt', 
       or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user.
    I: main.c: setrlimit(RLIMIT_NICE, (31, 31)) failed: Operation not permitted
    I: main.c: setrlimit(RLIMIT_RTPRIO, (9, 9)) failed: Operation not permitted
    D: main.c: Can realtime: no, can high-priority: no
    D: main.c: Can realtime: no, can high-priority: no
    I: main.c: Daemon startup successful.
    

    I am a member of pulse-rt group

    $ sudo adduser vava 'pulse-rt'
    The user `vava' is already a member of `pulse-rt'.
    

    And I'm not sure how to increate RLIMIT_PRPRIO, I've tried to put

    vava             soft    rtprio          10
    

    into /etc/security/limits.conf but that didn't help.

    So what else should I do to allow myself to run pulseaudio with realtime priority?

    • Admin
      Admin almost 15 years
      What do the /etc/pulse/daemon.conf entries related to priority and realtime-scheduling contain? Also check this post: ubuntuforums.org/archive/index.php/t-1142694.html
    • CTarczon
      CTarczon almost 15 years
      It doesn't really matter what daemon.conf contains when I use command line arguments as they take priority. Also, from the long it is clearly seen that PA wants to use real-time priority but something won't let it.
    • CTarczon
      CTarczon almost 15 years
      @nagul, but thanks for the link, seems like it getting better