increase shm size limit, modernizations

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2430 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2008-05-15 20:38:29 +00:00
parent 2bc77ff49a
commit 70c5967806
2 changed files with 11 additions and 9 deletions

View file

@ -57,7 +57,7 @@
#define MADV_REMOVE 9 #define MADV_REMOVE 9
#endif #endif
#define MAX_SHM_SIZE (PA_ALIGN(1024*1024*20)) #define MAX_SHM_SIZE (PA_ALIGN(1024*1024*64))
#ifdef __linux__ #ifdef __linux__
/* On Linux we know that the shared memory blocks are files in /* On Linux we know that the shared memory blocks are files in
@ -86,13 +86,13 @@ static char *segment_name(char *fn, size_t l, unsigned id) {
return fn; return fn;
} }
int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode) { int pa_shm_create_rw(pa_shm *m, size_t size, pa_bool_t shared, mode_t mode) {
char fn[32]; char fn[32];
int fd = -1; int fd = -1;
pa_assert(m); pa_assert(m);
pa_assert(size > 0); pa_assert(size > 0);
pa_assert(size < MAX_SHM_SIZE); pa_assert(size <= MAX_SHM_SIZE);
pa_assert(mode >= 0600); pa_assert(mode >= 0600);
/* Each time we create a new SHM area, let's first drop all stale /* Each time we create a new SHM area, let's first drop all stale
@ -124,7 +124,7 @@ int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode) {
m->ptr = pa_xmalloc(m->size); m->ptr = pa_xmalloc(m->size);
#endif #endif
m->do_unlink = 0; m->do_unlink = FALSE;
} else { } else {
#ifdef HAVE_SHM_OPEN #ifdef HAVE_SHM_OPEN
@ -157,7 +157,7 @@ int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode) {
pa_atomic_store(&marker->marker, SHM_MARKER); pa_atomic_store(&marker->marker, SHM_MARKER);
pa_assert_se(close(fd) == 0); pa_assert_se(close(fd) == 0);
m->do_unlink = 1; m->do_unlink = TRUE;
#else #else
return -1; return -1;
#endif #endif
@ -375,7 +375,7 @@ int pa_shm_cleanup(void) {
/* Ok, the owner of this shms segment is dead, so, let's remove the segment */ /* Ok, the owner of this shms segment is dead, so, let's remove the segment */
segment_name(fn, sizeof(fn), id); segment_name(fn, sizeof(fn), id);
if (shm_unlink(fn) < 0 && errno != EACCES) if (shm_unlink(fn) < 0 && errno != EACCES && errno != ENOENT)
pa_log_warn("Failed to remove SHM segment %s: %s\n", fn, pa_cstrerror(errno)); pa_log_warn("Failed to remove SHM segment %s: %s\n", fn, pa_cstrerror(errno));
} }

View file

@ -26,15 +26,17 @@
#include <sys/types.h> #include <sys/types.h>
#include <pulsecore/macro.h>
typedef struct pa_shm { typedef struct pa_shm {
unsigned id; unsigned id;
void *ptr; void *ptr;
size_t size; size_t size;
int do_unlink; pa_bool_t do_unlink:1;
int shared; pa_bool_t shared:1;
} pa_shm; } pa_shm;
int pa_shm_create_rw(pa_shm *m, size_t size, int shared, mode_t mode); int pa_shm_create_rw(pa_shm *m, size_t size, pa_bool_t shared, mode_t mode);
int pa_shm_attach_ro(pa_shm *m, unsigned id); int pa_shm_attach_ro(pa_shm *m, unsigned id);
void pa_shm_punch(pa_shm *m, size_t offset, size_t size); void pa_shm_punch(pa_shm *m, size_t offset, size_t size);