mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	initialize random seed globaly from $RANDOM_DEVICE
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@719 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									d50255ac1e
								
							
						
					
					
						commit
						0990d8c796
					
				
					 2 changed files with 25 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -135,6 +135,29 @@ static void close_pipe(int p[2]) {
 | 
			
		|||
    p[0] = p[1] = -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void set_random_seed(void) {
 | 
			
		||||
    unsigned int seed = 0;
 | 
			
		||||
    
 | 
			
		||||
#ifdef RANDOM_DEVICE
 | 
			
		||||
    int fd;
 | 
			
		||||
    
 | 
			
		||||
    if ((fd = open(RANDOM_DEVICE, O_RDONLY)) >= 0) {
 | 
			
		||||
        ssize_t r;
 | 
			
		||||
 | 
			
		||||
        if ((r = pa_loop_read(fd, &seed, sizeof(seed))) < 0 || (size_t) r != sizeof(seed)) {
 | 
			
		||||
            pa_log_error(__FILE__": failed to read entropy from '"RANDOM_DEVICE"'");
 | 
			
		||||
            seed += (unsigned int) time(NULL);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        close(fd);
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    seed = (unsigned int) time(NULL);
 | 
			
		||||
#endif
 | 
			
		||||
    
 | 
			
		||||
    srand(seed);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main(int argc, char *argv[]) {
 | 
			
		||||
    pa_core *c;
 | 
			
		||||
    pa_strbuf *buf = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -180,6 +203,8 @@ int main(int argc, char *argv[]) {
 | 
			
		|||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    set_random_seed();
 | 
			
		||||
    
 | 
			
		||||
    pa_log_set_ident("polypaudio");
 | 
			
		||||
    
 | 
			
		||||
    conf = pa_daemon_conf_new();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue