summaryrefslogtreecommitdiffstats
path: root/src/pulse
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulse')
-rw-r--r--src/pulse/client-conf.c3
-rw-r--r--src/pulse/client-conf.h1
-rw-r--r--src/pulse/client.conf.in1
-rw-r--r--src/pulse/context.c4
-rw-r--r--src/pulse/lock-autospawn.c330
-rw-r--r--src/pulse/lock-autospawn.h32
-rw-r--r--src/pulse/stream.c6
7 files changed, 10 insertions, 367 deletions
diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c
index 739ef161..58d64642 100644
--- a/src/pulse/client-conf.c
+++ b/src/pulse/client-conf.c
@@ -61,6 +61,7 @@ static const pa_client_conf default_conf = {
.disable_shm = FALSE,
.cookie_file = NULL,
.cookie_valid = FALSE,
+ .shm_size = 0
};
pa_client_conf *pa_client_conf_new(void) {
@@ -99,6 +100,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
{ "autospawn", pa_config_parse_bool, NULL },
{ "cookie-file", pa_config_parse_string, NULL },
{ "disable-shm", pa_config_parse_bool, NULL },
+ { "shm-size-bytes", pa_config_parse_size, NULL },
{ NULL, NULL, NULL },
};
@@ -110,6 +112,7 @@ int pa_client_conf_load(pa_client_conf *c, const char *filename) {
table[5].data = &c->autospawn;
table[6].data = &c->cookie_file;
table[7].data = &c->disable_shm;
+ table[8].data = &c->shm_size;
if (filename) {
diff --git a/src/pulse/client-conf.h b/src/pulse/client-conf.h
index 699279aa..4eac467e 100644
--- a/src/pulse/client-conf.h
+++ b/src/pulse/client-conf.h
@@ -31,6 +31,7 @@ typedef struct pa_client_conf {
pa_bool_t autospawn, disable_shm;
uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
pa_bool_t cookie_valid; /* non-zero, when cookie is valid */
+ size_t shm_size;
} pa_client_conf;
/* Create a new configuration data object and reset it to defaults */
diff --git a/src/pulse/client.conf.in b/src/pulse/client.conf.in
index 8339d651..579bcc20 100644
--- a/src/pulse/client.conf.in
+++ b/src/pulse/client.conf.in
@@ -30,3 +30,4 @@
; cookie-file =
; disable-shm = no
+; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
diff --git a/src/pulse/context.c b/src/pulse/context.c
index 154e5faf..3145d9c8 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -174,10 +174,10 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *
pa_client_conf_load(c->conf, NULL);
pa_client_conf_env(c->conf);
- if (!(c->mempool = pa_mempool_new(!c->conf->disable_shm))) {
+ if (!(c->mempool = pa_mempool_new(!c->conf->disable_shm, c->conf->shm_size))) {
if (!c->conf->disable_shm)
- c->mempool = pa_mempool_new(FALSE);
+ c->mempool = pa_mempool_new(FALSE, c->conf->shm_size);
if (!c->mempool) {
context_free(c);
diff --git a/src/pulse/lock-autospawn.c b/src/pulse/lock-autospawn.c
deleted file mode 100644
index d36b669e..00000000
--- a/src/pulse/lock-autospawn.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/***
- This file is part of PulseAudio.
-
- Copyright 2008 Lennart Poettering
-
- PulseAudio is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2 of the License,
- or (at your option) any later version.
-
- PulseAudio is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with PulseAudio; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- USA.
-***/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <fcntl.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/poll.h>
-#include <signal.h>
-#include <pthread.h>
-
-#include <pulse/i18n.h>
-#include <pulse/xmalloc.h>
-
-#include <pulsecore/mutex.h>
-#include <pulsecore/thread.h>
-#include <pulsecore/core-util.h>
-
-#include "lock-autospawn.h"
-
-/* So, why do we have this complex code here with threads and pipes
- * and stuff? For two reasons: POSIX file locks are per-process, not
- * per-file descriptor. That means that two contexts within the same
- * process that try to create the autospawn lock might end up assuming
- * they both managed to lock the file. And then, POSIX locking
- * operations are synchronous. If two contexts run from the same event
- * loop it must be made sure that they do not block each other, but
- * that the locking operation can happen asynchronously. */
-
-#define AUTOSPAWN_LOCK "autospawn.lock"
-
-static pa_mutex *mutex;
-
-static unsigned n_ref = 0;
-static int lock_fd = -1;
-static pa_mutex *lock_fd_mutex = NULL;
-static pa_bool_t taken = FALSE;
-static pa_thread *thread;
-static int pipe_fd[2] = { -1, -1 };
-
-static void destroy_mutex(void) PA_GCC_DESTRUCTOR;
-
-static int ref(void) {
-
- if (n_ref > 0) {
-
- pa_assert(pipe_fd[0] >= 0);
- pa_assert(pipe_fd[1] >= 0);
-
- n_ref++;
-
- return 0;
- }
-
- pa_assert(lock_fd < 0);
- pa_assert(!lock_fd_mutex);
- pa_assert(!taken);
- pa_assert(!thread);
- pa_assert(pipe_fd[0] < 0);
- pa_assert(pipe_fd[1] < 0);
-
- if (pipe(pipe_fd) < 0)
- return -1;
-
- lock_fd_mutex = pa_mutex_new(FALSE, FALSE);
-
- pa_make_fd_cloexec(pipe_fd[0]);
- pa_make_fd_cloexec(pipe_fd[1]);
-
- pa_make_fd_nonblock(pipe_fd[1]);
- pa_make_fd_nonblock(pipe_fd[0]);
-
- n_ref = 1;
- return 0;
-}
-
-static void unref(pa_bool_t after_fork) {
-
- pa_assert(n_ref > 0);
- pa_assert(pipe_fd[0] >= 0);
- pa_assert(pipe_fd[1] >= 0);
- pa_assert(lock_fd_mutex);
-
- n_ref--;
-
- if (n_ref > 0)
- return;
-
- pa_assert(!taken);
-
- if (thread) {
- pa_thread_free(thread);
- thread = NULL;
- }
-
- pa_mutex_lock(lock_fd_mutex);
- if (lock_fd >= 0) {
-
- if (after_fork)
- pa_close(lock_fd);
- else {
- char *lf;
-
- if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK)))
- pa_log_warn(_("Cannot access autospawn lock."));
-
- pa_unlock_lockfile(lf, lock_fd);
- pa_xfree(lf);
-
- lock_fd = -1;
- }
- }
- pa_mutex_unlock(lock_fd_mutex);
-
- pa_mutex_free(lock_fd_mutex);
- lock_fd_mutex = NULL;
-
- pa_close(pipe_fd[0]);
- pa_close(pipe_fd[1]);
- pipe_fd[0] = pipe_fd[1] = -1;
-}
-
-static void ping(void) {
- ssize_t s;
-
- pa_assert(pipe_fd[1] >= 0);
-
- for (;;) {
- char x = 'x';
-
- if ((s = write(pipe_fd[1], &x, 1)) == 1)
- break;
-
- pa_assert(s < 0);
-
- if (errno == EAGAIN)
- break;
-
- pa_assert(errno == EINTR);
- }
-}
-
-static void wait_for_ping(void) {
- ssize_t s;
- char x;
- struct pollfd pfd;
- int k;
-
- pa_assert(pipe_fd[0] >= 0);
-
- memset(&pfd, 0, sizeof(pfd));
- pfd.fd = pipe_fd[0];
- pfd.events = POLLIN;
-
- if ((k = poll(&pfd, 1, -1)) != 1) {
- pa_assert(k < 0);
- pa_assert(errno == EINTR);
- } else if ((s = read(pipe_fd[0], &x, 1)) != 1) {
- pa_assert(s < 0);
- pa_assert(errno == EAGAIN);
- }
-}
-
-static void empty_pipe(void) {
- char x[16];
- ssize_t s;
-
- pa_assert(pipe_fd[0] >= 0);
-
- if ((s = read(pipe_fd[0], &x, sizeof(x))) < 1) {
- pa_assert(s < 0);
- pa_assert(errno == EAGAIN);
- }
-}
-
-static void thread_func(void *u) {
- int fd;
- char *lf;
- sigset_t fullset;
-
- /* No signals in this thread please */
- sigfillset(&fullset);
- pthread_sigmask(SIG_BLOCK, &fullset, NULL);
-
- if (!(lf = pa_runtime_path(AUTOSPAWN_LOCK))) {
- pa_log_warn(_("Cannot access autospawn lock."));
- goto finish;
- }
-
- if ((fd = pa_lock_lockfile(lf)) < 0)
- goto finish;
-
- pa_mutex_lock(lock_fd_mutex);
- pa_assert(lock_fd < 0);
- lock_fd = fd;
- pa_mutex_unlock(lock_fd_mutex);
-
-finish:
- pa_xfree(lf);
-
- ping();
-}
-
-static int start_thread(void) {
-
- if (!thread)
- if (!(thread = pa_thread_new(thread_func, NULL)))
- return -1;
-
- return 0;
-}
-
-static void create_mutex(void) {
- PA_ONCE_BEGIN {
- mutex = pa_mutex_new(FALSE, FALSE);
- } PA_ONCE_END;
-}
-
-static void destroy_mutex(void) {
-
- if (mutex)
- pa_mutex_free(mutex);
-}
-
-
-int pa_autospawn_lock_init(void) {
- int ret = -1;
-
- create_mutex();
- pa_mutex_lock(mutex);
-
- if (ref() < 0)
- ret = -1;
- else
- ret = pipe_fd[0];
-
- pa_mutex_unlock(mutex);
-
- return ret;
-}
-
-int pa_autospawn_lock_acquire(pa_bool_t block) {
- int ret = -1;
-
- create_mutex();
- pa_mutex_lock(mutex);
- pa_assert(n_ref >= 1);
-
- pa_mutex_lock(lock_fd_mutex);
-
- for (;;) {
-
- empty_pipe();
-
- if (lock_fd >= 0 && !taken) {
- taken = TRUE;
- ret = 1;
- break;
- }
-
- if (lock_fd < 0)
- if (start_thread() < 0)
- break;
-
- if (!block) {
- ret = 0;
- break;
- }
-
- pa_mutex_unlock(lock_fd_mutex);
- pa_mutex_unlock(mutex);
-
- wait_for_ping();
-
- pa_mutex_lock(mutex);
- pa_mutex_lock(lock_fd_mutex);
- }
-
- pa_mutex_unlock(lock_fd_mutex);
-
- pa_mutex_unlock(mutex);
-
- return ret;
-}
-
-void pa_autospawn_lock_release(void) {
-
- create_mutex();
- pa_mutex_lock(mutex);
- pa_assert(n_ref >= 1);
-
- pa_assert(taken);
- taken = FALSE;
-
- ping();
-
- pa_mutex_unlock(mutex);
-}
-
-void pa_autospawn_lock_done(pa_bool_t after_fork) {
-
- create_mutex();
- pa_mutex_lock(mutex);
- pa_assert(n_ref >= 1);
-
- unref(after_fork);
-
- pa_mutex_unlock(mutex);
-}
diff --git a/src/pulse/lock-autospawn.h b/src/pulse/lock-autospawn.h
deleted file mode 100644
index c04c4bd1..00000000
--- a/src/pulse/lock-autospawn.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef foopulselockautospawnhfoo
-#define foopulselockautospawnhfoo
-
-/***
- This file is part of PulseAudio.
-
- Copyright 2008 Lennart Poettering
-
- PulseAudio is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as
- published by the Free Software Foundation; either version 2.1 of the
- License, or (at your option) any later version.
-
- PulseAudio is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with PulseAudio; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- USA.
-***/
-
-#include <pulsecore/macro.h>
-
-int pa_autospawn_lock_init(void);
-int pa_autospawn_lock_acquire(pa_bool_t block);
-void pa_autospawn_lock_release(void);
-void pa_autospawn_lock_done(pa_bool_t after_fork);
-
-#endif
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index d0c7d67e..ababe176 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -86,7 +86,7 @@ pa_stream *pa_stream_new_with_proplist(
pa_assert(PA_REFCNT_VALUE(c) >= 1);
PA_CHECK_VALIDITY_RETURN_NULL(c, ss && pa_sample_spec_valid(ss), PA_ERR_INVALID);
- PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 12 || (ss->format != PA_SAMPLE_S32LE || ss->format != PA_SAMPLE_S32NE), PA_ERR_NOTSUPPORTED);
+ PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 12 || (ss->format != PA_SAMPLE_S32LE && ss->format != PA_SAMPLE_S32BE), PA_ERR_NOTSUPPORTED);
PA_CHECK_VALIDITY_RETURN_NULL(c, !map || (pa_channel_map_valid(map) && map->channels == ss->channels), PA_ERR_INVALID);
PA_CHECK_VALIDITY_RETURN_NULL(c, name || (p && pa_proplist_contains(p, PA_PROP_MEDIA_NAME)), PA_ERR_INVALID);
@@ -557,7 +557,7 @@ void pa_command_stream_started(pa_pdispatch *pd, uint32_t command, uint32_t tag,
request_auto_timing_update(s, TRUE);
if (s->started_callback)
- s->started_callback(s, s->suspended_userdata);
+ s->started_callback(s, s->started_userdata);
finish:
pa_context_unref(c);
@@ -1851,7 +1851,7 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe
if (s->context->version >= 13) {
pa_proplist *p = pa_proplist_new();
- pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, name);
+ pa_proplist_sets(p, PA_PROP_MEDIA_NAME, name);
o = pa_stream_proplist_update(s, PA_UPDATE_REPLACE, p, cb, userdata);
pa_proplist_free(p);
} else {