mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	make use of PR_SET_TIMERSLACK
This commit is contained in:
		
							parent
							
								
									4a13763797
								
							
						
					
					
						commit
						5793f93350
					
				
					 3 changed files with 29 additions and 0 deletions
				
			
		| 
						 | 
					@ -885,6 +885,8 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        pa_log_info(_("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"));
 | 
					        pa_log_info(_("Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_rtclock_hrtimer_enable();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef SIGRTMIN
 | 
					#ifdef SIGRTMIN
 | 
				
			||||||
    /* Valgrind uses SIGRTMAX. To easy debugging we don't use it here */
 | 
					    /* Valgrind uses SIGRTMAX. To easy debugging we don't use it here */
 | 
				
			||||||
    pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);
 | 
					    pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,9 +27,12 @@
 | 
				
			||||||
#include <stddef.h>
 | 
					#include <stddef.h>
 | 
				
			||||||
#include <time.h>
 | 
					#include <time.h>
 | 
				
			||||||
#include <sys/time.h>
 | 
					#include <sys/time.h>
 | 
				
			||||||
 | 
					#include <sys/prctl.h>
 | 
				
			||||||
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pulse/timeval.h>
 | 
					#include <pulse/timeval.h>
 | 
				
			||||||
#include <pulsecore/macro.h>
 | 
					#include <pulsecore/macro.h>
 | 
				
			||||||
 | 
					#include <pulsecore/core-error.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "rtclock.h"
 | 
					#include "rtclock.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,6 +92,29 @@ pa_bool_t pa_rtclock_hrtimer(void) {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void pa_rtclock_hrtimer_enable(void) {
 | 
				
			||||||
 | 
					#ifdef PR_SET_TIMERSLACK
 | 
				
			||||||
 | 
					    int slack_ns;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((slack_ns = prctl(PR_GET_TIMERSLACK, 0, 0, 0, 0)) < 0) {
 | 
				
			||||||
 | 
					        pa_log_info("PR_GET_TIMERSLACK/PR_SET_TIMERSLACK not supported.");
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_log_debug("Timer slack set to %i us.", slack_ns/1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    slack_ns = 500000000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_log_debug("Setting timer slack to %i us.", slack_ns/1000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (prctl(PR_SET_TIMERSLACK, slack_ns, 0, 0, 0) < 0) {
 | 
				
			||||||
 | 
					        pa_log_warn("PR_SET_TIMERSLACK failed: %s", pa_cstrerror(errno));
 | 
				
			||||||
 | 
					        return;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pa_usec_t pa_rtclock_usec(void) {
 | 
					pa_usec_t pa_rtclock_usec(void) {
 | 
				
			||||||
    struct timeval tv;
 | 
					    struct timeval tv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@ pa_usec_t pa_rtclock_usec(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pa_usec_t pa_rtclock_age(const struct timeval *tv);
 | 
					pa_usec_t pa_rtclock_age(const struct timeval *tv);
 | 
				
			||||||
pa_bool_t pa_rtclock_hrtimer(void);
 | 
					pa_bool_t pa_rtclock_hrtimer(void);
 | 
				
			||||||
 | 
					void pa_rtclock_hrtimer_enable(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* timer with a resolution better than this are considered high-resolution */
 | 
					/* timer with a resolution better than this are considered high-resolution */
 | 
				
			||||||
#define PA_HRTIMER_THRESHOLD_USEC 10
 | 
					#define PA_HRTIMER_THRESHOLD_USEC 10
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue