mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
Port to Windows. This is mostly glue layers for the poor POSIX support
on Windows. A few notes * Only sockets behave somewhat like file descriptors in UNIX. * There are no fixed paths. Closes thing is environment variables that point to system directories. We also figure out where the binary/dll is located and use that as configuration directory. git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/ossman@418 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
2f74bb9d43
commit
19d9fcbda8
22 changed files with 712 additions and 58 deletions
|
|
@ -19,6 +19,10 @@
|
|||
USA.
|
||||
***/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
|
@ -31,13 +35,16 @@
|
|||
#include "util.h"
|
||||
#include "log.h"
|
||||
|
||||
#ifndef OS_IS_WIN32
|
||||
#define RANDOM_DEVICE "/dev/urandom"
|
||||
#endif
|
||||
|
||||
void pa_random(void *ret_data, size_t length) {
|
||||
int fd;
|
||||
ssize_t r = 0;
|
||||
assert(ret_data && length);
|
||||
|
||||
|
||||
#ifdef RANDOM_DEVICE
|
||||
if ((fd = open(RANDOM_DEVICE, O_RDONLY)) >= 0) {
|
||||
|
||||
if ((r = pa_loop_read(fd, ret_data, length)) < 0 || (size_t) r != length)
|
||||
|
|
@ -45,17 +52,20 @@ void pa_random(void *ret_data, size_t length) {
|
|||
|
||||
close(fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((size_t) r != length) {
|
||||
uint8_t *p;
|
||||
size_t l;
|
||||
|
||||
|
||||
#ifdef RANDOM_DEVICE
|
||||
pa_log_warn(__FILE__": WARNING: Failed to open entropy device '"RANDOM_DEVICE"': %s"
|
||||
", falling back to unsecure pseudo RNG.\n", strerror(errno));
|
||||
#endif
|
||||
|
||||
srandom(time(NULL));
|
||||
srand(time(NULL));
|
||||
|
||||
for (p = ret_data, l = length; l > 0; p++, l--)
|
||||
*p = (uint8_t) random();
|
||||
*p = (uint8_t) rand();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue