summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/daemon/daemon.conf.in2
-rw-r--r--src/modules/alsa/alsa-mixer.c18
-rw-r--r--src/modules/alsa/mixer/paths/analog-output-headphones.conf2
-rw-r--r--src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf2
-rw-r--r--src/modules/alsa/mixer/paths/analog-output-mono.conf2
-rw-r--r--src/modules/module-cli.c28
-rw-r--r--src/modules/module-position-event-sounds.c5
-rw-r--r--src/modules/raop/module-raop-discover.c4
-rw-r--r--src/modules/rtp/rtsp_client.c24
-rw-r--r--src/pulse/context.c5
-rw-r--r--src/pulse/def.h5
-rw-r--r--src/pulse/gccmacro.h2
-rw-r--r--src/pulse/mainloop.c179
-rw-r--r--src/pulse/proplist.h3
-rw-r--r--src/pulse/timeval.c67
-rw-r--r--src/pulse/timeval.h7
-rw-r--r--src/pulsecore/core-rtclock.c22
-rw-r--r--src/pulsecore/core-rtclock.h1
-rw-r--r--src/pulsecore/core-util.c33
-rw-r--r--src/pulsecore/core-util.h2
-rw-r--r--src/pulsecore/macro.h12
-rw-r--r--src/pulsecore/memblock.c27
-rw-r--r--src/pulsecore/socket-client.c60
-rw-r--r--src/pulsecore/socket-client.h2
-rw-r--r--src/pulsecore/svolume_mmx.c18
-rw-r--r--src/pulsecore/svolume_sse.c2
-rw-r--r--src/utils/pacat.c14
-rw-r--r--src/utils/padsp.c6
28 files changed, 330 insertions, 224 deletions
diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in
index db2059e1..3af68b0a 100644
--- a/src/daemon/daemon.conf.in
+++ b/src/daemon/daemon.conf.in
@@ -70,7 +70,7 @@
; rlimit-msgqueue = -1
; rlimit-nice = 31
; rlimit-rtprio = 9
-; rlimit-rtttime = 1000000
+; rlimit-rttime = 1000000
; default-sample-format = s16le
; default-sample-rate = 44100
diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 685169b9..f3ce681f 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -479,7 +479,6 @@ static int element_get_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann
snd_mixer_elem_t *me;
snd_mixer_selem_channel_id_t c;
pa_channel_position_mask_t mask = 0;
- pa_volume_t max_channel_volume = PA_VOLUME_MUTED;
unsigned k;
pa_assert(m);
@@ -546,9 +545,6 @@ static int element_get_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann
f = from_alsa_volume(value, e->min_volume, e->max_volume);
}
- if (f > max_channel_volume)
- max_channel_volume = f;
-
for (k = 0; k < cm->channels; k++)
if (e->masks[c][e->n_channels-1] & PA_CHANNEL_POSITION_MASK(cm->map[k]))
if (v->values[k] < f)
@@ -559,7 +555,7 @@ static int element_get_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann
for (k = 0; k < cm->channels; k++)
if (!(mask & PA_CHANNEL_POSITION_MASK(cm->map[k])))
- v->values[k] = max_channel_volume;
+ v->values[k] = PA_VOLUME_NORM;
return 0;
}
@@ -681,7 +677,6 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann
snd_mixer_elem_t *me;
snd_mixer_selem_channel_id_t c;
pa_channel_position_mask_t mask = 0;
- pa_volume_t max_channel_volume = PA_VOLUME_MUTED;
unsigned k;
pa_assert(m);
@@ -771,9 +766,6 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann
f = from_alsa_volume(value, e->min_volume, e->max_volume);
}
- if (f > max_channel_volume)
- max_channel_volume = f;
-
for (k = 0; k < cm->channels; k++)
if (e->masks[c][e->n_channels-1] & PA_CHANNEL_POSITION_MASK(cm->map[k]))
if (rv.values[k] < f)
@@ -784,7 +776,7 @@ static int element_set_volume(pa_alsa_element *e, snd_mixer_t *m, const pa_chann
for (k = 0; k < cm->channels; k++)
if (!(mask & PA_CHANNEL_POSITION_MASK(cm->map[k])))
- rv.values[k] = max_channel_volume;
+ rv.values[k] = PA_VOLUME_NORM;
*v = rv;
return 0;
@@ -1716,11 +1708,11 @@ static int option_verify(pa_alsa_option *o) {
{ "input-radio", N_("Radio") },
{ "input-video", N_("Video") },
{ "input-agc-on", N_("Automatic Gain Control") },
- { "input-agc-off", "" },
+ { "input-agc-off", N_("No Automatic Gain Control") },
{ "input-boost-on", N_("Boost") },
- { "input-boost-off", "" },
+ { "input-boost-off", N_("No Boost") },
{ "output-amplifier-on", N_("Amplifier") },
- { "output-amplifier-off", "" }
+ { "output-amplifier-off", N_("No Amplifier") }
};
pa_assert(o);
diff --git a/src/modules/alsa/mixer/paths/analog-output-headphones.conf b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
index 691cb3f2..61d2e297 100644
--- a/src/modules/alsa/mixer/paths/analog-output-headphones.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-headphones.conf
@@ -56,7 +56,7 @@ volume = off
switch = off
volume = off
-[Element Sourround]
+[Element Surround]
switch = off
volume = off
diff --git a/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf b/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf
index 3457d4a2..911361d7 100644
--- a/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf
@@ -62,7 +62,7 @@ volume = off
switch = off
volume = off
-[Element Sourround]
+[Element Surround]
switch = off
volume = off
diff --git a/src/modules/alsa/mixer/paths/analog-output-mono.conf b/src/modules/alsa/mixer/paths/analog-output-mono.conf
index dc270cfe..2fbc60b7 100644
--- a/src/modules/alsa/mixer/paths/analog-output-mono.conf
+++ b/src/modules/alsa/mixer/paths/analog-output-mono.conf
@@ -59,7 +59,7 @@ volume = off
switch = off
volume = off
-[Element Sourround]
+[Element Surround]
switch = off
volume = off
diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c
index fd9452b4..6bd0f4fc 100644
--- a/src/modules/module-cli.c
+++ b/src/modules/module-cli.c
@@ -25,6 +25,8 @@
#include <stdio.h>
#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
#include <pulsecore/module.h>
#include <pulsecore/iochannel.h>
@@ -33,6 +35,8 @@
#include <pulsecore/log.h>
#include <pulsecore/modargs.h>
#include <pulsecore/macro.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/core-error.h>
#include "module-cli-symdef.h"
@@ -69,6 +73,7 @@ int pa__init(pa_module*m) {
pa_iochannel *io;
pa_modargs *ma;
pa_bool_t exit_on_eof = FALSE;
+ int fd;
pa_assert(m);
@@ -88,15 +93,28 @@ int pa__init(pa_module*m) {
}
if (pa_stdio_acquire() < 0) {
- pa_log("STDIN/STDUSE already in use.");
+ pa_log("STDIN/STDOUT already in use.");
goto fail;
}
- io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
- pa_iochannel_set_noclose(io, 1);
+ /* We try to open the controlling tty anew here. This has the
+ * benefit of giving us a new fd that doesn't share the O_NDELAY
+ * flag with fds 0, 1, or 2. Since pa_iochannel_xxx needs O_NDELAY
+ * on its fd using those fds directly could set O_NDELAY which
+ * fprintf() doesn't really like, resulting in truncated output
+ * of log messages, particularly because if stdout and stderr are
+ * dup'ed they share the same O_NDELAY, too. */
+
+ if ((fd = open("/dev/tty", O_RDWR|O_CLOEXEC|O_NONBLOCK)) >= 0) {
+ io = pa_iochannel_new(m->core->mainloop, fd, fd);
+ pa_log_debug("Managed to open /dev/tty.");
+ } else {
+ io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
+ pa_iochannel_set_noclose(io, TRUE);
+ pa_log_debug("Failed to open /dev/tty, using stdin/stdout fds instead.");
+ }
m->userdata = pa_cli_new(m->core, io, m);
-
pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m);
pa_modargs_free(ma);
@@ -114,7 +132,7 @@ fail:
void pa__done(pa_module*m) {
pa_assert(m);
- if (m->core->running_as_daemon == 0) {
+ if (m->userdata) {
pa_cli_free(m->userdata);
pa_stdio_release();
}
diff --git a/src/modules/module-position-event-sounds.c b/src/modules/module-position-event-sounds.c
index fa8f73d8..7221b14f 100644
--- a/src/modules/module-position-event-sounds.c
+++ b/src/modules/module-position-event-sounds.c
@@ -65,8 +65,9 @@ static int parse_pos(const char *pos, double *f) {
}
if (*f < 0.0 || *f > 1.0) {
- pa_log_warn("Property hpos/vpos out of range %0.2f", *f);
- return -1;
+ pa_log_debug("Property hpos/vpos out of range %0.2f", *f);
+
+ *f = PA_CLAMP(*f, 0.0, 1.0);
}
return 0;
diff --git a/src/modules/raop/module-raop-discover.c b/src/modules/raop/module-raop-discover.c
index eaeb77fc..adba8e4f 100644
--- a/src/modules/raop/module-raop-discover.c
+++ b/src/modules/raop/module-raop-discover.c
@@ -265,7 +265,7 @@ static void browser_cb(
struct tunnel *t2;
if ((t2 = pa_hashmap_get(u->tunnels, t))) {
- pa_module_unload_by_index(u->core, t2->module_index, TRUE);
+ pa_module_unload_request_by_index(u->core, t2->module_index, TRUE);
pa_hashmap_remove(u->tunnels, t2);
tunnel_free(t2);
}
@@ -386,7 +386,7 @@ void pa__done(pa_module*m) {
struct tunnel *t;
while ((t = pa_hashmap_steal_first(u->tunnels))) {
- pa_module_unload_by_index(u->core, t->module_index, TRUE);
+ pa_module_unload_request_by_index(u->core, t->module_index, TRUE);
tunnel_free(t);
}
diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 915c1072..59618064 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -60,7 +60,6 @@ struct pa_rtsp_client {
uint16_t port;
pa_socket_client *sc;
- pa_iochannel *io;
pa_ioline *ioline;
pa_rtsp_cb_t callback;
@@ -111,10 +110,8 @@ void pa_rtsp_client_free(pa_rtsp_client* c) {
if (c->sc)
pa_socket_client_unref(c->sc);
- if (c->ioline)
- pa_ioline_close(c->ioline);
- else if (c->io)
- pa_iochannel_free(c->io);
+
+ pa_rtsp_disconnect(c);
pa_xfree(c->hostname);
pa_xfree(c->url);
@@ -187,7 +184,6 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
if (!s) {
/* Keep the ioline/iochannel open as they will be freed automatically */
c->ioline = NULL;
- c->io = NULL;
c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
return;
}
@@ -303,8 +299,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
pa_log("Connection failed: %s", pa_cstrerror(errno));
return;
}
- pa_assert(!c->io);
- c->io = io;
+ pa_assert(!c->ioline);
c->ioline = pa_ioline_new(io);
pa_ioline_set_callback(c->ioline, line_callback, c);
@@ -360,9 +355,6 @@ void pa_rtsp_disconnect(pa_rtsp_client *c) {
if (c->ioline)
pa_ioline_close(c->ioline);
- else if (c->io)
- pa_iochannel_free(c->io);
- c->io = NULL;
c->ioline = NULL;
}
@@ -408,13 +400,11 @@ static int rtsp_exec(pa_rtsp_client* c, const char* cmd,
pa_headerlist* headers) {
pa_strbuf* buf;
char* hdrs;
- ssize_t l;
pa_assert(c);
pa_assert(c->url);
-
- if (!cmd)
- return -1;
+ pa_assert(cmd);
+ pa_assert(c->ioline);
pa_log_debug("Sending command: %s", cmd);
@@ -453,11 +443,9 @@ static int rtsp_exec(pa_rtsp_client* c, const char* cmd,
hdrs = pa_strbuf_tostring_free(buf);
/*pa_log_debug("Submitting request:");
pa_log_debug(hdrs);*/
- l = pa_iochannel_write(c->io, hdrs, strlen(hdrs));
+ pa_ioline_puts(c->ioline, hdrs);
pa_xfree(hdrs);
- /* FIXME: this is broken, not necessarily all bytes are written */
-
return 0;
}
diff --git a/src/pulse/context.c b/src/pulse/context.c
index 894ab2e0..23ae30ce 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -1045,7 +1045,10 @@ pa_context_state_t pa_context_get_state(pa_context *c) {
}
int pa_context_errno(pa_context *c) {
- pa_assert(c);
+
+ if (!c)
+ return PA_ERR_INVALID;
+
pa_assert(PA_REFCNT_VALUE(c) >= 1);
return c->error;
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 1a7da974..e839bd92 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -95,13 +95,14 @@ static inline int PA_STREAM_IS_GOOD(pa_stream_state_t x) {
typedef enum pa_operation_state {
PA_OPERATION_RUNNING, /**< The operation is still running */
PA_OPERATION_DONE, /**< The operation has been completed */
- PA_OPERATION_CANCELED /**< The operation has been canceled */
+ PA_OPERATION_CANCELLED /**< The operation has been cancelled. Before 0.9.18 this was called PA_OPERATION_CANCELED. That name is still available for compatibility. */
} pa_operation_state_t;
/** \cond fulldocs */
#define PA_OPERATION_RUNNING PA_OPERATION_RUNNING
#define PA_OPERATION_DONE PA_OPERATION_DONE
-#define PA_OPERATION_CANCELED PA_OPERATION_CANCELED
+#define PA_OPERATION_CANCELED PA_OPERATION_CANCELLED
+#define PA_OPERATION_CANCELLED PA_OPERATION_CANCELLED
/** \endcond */
/** An invalid index */
diff --git a/src/pulse/gccmacro.h b/src/pulse/gccmacro.h
index e85ecb66..57e80509 100644
--- a/src/pulse/gccmacro.h
+++ b/src/pulse/gccmacro.h
@@ -118,7 +118,7 @@
#endif
#ifndef PA_GCC_WEAKREF
-#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ > 1)) || (__GNUC__ > 4))
+#if defined(__GNUC__) && defined(__ELF__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ > 1)) || (__GNUC__ > 4))
/** Macro for usgae of GCC's weakref attribute */
#define PA_GCC_WEAKREF(x) __attribute__((weakref(#x)));
#endif
diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c
index 93a4742d..090ac8c2 100644
--- a/src/pulse/mainloop.c
+++ b/src/pulse/mainloop.c
@@ -78,6 +78,7 @@ struct pa_time_event {
pa_bool_t dead:1;
pa_bool_t enabled:1;
+ pa_bool_t use_rtclock:1;
pa_usec_t time;
pa_time_event_cb_t callback;
@@ -112,7 +113,7 @@ struct pa_mainloop {
struct pollfd *pollfds;
unsigned max_pollfds, n_pollfds;
- int prepared_timeout;
+ pa_usec_t prepared_timeout;
pa_time_event *cached_next_time_event;
pa_mainloop_api api;
@@ -172,17 +173,14 @@ static pa_io_event* mainloop_io_new(
m = a->userdata;
pa_assert(a == &m->api);
- e = pa_xnew(pa_io_event, 1);
+ e = pa_xnew0(pa_io_event, 1);
e->mainloop = m;
- e->dead = FALSE;
e->fd = fd;
e->events = events;
- e->pollfd = NULL;
e->callback = callback;
e->userdata = userdata;
- e->destroy_callback = NULL;
#ifdef OS_IS_WIN32
{
@@ -265,16 +263,14 @@ static pa_defer_event* mainloop_defer_new(
m = a->userdata;
pa_assert(a == &m->api);
- e = pa_xnew(pa_defer_event, 1);
+ e = pa_xnew0(pa_defer_event, 1);
e->mainloop = m;
- e->dead = FALSE;
e->enabled = TRUE;
m->n_enabled_defer_events++;
e->callback = callback;
e->userdata = userdata;
- e->destroy_callback = NULL;
PA_LLIST_PREPEND(pa_defer_event, m->defer_events, e);
@@ -320,18 +316,20 @@ static void mainloop_defer_set_destroy(pa_defer_event *e, pa_defer_event_destroy
}
/* Time events */
-static pa_usec_t timeval_load(const struct timeval *tv) {
- pa_bool_t is_rtclock;
+static pa_usec_t make_rt(const struct timeval *tv, pa_bool_t *use_rtclock) {
struct timeval ttv;
- if (!tv)
+ if (!tv) {
+ *use_rtclock = FALSE;
return PA_USEC_INVALID;
+ }
ttv = *tv;
- is_rtclock = !!(ttv.tv_usec & PA_TIMEVAL_RTCLOCK);
- ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK;
+ *use_rtclock = !!(ttv.tv_usec & PA_TIMEVAL_RTCLOCK);
- if (!is_rtclock)
+ if (*use_rtclock)
+ ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK;
+ else
pa_rtclock_from_wallclock(&ttv);
return pa_timeval_load(&ttv);
@@ -346,22 +344,23 @@ static pa_time_event* mainloop_time_new(
pa_mainloop *m;
pa_time_event *e;
pa_usec_t t;
+ pa_bool_t use_rtclock = FALSE;
pa_assert(a);
pa_assert(a->userdata);
pa_assert(callback);
- t = timeval_load(tv);
+ t = make_rt(tv, &use_rtclock);
m = a->userdata;
pa_assert(a == &m->api);
- e = pa_xnew(pa_time_event, 1);
+ e = pa_xnew0(pa_time_event, 1);
e->mainloop = m;
- e->dead = FALSE;
if ((e->enabled = (t != PA_USEC_INVALID))) {
e->time = t;
+ e->use_rtclock= use_rtclock;
m->n_enabled_time_events++;
@@ -375,7 +374,6 @@ static pa_time_event* mainloop_time_new(
e->callback = callback;
e->userdata = userdata;
- e->destroy_callback = NULL;
PA_LLIST_PREPEND(pa_time_event, m->time_events, e);
@@ -388,11 +386,12 @@ static pa_time_event* mainloop_time_new(
static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
pa_bool_t valid;
pa_usec_t t;
+ pa_bool_t use_rtclock = FALSE;
pa_assert(e);
pa_assert(!e->dead);
- t = timeval_load(tv);
+ t = make_rt(tv, &use_rtclock);
valid = (t != PA_USEC_INVALID);
if (e->enabled && !valid) {
@@ -403,6 +402,7 @@ static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
if ((e->enabled = valid)) {
e->time = t;
+ e->use_rtclock = use_rtclock;
pa_mainloop_wakeup(e->mainloop);
}
@@ -480,9 +480,8 @@ pa_mainloop *pa_mainloop_new(void) {
pa_init_i18n();
- m = pa_xnew(pa_mainloop, 1);
+ m = pa_xnew0(pa_mainloop, 1);
- m->wakeup_pipe_type = 0;
if (pipe(m->wakeup_pipe) < 0) {
pa_log_error("ERROR: cannot create wakeup pipe");
pa_xfree(m);
@@ -493,43 +492,23 @@ pa_mainloop *pa_mainloop_new(void) {
pa_make_fd_nonblock(m->wakeup_pipe[1]);
pa_make_fd_cloexec(m->wakeup_pipe[0]);
pa_make_fd_cloexec(m->wakeup_pipe[1]);
- m->wakeup_requested = FALSE;
-
- PA_LLIST_HEAD_INIT(pa_io_event, m->io_events);
- PA_LLIST_HEAD_INIT(pa_time_event, m->time_events);
- PA_LLIST_HEAD_INIT(pa_defer_event, m->defer_events);
-
- m->n_enabled_defer_events = m->n_enabled_time_events = m->n_io_events = 0;
- m->io_events_please_scan = m->time_events_please_scan = m->defer_events_please_scan = 0;
-
- m->cached_next_time_event = NULL;
- m->prepared_timeout = 0;
- m->pollfds = NULL;
- m->max_pollfds = m->n_pollfds = 0;
m->rebuild_pollfds = TRUE;
- m->quit = FALSE;
- m->retval = 0;
-
m->api = vtable;
m->api.userdata = m;
m->state = STATE_PASSIVE;
- m->poll_func = NULL;
- m->poll_func_userdata = NULL;
m->poll_func_ret = -1;
return m;
}
static void cleanup_io_events(pa_mainloop *m, pa_bool_t force) {
- pa_io_event *e;
+ pa_io_event *e, *n;
- e = m->io_events;
- while (e) {
- pa_io_event *n = e->next;
+ PA_LLIST_FOREACH_SAFE(e, n, m->io_events) {
if (!force && m->io_events_please_scan <= 0)
break;
@@ -549,19 +528,15 @@ static void cleanup_io_events(pa_mainloop *m, pa_bool_t force) {
m->rebuild_pollfds = TRUE;
}
-
- e = n;
}
pa_assert(m->io_events_please_scan == 0);
}
static void cleanup_time_events(pa_mainloop *m, pa_bool_t force) {
- pa_time_event *e;
+ pa_time_event *e, *n;
- e = m->time_events;
- while (e) {
- pa_time_event *n = e->next;
+ PA_LLIST_FOREACH_SAFE(e, n, m->time_events) {
if (!force && m->time_events_please_scan <= 0)
break;
@@ -585,19 +560,15 @@ static void cleanup_time_events(pa_mainloop *m, pa_bool_t force) {
pa_xfree(e);
}
-
- e = n;
}
pa_assert(m->time_events_please_scan == 0);
}
static void cleanup_defer_events(pa_mainloop *m, pa_bool_t force) {
- pa_defer_event *e;
+ pa_defer_event *e, *n;
- e = m->defer_events;
- while (e) {
- pa_defer_event *n = e->next;
+ PA_LLIST_FOREACH_SAFE(e, n, m->defer_events) {
if (!force && m->defer_events_please_scan <= 0)
break;
@@ -621,8 +592,6 @@ static void cleanup_defer_events(pa_mainloop *m, pa_bool_t force) {
pa_xfree(e);
}
-
- e = n;
}
pa_assert(m->defer_events_please_scan == 0);
@@ -679,7 +648,7 @@ static void rebuild_pollfds(pa_mainloop *m) {
m->n_pollfds++;
}
- for (e = m->io_events; e; e = e->next) {
+ PA_LLIST_FOREACH(e, m->io_events) {
if (e->dead) {
e->pollfd = NULL;
continue;
@@ -697,36 +666,46 @@ static void rebuild_pollfds(pa_mainloop *m) {
m->rebuild_pollfds = FALSE;
}
-static int dispatch_pollfds(pa_mainloop *m) {
+static unsigned dispatch_pollfds(pa_mainloop *m) {
pa_io_event *e;
- int r = 0, k;
+ unsigned r = 0, k;
pa_assert(m->poll_func_ret > 0);
- for (e = m->io_events, k = m->poll_func_ret; e && !m->quit && k > 0; e = e->next) {
+ k = m->poll_func_ret;
+
+ PA_LLIST_FOREACH(e, m->io_events) {
+
+ if (k <= 0 || m->quit)
+ break;
+
if (e->dead || !e->pollfd || !e->pollfd->revents)
continue;
pa_assert(e->pollfd->fd == e->fd);
pa_assert(e->callback);
+
e->callback(&m->api, e, e->fd, map_flags_from_libc(e->pollfd->revents), e->userdata);
e->pollfd->revents = 0;
r++;
-
k--;
}
return r;
}
-static int dispatch_defer(pa_mainloop *m) {
+static unsigned dispatch_defer(pa_mainloop *m) {
pa_defer_event *e;
- int r = 0;
+ unsigned r = 0;
if (m->n_enabled_defer_events <= 0)
return 0;
- for (e = m->defer_events; e && !m->quit; e = e->next) {
+ PA_LLIST_FOREACH(e, m->defer_events) {
+
+ if (m->quit)
+ break;
+
if (e->dead || !e->enabled)
continue;
@@ -745,7 +724,7 @@ static pa_time_event* find_next_time_event(pa_mainloop *m) {
if (m->cached_next_time_event)
return m->cached_next_time_event;
- for (t = m->time_events; t; t = t->next) {
+ PA_LLIST_FOREACH(t, m->time_events) {
if (t->dead || !t->enabled)
continue;
@@ -763,12 +742,12 @@ static pa_time_event* find_next_time_event(pa_mainloop *m) {
return n;
}
-static int calc_next_timeout(pa_mainloop *m) {
+static pa_usec_t calc_next_timeout(pa_mainloop *m) {
pa_time_event *t;
pa_usec_t clock_now;
- if (!m->n_enabled_time_events)
- return -1;
+ if (m->n_enabled_time_events <= 0)
+ return PA_USEC_INVALID;
pa_assert_se(t = find_next_time_event(m));
@@ -780,13 +759,13 @@ static int calc_next_timeout(pa_mainloop *m) {
if (t->time <= clock_now)
return 0;
- return (int) ((t->time - clock_now) / 1000); /* in milliseconds */
+ return t->time - clock_now;
}
-static int dispatch_timeout(pa_mainloop *m) {
+static unsigned dispatch_timeout(pa_mainloop *m) {
pa_time_event *e;
pa_usec_t now;
- int r = 0;
+ unsigned r = 0;
pa_assert(m);
if (m->n_enabled_time_events <= 0)
@@ -794,7 +773,10 @@ static int dispatch_timeout(pa_mainloop *m) {
now = pa_rtclock_now();
- for (e = m->time_events; e && !m->quit; e = e->next) {
+ PA_LLIST_FOREACH(e, m->time_events) {
+
+ if (m->quit)
+ break;
if (e->dead || !e->enabled)
continue;
@@ -806,7 +788,7 @@ static int dispatch_timeout(pa_mainloop *m) {
/* Disable time event */
mainloop_time_restart(e, NULL);
- e->callback(&m->api, e, pa_timeval_rtstore(&tv, e->time, TRUE), e->userdata);
+ e->callback(&m->api, e, pa_timeval_rtstore(&tv, e->time, e->use_rtclock), e->userdata);
r++;
}
@@ -834,7 +816,8 @@ static void clear_wakeup(pa_mainloop *m) {
return;
if (m->wakeup_requested) {
- while (pa_read(m->wakeup_pipe[0], &c, sizeof(c), &m->wakeup_pipe_type) == sizeof(c));
+ while (pa_read(m->wakeup_pipe[0], &c, sizeof(c), &m->wakeup_pipe_type) == sizeof(c))
+ ;
m->wakeup_requested = 0;
}
}
@@ -850,12 +833,17 @@ int pa_mainloop_prepare(pa_mainloop *m, int timeout) {
goto quit;
if (m->n_enabled_defer_events <= 0) {
+
if (m->rebuild_pollfds)
rebuild_pollfds(m);
m->prepared_timeout = calc_next_timeout(m);
- if (timeout >= 0 && (timeout < m->prepared_timeout || m->prepared_timeout < 0))
- m->prepared_timeout = timeout;
+ if (timeout >= 0) {
+ uint64_t u = (uint64_t) timeout * PA_USEC_PER_MSEC;
+
+ if (u < m->prepared_timeout || m->prepared_timeout == PA_USEC_INVALID)
+ m->prepared_timeout = timeout;
+ }
}
m->state = STATE_PREPARED;
@@ -866,6 +854,13 @@ quit:
return -2;
}
+static int usec_to_timeout(pa_usec_t u) {
+ if (u == PA_USEC_INVALID)
+ return -1;
+
+ return (u + PA_USEC_PER_MSEC - 1) / PA_USEC_PER_MSEC;
+}
+
int pa_mainloop_poll(pa_mainloop *m) {
pa_assert(m);
pa_assert(m->state == STATE_PREPARED);
@@ -881,9 +876,24 @@ int pa_mainloop_poll(pa_mainloop *m) {
pa_assert(!m->rebuild_pollfds);
if (m->poll_func)
- m->poll_func_ret = m->poll_func(m->pollfds, m->n_pollfds, m->prepared_timeout, m->poll_func_userdata);
- else
- m->poll_func_ret = poll(m->pollfds, m->n_pollfds, m->prepared_timeout);
+ m->poll_func_ret = m->poll_func(
+ m->pollfds, m->n_pollfds,
+ usec_to_timeout(m->prepared_timeout),
+ m->poll_func_userdata);
+ else {
+#ifdef HAVE_PPOLL
+ struct timespec ts;
+
+ m->poll_func_ret = ppoll(
+ m->pollfds, m->n_pollfds,
+ m->prepared_timeout == PA_USEC_INVALID ? NULL : pa_timespec_store(&ts, m->prepared_timeout),
+ NULL);
+#else
+ m->poll_func_ret = poll(
+ m->pollfds, m->n_pollfds,
+ usec_to_timeout(m->prepared_timeout));
+#endif
+ }
if (m->poll_func_ret < 0) {
if (errno == EINTR)
@@ -902,7 +912,7 @@ quit:
}
int pa_mainloop_dispatch(pa_mainloop *m) {
- int dispatched = 0;
+ unsigned dispatched = 0;
pa_assert(m);
pa_assert(m->state == STATE_POLLED);
@@ -928,7 +938,7 @@ int pa_mainloop_dispatch(pa_mainloop *m) {
m->state = STATE_PASSIVE;
- return dispatched;
+ return (int) dispatched;
quit:
m->state = STATE_QUIT;
@@ -937,6 +947,7 @@ quit:
int pa_mainloop_get_retval(pa_mainloop *m) {
pa_assert(m);
+
return m->retval;
}
@@ -965,7 +976,8 @@ quit:
int pa_mainloop_run(pa_mainloop *m, int *retval) {
int r;
- while ((r = pa_mainloop_iterate(m, 1, retval)) >= 0);
+ while ((r = pa_mainloop_iterate(m, 1, retval)) >= 0)
+ ;
if (r == -2)
return 1;
@@ -985,6 +997,7 @@ void pa_mainloop_quit(pa_mainloop *m, int retval) {
pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m) {
pa_assert(m);
+
return &m->api;
}
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 8bf9c482..8dff8df4 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -115,6 +115,9 @@ PA_C_DECL_BEGIN
/** For streams that belong to a window on the screen: relative position of the window center on the screen, float formatted as text string, ranging from 0.0 (top of the screen) to 1.0 (bottom of the screen). e.g. "0.43". \since 0.9.17 */
#define PA_PROP_WINDOW_VPOS "window.vpos"
+/** For streams that belong to a window on the screen: if the windowing system supports multiple desktops, a comma seperated list of indexes of the desktops this window is visible on. If this property is an empty string, it is visible on all desktops (i.e. 'sticky'). The first desktop is 0. e.g. "0,2,3" \since 0.9.18 */
+#define PA_PROP_WINDOW_DESKTOP "window.desktop"
+
/** For streams that belong to an X11 window on the screen: the X11 display string. e.g. ":0.0" */
#define PA_PROP_WINDOW_X11_DISPLAY "window.x11.display"
diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c
index 376cf13c..cde4417c 100644
--- a/src/pulse/timeval.c
+++ b/src/pulse/timeval.c
@@ -33,6 +33,7 @@
#include <pulsecore/winsock.h>
#include <pulsecore/macro.h>
+#include <pulsecore/core-util.h>
#include "timeval.h"
@@ -54,9 +55,9 @@ struct timeval *pa_gettimeofday(struct timeval *tv) {
#define EPOCHFILETIME (116444736000000000LL)
#endif
- FILETIME ft;
- LARGE_INTEGER li;
- __int64 t;
+ FILETIME ft;
+ LARGE_INTEGER li;
+ int64_t t;
pa_assert(tv);
@@ -82,7 +83,7 @@ pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
pa_assert(b);
/* Check which whan is the earlier time and swap the two arguments if required. */
- if (pa_timeval_cmp(a, b) < 0) {
+ if (PA_UNLIKELY(pa_timeval_cmp(a, b) < 0)) {
const struct timeval *c;
c = a;
a = b;
@@ -94,9 +95,9 @@ pa_usec_t pa_timeval_diff(const struct timeval *a, const struct timeval *b) {
/* Calculate the microsecond difference */
if (a->tv_usec > b->tv_usec)
- r += ((pa_usec_t) a->tv_usec - (pa_usec_t) b->tv_usec);
+ r += (pa_usec_t) a->tv_usec - (pa_usec_t) b->tv_usec;
else if (a->tv_usec < b->tv_usec)
- r -= ((pa_usec_t) b->tv_usec - (pa_usec_t) a->tv_usec);
+ r -= (pa_usec_t) b->tv_usec - (pa_usec_t) a->tv_usec;
return r;
}
@@ -128,45 +129,77 @@ pa_usec_t pa_timeval_age(const struct timeval *tv) {
}
struct timeval* pa_timeval_add(struct timeval *tv, pa_usec_t v) {
- unsigned long secs;
+ time_t secs;
pa_assert(tv);
- secs = (unsigned long) (v/PA_USEC_PER_SEC);
- tv->tv_sec += (time_t) secs;
- v -= ((pa_usec_t) secs) * PA_USEC_PER_SEC;
+ secs = (time_t) (v/PA_USEC_PER_SEC);
+ if (PA_UNLIKELY(tv->tv_sec > PA_INT_TYPE_MAX(time_t) - secs))
+ goto overflow;
+
+ tv->tv_sec += secs;
+ v -= (pa_usec_t) secs * PA_USEC_PER_SEC;
tv->tv_usec += (suseconds_t) v;
/* Normalize */
- while ((unsigned) tv->tv_usec >= PA_USEC_PER_SEC) {
+ while ((pa_usec_t) tv->tv_usec >= PA_USEC_PER_SEC) {
+
+ if (PA_UNLIKELY(tv->tv_sec >= PA_INT_TYPE_MAX(time_t)))
+ goto overflow;
+
tv->tv_sec++;
tv->tv_usec -= (suseconds_t) PA_USEC_PER_SEC;
}
return tv;
+
+overflow:
+ tv->tv_sec = PA_INT_TYPE_MAX(time_t);
+ tv->tv_usec = (suseconds_t) (PA_USEC_PER_SEC-1);
+ return tv;
}
struct timeval* pa_timeval_sub(struct timeval *tv, pa_usec_t v) {
- unsigned long secs;
+ time_t secs;
pa_assert(tv);
- secs = (unsigned long) (v/PA_USEC_PER_SEC);
- tv->tv_sec -= (time_t) secs;
- v -= ((pa_usec_t) secs) * PA_USEC_PER_SEC;
+ secs = (time_t) (v/PA_USEC_PER_SEC);
+
+ if (PA_UNLIKELY(tv->tv_sec < secs))
+ goto underflow;
+
+ tv->tv_sec -= secs;
+ v -= (pa_usec_t) secs * PA_USEC_PER_SEC;
if (tv->tv_usec >= (suseconds_t) v)
tv->tv_usec -= (suseconds_t) v;
else {
+
+ if (PA_UNLIKELY(tv->tv_sec <= 0))
+ goto underflow;
+
tv->tv_sec --;
tv->tv_usec += (suseconds_t) (PA_USEC_PER_SEC - v);
}
return tv;
+
+underflow:
+ tv->tv_sec = 0;
+ tv->tv_usec = 0;
+ return tv;
}
struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v) {
pa_assert(tv);
+ if (PA_UNLIKELY(v == PA_USEC_INVALID)) {
+ tv->tv_sec = PA_INT_TYPE_MAX(time_t);
+ tv->tv_usec = (suseconds_t) (PA_USEC_PER_SEC-1);
+
+ return tv;
+ }
+
tv->tv_sec = (time_t) (v / PA_USEC_PER_SEC);
tv->tv_usec = (suseconds_t) (v % PA_USEC_PER_SEC);
@@ -174,7 +207,9 @@ struct timeval* pa_timeval_store(struct timeval *tv, pa_usec_t v) {
}
pa_usec_t pa_timeval_load(const struct timeval *tv) {
- pa_assert(tv);
+
+ if (PA_UNLIKELY(!tv))
+ return PA_USEC_INVALID;
return
(pa_usec_t) tv->tv_sec * PA_USEC_PER_SEC +
diff --git a/src/pulse/timeval.h b/src/pulse/timeval.h
index 48c6cdb3..3cea5d3b 100644
--- a/src/pulse/timeval.h
+++ b/src/pulse/timeval.h
@@ -51,12 +51,15 @@ PA_C_DECL_BEGIN
/** The number of nanoseconds in a microsecond */
#define PA_NSEC_PER_USEC ((unsigned long long) 1000ULL)
-/** Invalid time in usec */
+/** Invalid time in usec. \since 0.9.15 */
#define PA_USEC_INVALID ((pa_usec_t) -1)
+/** Biggest time in usec. \since 0.9.18 */
+#define PA_USEC_MAX ((pa_usec_t) -2)
+
struct timeval;
-/** Return the current timestamp, just like UNIX gettimeofday() */
+/** Return the current wallclock timestamp, just like UNIX gettimeofday(). */
struct timeval *pa_gettimeofday(struct timeval *tv);
/** Calculate the difference between the two specified timeval
diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c
index 3b3e3a64..1420470a 100644
--- a/src/pulsecore/core-rtclock.c
+++ b/src/pulsecore/core-rtclock.c
@@ -132,6 +132,8 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) {
pa_assert(tv);
+ /* pa_timeval_sub() saturates on underflow! */
+
if (pa_timeval_cmp(&wc_now, tv) < 0)
pa_timeval_add(&rt_now, pa_timeval_diff(tv, &wc_now));
else
@@ -144,13 +146,29 @@ struct timeval* pa_rtclock_from_wallclock(struct timeval *tv) {
}
pa_usec_t pa_timespec_load(const struct timespec *ts) {
- pa_assert(ts);
+
+ if (PA_UNLIKELY(!ts))
+ return PA_USEC_INVALID;
return
(pa_usec_t) ts->tv_sec * PA_USEC_PER_SEC +
(pa_usec_t) ts->tv_nsec / PA_NSEC_PER_USEC;
}
+struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v) {
+ pa_assert(ts);
+
+ if (PA_UNLIKELY(v == PA_USEC_INVALID)) {
+ ts->tv_sec = PA_INT_TYPE_MAX(time_t);
+ ts->tv_nsec = (long) (PA_NSEC_PER_SEC-1);
+ return NULL;
+ }
+
+ ts->tv_sec = (time_t) (v / PA_USEC_PER_SEC);
+ ts->tv_nsec = (long) ((v % PA_USEC_PER_SEC) * PA_NSEC_PER_USEC);
+
+ return ts;
+}
static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
@@ -162,6 +180,8 @@ static struct timeval* wallclock_from_rtclock(struct timeval *tv) {
pa_assert(tv);
+ /* pa_timeval_sub() saturates on underflow! */
+
if (pa_timeval_cmp(&rt_now, tv) < 0)
pa_timeval_add(&wc_now, pa_timeval_diff(tv, &rt_now));
else
diff --git a/src/pulsecore/core-rtclock.h b/src/pulsecore/core-rtclock.h
index 9f5ae2dd..3b393ed5 100644
--- a/src/pulsecore/core-rtclock.h
+++ b/src/pulsecore/core-rtclock.h
@@ -44,6 +44,7 @@ void pa_rtclock_hrtimer_enable(void);
struct timeval* pa_rtclock_from_wallclock(struct timeval *tv);
pa_usec_t pa_timespec_load(const struct timespec *ts);
+struct timespec* pa_timespec_store(struct timespec *ts, pa_usec_t v);
struct timeval* pa_timeval_rtstore(struct timeval *tv, pa_usec_t v, pa_bool_t rtclock);
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 7a9f458c..8e98e857 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1378,19 +1378,10 @@ static char* make_random_dir(mode_t m) {
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
- const char *tmpdir;
char *fn;
size_t pathlen;
- if (!(tmpdir = getenv("TMPDIR")))
- if (!(tmpdir = getenv("TMP")))
- if (!(tmpdir = getenv("TEMP")))
- tmpdir = getenv("TEMPDIR");
-
- if (!tmpdir || !pa_is_path_absolute(tmpdir))
- tmpdir = "/tmp";
-
- fn = pa_sprintf_malloc("%s/pulse-XXXXXXXXXXXX", tmpdir);
+ fn = pa_sprintf_malloc("%s" PA_PATH_SEP "pulse-XXXXXXXXXXXX", pa_get_temp_dir());
pathlen = strlen(fn);
for (;;) {
@@ -2854,3 +2845,25 @@ pa_bool_t pa_run_from_build_tree(void) {
}
#endif
+
+const char *pa_get_temp_dir(void) {
+ const char *t;
+
+ if ((t = getenv("TMPDIR")) &&
+ pa_is_path_absolute(t))
+ return t;
+
+ if ((t = getenv("TMP")) &&
+ pa_is_path_absolute(t))
+ return t;
+
+ if ((t = getenv("TEMP")) &&
+ pa_is_path_absolute(t))
+ return t;
+
+ if ((t = getenv("TEMPDIR")) &&
+ pa_is_path_absolute(t))
+ return t;
+
+ return "/tmp";
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index ccc9a38e..84752d4d 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -249,4 +249,6 @@ void pa_reset_personality(void);
pa_bool_t pa_run_from_build_tree(void);
#endif
+const char *pa_get_temp_dir(void);
+
#endif
diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index bffcc264..9a5a2670 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -304,6 +304,18 @@ typedef int pa_bool_t;
#define pa_memzero(x,l) (memset((x), 0, (l)))
#define pa_zero(x) (pa_memzero(&(x), sizeof(x)))
+#define PA_INT_TYPE_SIGNED(type) (!!((type) 0 > (type) -1))
+
+#define PA_INT_TYPE_MAX(type) \
+ ((type) (PA_INT_TYPE_SIGNED(type) \
+ ? ~(~(type) 0 << (8*sizeof(type)-1)) \
+ : (type) -1))
+
+#define PA_INT_TYPE_MIN(type) \
+ ((type) (PA_INT_TYPE_SIGNED(type) \
+ ? (~(type) 0 << (8*sizeof(type)-1)) \
+ : (type) 0))
+
/* We include this at the very last place */
#include <pulsecore/log.h>
diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
index 0e40d12b..f38b17c6 100644
--- a/src/pulsecore/memblock.c
+++ b/src/pulsecore/memblock.c
@@ -303,10 +303,17 @@ static struct mempool_slot* mempool_slot_by_ptr(pa_mempool *p, void *ptr) {
pa_memblock *pa_memblock_new_pool(pa_mempool *p, size_t length) {
pa_memblock *b = NULL;
struct mempool_slot *slot;
+ static int mempool_disable = 0;
pa_assert(p);
pa_assert(length);
+ if (mempool_disable == 0)
+ mempool_disable = getenv("PULSE_MEMPOOL_DISABLE") ? 1 : -1;
+
+ if (mempool_disable > 0)
+ return NULL;
+
/* If -1 is passed as length we choose the size for the caller: we
* take the largest size that fits in one of our slots. */
@@ -361,6 +368,7 @@ pa_memblock *pa_memblock_new_fixed(pa_mempool *p, void *d, size_t length, pa_boo
if (!(b = pa_flist_pop(PA_STATIC_FLIST_GET(unused_memblocks))))
b = pa_xnew(pa_memblock, 1);
+
PA_REFCNT_INIT(b);
b->pool = p;
b->type = PA_MEMBLOCK_FIXED;
@@ -387,6 +395,7 @@ pa_memblock *pa_memblock_new_user(pa_mempool *p, void *d, size_t length, pa_free
if (!(b = pa_flist_pop(PA_STATIC_FLIST_GET(unused_memblocks))))
b = pa_xnew(pa_memblock, 1);
+
PA_REFCNT_INIT(b);
b->pool = p;
b->type = PA_MEMBLOCK_USER;
@@ -499,13 +508,19 @@ static void memblock_free(pa_memblock *b) {
/* Fall through */
case PA_MEMBLOCK_FIXED:
- case PA_MEMBLOCK_APPENDED :
if (pa_flist_push(PA_STATIC_FLIST_GET(unused_memblocks), b) < 0)
pa_xfree(b);
break;
- case PA_MEMBLOCK_IMPORTED : {
+ case PA_MEMBLOCK_APPENDED:
+
+ /* We could attached it unused_memblocks, but that would
+ * probably waste some considerable memory */
+ pa_xfree(b);
+ break;
+
+ case PA_MEMBLOCK_IMPORTED: {
pa_memimport_segment *segment;
pa_memimport *import;
@@ -539,8 +554,7 @@ static void memblock_free(pa_memblock *b) {
struct mempool_slot *slot;
pa_bool_t call_free;
- slot = mempool_slot_by_ptr(b->pool, pa_atomic_ptr_load(&b->data));
- pa_assert(slot);
+ pa_assert_se(slot = mempool_slot_by_ptr(b->pool, pa_atomic_ptr_load(&b->data)));
call_free = b->type == PA_MEMBLOCK_POOL_EXTERNAL;
@@ -891,7 +905,7 @@ static pa_memimport_segment* segment_attach(pa_memimport *i, uint32_t shm_id) {
if (pa_hashmap_size(i->segments) >= PA_MEMIMPORT_SEGMENTS_MAX)
return NULL;
- seg = pa_xnew(pa_memimport_segment, 1);
+ seg = pa_xnew0(pa_memimport_segment, 1);
if (pa_shm_attach_ro(&seg->memory, shm_id) < 0) {
pa_xfree(seg);
@@ -899,10 +913,9 @@ static pa_memimport_segment* segment_attach(pa_memimport *i, uint32_t shm_id) {
}
seg->import = i;
- seg->n_blocks = 0;
seg->trap = pa_memtrap_add(seg->memory.ptr, seg->memory.size);
- pa_hashmap_put(i->segments, PA_UINT32_TO_PTR(shm_id), seg);
+ pa_hashmap_put(i->segments, PA_UINT32_TO_PTR(seg->memory.id), seg);
return seg;
}
diff --git a/src/pulsecore/socket-client.c b/src/pulsecore/socket-client.c
index c9cfdbe3..b9d69505 100644
--- a/src/pulsecore/socket-client.c
+++ b/src/pulsecore/socket-client.c
@@ -73,14 +73,18 @@
struct pa_socket_client {
PA_REFCNT_DECLARE;
- pa_mainloop_api *mainloop;
int fd;
+
+ pa_mainloop_api *mainloop;
pa_io_event *io_event;
pa_time_event *timeout_event;
pa_defer_event *defer_event;
+
pa_socket_client_cb_t callback;
void *userdata;
+
pa_bool_t local;
+
#ifdef HAVE_LIBASYNCNS
asyncns_t *asyncns;
asyncns_query_t * asyncns_query;
@@ -92,22 +96,10 @@ static pa_socket_client* socket_client_new(pa_mainloop_api *m) {
pa_socket_client *c;
pa_assert(m);
- c = pa_xnew(pa_socket_client, 1);
+ c = pa_xnew0(pa_socket_client, 1);
PA_REFCNT_INIT(c);
c->mainloop = m;
c->fd = -1;
- c->io_event = NULL;
- c->timeout_event = NULL;
- c->defer_event = NULL;
- c->callback = NULL;
- c->userdata = NULL;
- c->local = FALSE;
-
-#ifdef HAVE_LIBASYNCNS
- c->asyncns = NULL;
- c->asyncns_io_event = NULL;
- c->asyncns_query = NULL;
-#endif
return c;
}
@@ -163,7 +155,6 @@ static void do_call(pa_socket_client *c) {
}
io = pa_iochannel_new(c->mainloop, c->fd, c->fd);
- pa_assert(io);
finish:
if (!io && c->fd >= 0)
@@ -172,7 +163,6 @@ finish:
free_events(c);
- pa_assert(c->callback);
c->callback(c, io, c->userdata);
pa_socket_client_unref(c);
@@ -220,9 +210,9 @@ static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t
return -1;
}
- pa_assert_se(c->io_event = c->mainloop->io_new(c->mainloop, c->fd, PA_IO_EVENT_OUTPUT, connect_io_cb, c));
+ c->io_event = c->mainloop->io_new(c->mainloop, c->fd, PA_IO_EVENT_OUTPUT, connect_io_cb, c);
} else
- pa_assert_se(c->defer_event = c->mainloop->defer_new(c->mainloop, connect_defer_cb, c));
+ c->defer_event = c->mainloop->defer_new(c->mainloop, connect_defer_cb, c);
return 0;
}
@@ -233,7 +223,7 @@ pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address
pa_assert(m);
pa_assert(port > 0);
- memset(&sa, 0, sizeof(sa));
+ pa_zero(sa);
sa.sin_family = AF_INET;
sa.sin_port = htons(port);
sa.sin_addr.s_addr = htonl(address);
@@ -241,28 +231,24 @@ pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address
return pa_socket_client_new_sockaddr(m, (struct sockaddr*) &sa, sizeof(sa));
}
-#ifdef HAVE_SYS_UN_H
pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename) {
+#ifdef HAVE_SYS_UN_H
struct sockaddr_un sa;
pa_assert(m);
pa_assert(filename);
- memset(&sa, 0, sizeof(sa));
+ pa_zero(sa);
sa.sun_family = AF_UNIX;
pa_strlcpy(sa.sun_path, filename, sizeof(sa.sun_path));
return pa_socket_client_new_sockaddr(m, (struct sockaddr*) &sa, sizeof(sa));
-}
-
#else /* HAVE_SYS_UN_H */
-pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename) {
return NULL;
-}
-
#endif /* HAVE_SYS_UN_H */
+}
static int sockaddr_prepare(pa_socket_client *c, const struct sockaddr *sa, size_t salen) {
pa_assert(c);
@@ -300,7 +286,7 @@ pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct
pa_assert(sa);
pa_assert(salen > 0);
- pa_assert_se(c = socket_client_new(m));
+ c = socket_client_new(m);
if (sockaddr_prepare(c, sa, salen) < 0)
goto fail;
@@ -357,22 +343,25 @@ void pa_socket_client_set_callback(pa_socket_client *c, pa_socket_client_cb_t on
c->userdata = userdata;
}
-#ifdef HAVE_IPV6
pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port) {
+#ifdef HAVE_IPV6
struct sockaddr_in6 sa;
pa_assert(m);
pa_assert(address);
pa_assert(port > 0);
- memset(&sa, 0, sizeof(sa));
+ pa_zero(sa);
sa.sin6_family = AF_INET6;
sa.sin6_port = htons(port);
memcpy(&sa.sin6_addr, address, sizeof(sa.sin6_addr));
return pa_socket_client_new_sockaddr(m, (struct sockaddr*) &sa, sizeof(sa));
-}
+
+#else
+ return NULL;
#endif
+}
#ifdef HAVE_LIBASYNCNS
@@ -466,14 +455,13 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, pa_bool_t use_
case PA_PARSED_ADDRESS_TCP4: /* Fallthrough */
case PA_PARSED_ADDRESS_TCP6: /* Fallthrough */
- case PA_PARSED_ADDRESS_TCP_AUTO:{
-
+ case PA_PARSED_ADDRESS_TCP_AUTO: {
struct addrinfo hints;
char port[12];
pa_snprintf(port, sizeof(port), "%u", (unsigned) a.port);
- memset(&hints, 0, sizeof(hints));
+ pa_zero(hints);
if (a.type == PA_PARSED_ADDRESS_TCP4)
hints.ai_family = PF_INET;
#ifdef HAVE_IPV6
@@ -492,11 +480,10 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, pa_bool_t use_
if (!(asyncns = asyncns_new(1)))
goto finish;
- pa_assert_se(c = socket_client_new(m));
+ c = socket_client_new(m);
c->asyncns = asyncns;
c->asyncns_io_event = m->io_new(m, asyncns_fd(c->asyncns), PA_IO_EVENT_INPUT, asyncns_cb, c);
- c->asyncns_query = asyncns_getaddrinfo(c->asyncns, a.path_or_host, port, &hints);
- pa_assert(c->asyncns_query);
+ pa_assert_se(c->asyncns_query = asyncns_getaddrinfo(c->asyncns, a.path_or_host, port, &hints));
start_timeout(c, use_rtclock);
}
#elif defined(HAVE_GETADDRINFO)
@@ -539,6 +526,7 @@ pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, pa_bool_t use_
if (!host)
goto finish;
+ pa_zero(sa);
s.sin_family = AF_INET;
memcpy(&s.sin_addr, host->h_addr, sizeof(struct in_addr));
s.sin_port = htons(a.port);
diff --git a/src/pulsecore/socket-client.h b/src/pulsecore/socket-client.h
index b896afa9..138f658c 100644
--- a/src/pulsecore/socket-client.h
+++ b/src/pulsecore/socket-client.h
@@ -35,9 +35,7 @@ typedef struct pa_socket_client pa_socket_client;
typedef void (*pa_socket_client_cb_t)(pa_socket_client *c, pa_iochannel*io, void *userdata);
pa_socket_client* pa_socket_client_new_ipv4(pa_mainloop_api *m, uint32_t address, uint16_t port);
-#ifdef HAVE_IPV6
pa_socket_client* pa_socket_client_new_ipv6(pa_mainloop_api *m, uint8_t address[16], uint16_t port);
-#endif
pa_socket_client* pa_socket_client_new_unix(pa_mainloop_api *m, const char *filename);
pa_socket_client* pa_socket_client_new_sockaddr(pa_mainloop_api *m, const struct sockaddr *sa, size_t salen);
pa_socket_client* pa_socket_client_new_string(pa_mainloop_api *m, pa_bool_t use_rtclock, const char *a, uint16_t default_port);
diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c
index 74918e78..62f3397e 100644
--- a/src/pulsecore/svolume_mmx.c
+++ b/src/pulsecore/svolume_mmx.c
@@ -57,14 +57,12 @@
" punpcklwd %%mm4, "#s" \n\t" /* .. | 0 | p0 | */ \
" pcmpgtw "#v", %%mm4 \n\t" /* .. | 0 | s(vl) | */ \
" pand "#s", %%mm4 \n\t" /* .. | 0 | (p0) | (vl >> 15) & p */ \
- " movq %%mm6, %%mm5 \n\t" /* .. | ffff | 0 | */ \
- " pand "#v", %%mm5 \n\t" /* .. | vh | 0 | */ \
- " por %%mm5, %%mm4 \n\t" /* .. | vh | (p0) | */ \
- " pmulhw "#s", "#v" \n\t" /* .. | 0 | vl*p0 | */ \
- " paddw %%mm4, "#v" \n\t" /* .. | vh | vl*p0 | vh + sign correct */ \
- " pslld $16, "#s" \n\t" /* .. | p0 | 0 | */ \
- " por %%mm7, "#s" \n\t" /* .. | p0 | 1 | */ \
- " pmaddwd "#s", "#v" \n\t" /* .. | p0 * v0 | */ \
+ " movq "#s", %%mm5 \n\t" \
+ " pmulhw "#v", "#s" \n\t" /* .. | 0 | vl*p0 | */ \
+ " paddw %%mm4, "#s" \n\t" /* .. | 0 | vl*p0 | + sign correct */ \
+ " psrld $16, "#v" \n\t" /* .. | 0 | vh | */ \
+ " pmaddwd %%mm5, "#v" \n\t" /* .. | p0 * vh | */ \
+ " paddd "#s", "#v" \n\t" /* .. | p0 * v0 | */ \
" packssdw "#v", "#v" \n\t" /* .. | p1*v1 | p0*v0 | */
/* approximately advances %3 = (%3 + a) % b. This function requires that
@@ -105,10 +103,6 @@ pa_volume_s16ne_mmx (int16_t *samples, int32_t *volumes, unsigned channels, unsi
__asm__ __volatile__ (
" xor %3, %3 \n\t"
" sar $1, %2 \n\t" /* length /= sizeof (int16_t) */
- " pcmpeqw %%mm6, %%mm6 \n\t" /* .. | ffff | ffff | */
- " pcmpeqw %%mm7, %%mm7 \n\t" /* .. | ffff | ffff | */
- " pslld $16, %%mm6 \n\t" /* .. | ffff | 0 | */
- " psrld $31, %%mm7 \n\t" /* .. | 0 | 1 | */
" test $1, %2 \n\t" /* check for odd samples */
" je 2f \n\t"
diff --git a/src/pulsecore/svolume_sse.c b/src/pulsecore/svolume_sse.c
index bbd73a9b..5276bda4 100644
--- a/src/pulsecore/svolume_sse.c
+++ b/src/pulsecore/svolume_sse.c
@@ -45,7 +45,7 @@
" movdqa "#s", %%xmm5 \n\t" \
" pmulhuw "#v", "#s" \n\t" /* .. | 0 | vl*p0 | */ \
" psubd %%xmm4, "#s" \n\t" /* .. | 0 | vl*p0 | + sign correct */ \
- " psrld $16, "#v" \n\t" /* .. | p0 | 0 | */ \
+ " psrld $16, "#v" \n\t" /* .. | 0 | vh | */ \
" pmaddwd %%xmm5, "#v" \n\t" /* .. | p0 * vh | */ \
" paddd "#s", "#v" \n\t" /* .. | p0 * v0 | */ \
" packssdw "#v", "#v" \n\t" /* .. | p1*v1 | p0*v0 | */
diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index 781bfa33..5f29ba39 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -430,14 +430,18 @@ static void context_state_callback(pa_context *c, void *userdata) {
pa_stream_set_event_callback(stream, stream_event_callback, NULL);
pa_stream_set_buffer_attr_callback(stream, stream_buffer_attr_callback, NULL);
+ pa_zero(buffer_attr);
+ buffer_attr.maxlength = (uint32_t) -1;
+ buffer_attr.prebuf = (uint32_t) -1;
+
if (latency > 0) {
- memset(&buffer_attr, 0, sizeof(buffer_attr));
- buffer_attr.tlength = (uint32_t) latency;
+ buffer_attr.fragsize = buffer_attr.tlength = (uint32_t) latency;
buffer_attr.minreq = (uint32_t) process_time;
- buffer_attr.maxlength = (uint32_t) -1;
- buffer_attr.prebuf = (uint32_t) -1;
- buffer_attr.fragsize = (uint32_t) latency;
flags |= PA_STREAM_ADJUST_LATENCY;
+ } else {
+ buffer_attr.tlength = (uint32_t) -1;
+ buffer_attr.minreq = (uint32_t) -1;
+ buffer_attr.fragsize = (uint32_t) -1;
}
if (mode == PLAYBACK) {
diff --git a/src/utils/padsp.c b/src/utils/padsp.c
index 41bfd741..2ed0a039 100644
--- a/src/utils/padsp.c
+++ b/src/utils/padsp.c
@@ -1394,11 +1394,13 @@ static int sndstat_open(int flags, int *_errno) {
"Mixers:\n"
"0: PulseAudio Virtual OSS\n";
- char fn[] = "/tmp/padsp-sndstat-XXXXXX";
+ char *fn;
mode_t u;
int fd = -1;
int e;
+ fn = pa_sprintf_malloc("%s" PA_PATH_SEP "padsp-sndstat-XXXXXX", pa_get_temp_dir());
+
debug(DEBUG_LEVEL_NORMAL, __FILE__": sndstat_open()\n");
if (flags != O_RDONLY
@@ -1423,6 +1425,7 @@ static int sndstat_open(int flags, int *_errno) {
}
unlink(fn);
+ pa_xfree(fn);
if (write(fd, sndstat, sizeof(sndstat) -1) != sizeof(sndstat)-1) {
*_errno = errno;
@@ -1439,6 +1442,7 @@ static int sndstat_open(int flags, int *_errno) {
return fd;
fail:
+ pa_xfree(fn);
if (fd >= 0)
close(fd);
return -1;