mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add API pa_ncpus()
This commit is contained in:
		
							parent
							
								
									c0e4e5a868
								
							
						
					
					
						commit
						4dc1916467
					
				
					 3 changed files with 16 additions and 0 deletions
				
			
		| 
						 | 
					@ -823,6 +823,8 @@ int main(int argc, char *argv[]) {
 | 
				
			||||||
    pa_log_debug(_("Running on host: %s"), s);
 | 
					    pa_log_debug(_("Running on host: %s"), s);
 | 
				
			||||||
    pa_xfree(s);
 | 
					    pa_xfree(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_log_debug(_("Found %u CPUs."), pa_ncpus());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE);
 | 
					    pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_VALGRIND_MEMCHECK_H
 | 
					#ifdef HAVE_VALGRIND_MEMCHECK_H
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2541,3 +2541,15 @@ void pa_reduce(unsigned *num, unsigned *den) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(pa_gcd(*num, *den) == 1);
 | 
					    pa_assert(pa_gcd(*num, *den) == 1);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unsigned pa_ncpus(void) {
 | 
				
			||||||
 | 
					    long ncpus;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _SC_NPROCESSORS_CONF
 | 
				
			||||||
 | 
					    ncpus = sysconf(_SC_NPROCESSORS_CONF);
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					    ncpus = 1;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return ncpus <= 0 ? 1 : (unsigned) ncpus;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -213,4 +213,6 @@ static inline pa_bool_t pa_in_valgrind(void) {
 | 
				
			||||||
unsigned pa_gcd(unsigned a, unsigned b);
 | 
					unsigned pa_gcd(unsigned a, unsigned b);
 | 
				
			||||||
void pa_reduce(unsigned *num, unsigned *den);
 | 
					void pa_reduce(unsigned *num, unsigned *den);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unsigned pa_ncpus(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue