mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	core-util: Clamp RLIMIT_RTTIME to what RealtimeKit accepts
In the default configuration, PulseAudio's rlimit-rttime is set to 1000000 (100%), which is higher than what RealtimeKit requires from its clients (200000, 20%). Make an attempt to still get realtime scheduling by clamping the current RLIMIT_RTTIME to what RealtimeKit accepts. Warn about doing this.
This commit is contained in:
		
							parent
							
								
									baee32f2ee
								
							
						
					
					
						commit
						07290d9da7
					
				
					 1 changed files with 31 additions and 7 deletions
				
			
		| 
						 | 
					@ -684,6 +684,10 @@ static int set_scheduler(int rtprio) {
 | 
				
			||||||
    struct sched_param sp;
 | 
					    struct sched_param sp;
 | 
				
			||||||
#ifdef HAVE_DBUS
 | 
					#ifdef HAVE_DBUS
 | 
				
			||||||
    int r;
 | 
					    int r;
 | 
				
			||||||
 | 
					    long long rttime;
 | 
				
			||||||
 | 
					#ifdef HAVE_SYS_RESOURCE_H
 | 
				
			||||||
 | 
					    struct rlimit rl;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
    DBusError error;
 | 
					    DBusError error;
 | 
				
			||||||
    DBusConnection *bus;
 | 
					    DBusConnection *bus;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -721,6 +725,20 @@ static int set_scheduler(int rtprio) {
 | 
				
			||||||
     * https://bugs.freedesktop.org/show_bug.cgi?id=16924 */
 | 
					     * https://bugs.freedesktop.org/show_bug.cgi?id=16924 */
 | 
				
			||||||
    dbus_connection_set_exit_on_disconnect(bus, FALSE);
 | 
					    dbus_connection_set_exit_on_disconnect(bus, FALSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    rttime = rtkit_get_rttime_usec_max(bus);
 | 
				
			||||||
 | 
					    if (rttime >= 0) {
 | 
				
			||||||
 | 
					#ifdef HAVE_SYS_RESOURCE_H
 | 
				
			||||||
 | 
					        r = getrlimit(RLIMIT_RTTIME, &rl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (r >= 0 && (long long) rl.rlim_max > rttime) {
 | 
				
			||||||
 | 
					            pa_log_warn("Clamping rlimit-rttime to %lld for RealtimeKit\n", rttime);
 | 
				
			||||||
 | 
					            rl.rlim_cur = rl.rlim_max = rttime;
 | 
				
			||||||
 | 
					            r = setrlimit(RLIMIT_RTTIME, &rl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (r < 0)
 | 
				
			||||||
 | 
					                pa_log_info("setrlimit() failed: %s", pa_cstrerror(errno));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
        r = rtkit_make_realtime(bus, 0, rtprio);
 | 
					        r = rtkit_make_realtime(bus, 0, rtprio);
 | 
				
			||||||
        dbus_connection_close(bus);
 | 
					        dbus_connection_close(bus);
 | 
				
			||||||
        dbus_connection_unref(bus);
 | 
					        dbus_connection_unref(bus);
 | 
				
			||||||
| 
						 | 
					@ -731,6 +749,12 @@ static int set_scheduler(int rtprio) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        errno = -r;
 | 
					        errno = -r;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        dbus_connection_close(bus);
 | 
				
			||||||
 | 
					        dbus_connection_unref(bus);
 | 
				
			||||||
 | 
					        errno = -rttime;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
    errno = 0;
 | 
					    errno = 0;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue