From d397a82e14da192995ba8caee5c95e70e545df29 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 12 Sep 2009 12:02:40 +0200 Subject: svolume_sse: fix comment --- src/pulsecore/svolume_sse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 | */ -- cgit From 3d5a572694388008fd4cf522699fc6c431f97325 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 12 Sep 2009 12:02:59 +0200 Subject: svolume_mmx: optimize some more We can reorder the algortihm a bit like we do for sse so that we don't need the contants and masking instructions. Saves 2 instructions for the mmx code. --- src/pulsecore/svolume_mmx.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c index 74918e78..170f01d4 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" @@ -239,7 +233,7 @@ pa_volume_s16re_mmx (int16_t *samples, int32_t *volumes, unsigned channels, unsi ); } -#undef RUN_TEST +#define RUN_TEST #ifdef RUN_TEST #define CHANNELS 2 -- cgit From 6b8fdc41693a710a29c4d3851a8c870031f1af88 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 01:19:55 +0200 Subject: CANCELLED vs. CANCELED Define CANCELLED as alias for CANCELED --- src/pulse/def.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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 */ -- cgit From e2899f8bf331d4cc89e2fa4ef3d17924fb91f922 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 01:21:56 +0200 Subject: memblock: make it easy to disable mempool usage with $PULSE_MEMPOOL_DISABLE --- src/pulsecore/memblock.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c index 0e40d12b..47f298a4 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. */ -- cgit From 1a6974a1e2f013e6ae522bc404adf24724f3127b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 01:22:48 +0200 Subject: pacat: use fully automatic buffer sizes if possible --- src/utils/pacat.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') 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) { -- cgit From e63c867f8714a790e157c5e6f834b421cc82ae33 Mon Sep 17 00:00:00 2001 From: Vladimir Kokarev Date: Thu, 17 Sep 2009 01:26:18 +0200 Subject: alsa: correct assumptions about channels an element lacks If an element does not control some channels assume they are 0dB in comparison to the other elements, i.e. do not influence the volume at all. Previously we were assuming they were as high as the highest of the channels we do control. --- src/modules/alsa/alsa-mixer.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 685169b9..8d54d583 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; -- cgit From 231c17be0330a3621f5249c5c7ea0ce521085c61 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 01:34:02 +0200 Subject: svolume_mmx: disable test accidentaly left on --- src/pulsecore/svolume_mmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c index 170f01d4..62f3397e 100644 --- a/src/pulsecore/svolume_mmx.c +++ b/src/pulsecore/svolume_mmx.c @@ -233,7 +233,7 @@ pa_volume_s16re_mmx (int16_t *samples, int32_t *volumes, unsigned channels, unsi ); } -#define RUN_TEST +#undef RUN_TEST #ifdef RUN_TEST #define CHANNELS 2 -- cgit From cdbeac6b6961b5e071250f539b7011efe65ef513 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 01:37:23 +0200 Subject: libpulse: as a special exception, don't require a non-NULL context in pa_context_errno --- src/pulse/context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') 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; -- cgit From add4cbf2f3e40131c03318d76c4c1e5208025ddc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 02:04:59 +0200 Subject: position-event-sounds: don't warn that loud about vpos/hpos out of range --- src/modules/module-position-event-sounds.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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; -- cgit From 94f28b9d4b7448c1e9bb6fb8a3b44f53988f6aa5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 02:22:41 +0200 Subject: proplist: introduce PA_PROP_WINDOW_DESKTOP property --- src/pulse/proplist.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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" -- cgit From b4d4f2b856cd0d5e24f777a088b9d4462567dac0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 03:51:35 +0200 Subject: cli: don't accidentaly set O_NDELAY on stderr Loading module-cli could have the effect of setting O_NDELAY on stderr, because it was just a dup'ed fd of stdin which module-cli sets O_NDELAY for and which flag is shared between all dupes. Instead of using stdin/stdout directly we now open a new file descriptor for the controlling terminal, which is equally useful as stdin/stdout but gives a new file that does not share O_NDELAY with stdin/stdout. This solves a problem where when running pulseaudio -C resulted in log output being truncated since stdio does not really handle O_NDELAY that well in on its fds. --- src/modules/module-cli.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index fd9452b4..60a9d460 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -25,6 +25,8 @@ #include #include +#include +#include #include #include @@ -33,6 +35,8 @@ #include #include #include +#include +#include #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); @@ -92,11 +97,24 @@ int pa__init(pa_module*m) { 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); -- cgit From 3de5c49e4289bb646919bdced6fccb82ced51ad0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 04:04:54 +0200 Subject: cli: properly destruct cli object --- src/modules/module-cli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index 60a9d460..6bd0f4fc 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -93,7 +93,7 @@ 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; } @@ -132,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(); } -- cgit From 2d9168ceb388cbb6dba49cc3a531921f78ec3295 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 20:58:36 +0200 Subject: Improve TMPDIR handling Patch from 'jnelson', http://pulseaudio.org/ticket/653 --- src/pulsecore/core-util.c | 2 +- src/utils/padsp.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 7a9f458c..690f34c9 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -1390,7 +1390,7 @@ static char* make_random_dir(mode_t m) { 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", tmpdir); pathlen = strlen(fn); for (;;) { diff --git a/src/utils/padsp.c b/src/utils/padsp.c index 41bfd741..c8c0874d 100644 --- a/src/utils/padsp.c +++ b/src/utils/padsp.c @@ -1394,10 +1394,21 @@ 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; + const char *tmpdir; + + 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" PA_PATH_SEP "padsp-sndstat-XXXXXX", tmpdir); debug(DEBUG_LEVEL_NORMAL, __FILE__": sndstat_open()\n"); @@ -1423,6 +1434,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 +1451,7 @@ static int sndstat_open(int flags, int *_errno) { return fd; fail: + pa_xfree(fn); if (fd >= 0) close(fd); return -1; -- cgit From 7b76ea378460bf3e037dff90742f88f74ee70b11 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2009 21:06:54 +0200 Subject: core-util: unify how we determine the temporary directory --- src/pulsecore/core-util.c | 33 +++++++++++++++++++++++---------- src/pulsecore/core-util.h | 2 ++ src/utils/padsp.c | 11 +---------- 3 files changed, 26 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 690f34c9..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" PA_PATH_SEP "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/utils/padsp.c b/src/utils/padsp.c index c8c0874d..2ed0a039 100644 --- a/src/utils/padsp.c +++ b/src/utils/padsp.c @@ -1398,17 +1398,8 @@ static int sndstat_open(int flags, int *_errno) { mode_t u; int fd = -1; int e; - const char *tmpdir; - 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" PA_PATH_SEP "padsp-sndstat-XXXXXX", tmpdir); + fn = pa_sprintf_malloc("%s" PA_PATH_SEP "padsp-sndstat-XXXXXX", pa_get_temp_dir()); debug(DEBUG_LEVEL_NORMAL, __FILE__": sndstat_open()\n"); -- cgit From 94d20a59faacb3c690227602ab5d097ea3999d24 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Wed, 16 Sep 2009 20:54:51 +0100 Subject: raop: Use pa_module_unload_request_by_index as per module-zeroconf-discover --- src/modules/raop/module-raop-discover.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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); } -- cgit From 56b6e18030b5a467946bd0a5803ec119efccdc8a Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 18 Sep 2009 00:20:46 +0100 Subject: rtp: Factor out direct io writing and use ioline instead. This is how things should have worked orinally, but I obviously misunderstood things a bit. This seems to prevent the random hangups that were happening previously :) --- src/modules/rtp/rtsp_client.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c index 915c1072..88574143 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,7 +443,7 @@ 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 */ -- cgit From a37e48a819f40bebd31e353f4afa43a1ba4a7567 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 03:46:33 +0200 Subject: alsa: fix Surround mixer element name s/Sourround/Surround/ Spotted by Colin Guthrie --- src/modules/alsa/mixer/paths/analog-output-headphones.conf | 2 +- src/modules/alsa/mixer/paths/analog-output-lfe-on-mono.conf | 2 +- src/modules/alsa/mixer/paths/analog-output-mono.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit From a43118b730c60a17b032b882b10ff9b93ab59460 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 03:48:55 +0200 Subject: mainloop: properly convert time to wallclock time when handing it to the user --- src/pulse/mainloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 93a4742d..379f88a8 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -806,7 +806,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, FALSE), e->userdata); r++; } -- cgit From a049909a7044813cb6237d22757ac24081b59af8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 03:59:40 +0200 Subject: mainloop: calculate in pa_usec_t everywhere --- src/pulse/mainloop.c | 67 ++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 379f88a8..d2cc7aec 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -112,7 +112,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; @@ -320,21 +320,19 @@ 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) { struct timeval ttv; if (!tv) return PA_USEC_INVALID; - ttv = *tv; - is_rtclock = !!(ttv.tv_usec & PA_TIMEVAL_RTCLOCK); - ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK; - - if (!is_rtclock) - pa_rtclock_from_wallclock(&ttv); + if (tv->tv_usec & PA_TIMEVAL_RTCLOCK) { + ttv = *tv; + ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK; + tv = pa_rtclock_from_wallclock(&ttv); + } - return pa_timeval_load(&ttv); + return pa_timeval_load(tv); } static pa_time_event* mainloop_time_new( @@ -351,7 +349,7 @@ static pa_time_event* mainloop_time_new( pa_assert(a->userdata); pa_assert(callback); - t = timeval_load(tv); + t = make_rt(tv); m = a->userdata; pa_assert(a == &m->api); @@ -392,7 +390,7 @@ static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) { pa_assert(e); pa_assert(!e->dead); - t = timeval_load(tv); + t = make_rt(tv); valid = (t != PA_USEC_INVALID); if (e->enabled && !valid) { @@ -763,12 +761,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,7 +778,7 @@ 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) { @@ -850,12 +848,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 +869,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 +891,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) -- cgit From b32f5994e9d1872c3a2ed8fd44d6d1866bb8387f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:00:38 +0200 Subject: mainloop: don't initialize fields we don't have to --- src/pulse/mainloop.c | 34 ++++------------------------------ 1 file changed, 4 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index d2cc7aec..4f3b676f 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -172,17 +172,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 +262,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); @@ -354,9 +349,8 @@ static pa_time_event* mainloop_time_new( 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; @@ -373,7 +367,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); @@ -478,9 +471,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); @@ -491,32 +483,14 @@ 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; -- cgit From 18d69c5d9d04d81135f078d7f49bad3214418622 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:03:49 +0200 Subject: mainloop: use PA_LLIST_FOREACH macros where applicable --- src/pulse/mainloop.c | 56 ++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 4f3b676f..67f095be 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -497,11 +497,9 @@ pa_mainloop *pa_mainloop_new(void) { } 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; @@ -521,19 +519,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; @@ -557,19 +551,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; @@ -593,8 +583,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); @@ -651,7 +639,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; @@ -675,16 +663,22 @@ static int dispatch_pollfds(pa_mainloop *m) { 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--; } @@ -698,7 +692,11 @@ static int dispatch_defer(pa_mainloop *m) { 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; @@ -717,7 +715,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; @@ -766,7 +764,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 +807,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; } } @@ -964,7 +966,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; @@ -984,6 +987,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; } -- cgit From fb4a2a1bbbd35601b5da62037c1cee40be859428 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:05:10 +0200 Subject: mainloop: sum up dispatched events in an unsigned to clarify range --- src/pulse/mainloop.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 67f095be..62659d89 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -657,9 +657,9 @@ 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); @@ -685,9 +685,9 @@ static int dispatch_pollfds(pa_mainloop *m) { 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; @@ -753,10 +753,10 @@ static pa_usec_t calc_next_timeout(pa_mainloop *m) { 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) @@ -903,7 +903,7 @@ quit: } int pa_mainloop_dispatch(pa_mainloop *m) { - int dispatched = 0; + unsigned dispatched = 0; pa_assert(m); pa_assert(m->state == STATE_POLLED); @@ -929,7 +929,7 @@ int pa_mainloop_dispatch(pa_mainloop *m) { m->state = STATE_PASSIVE; - return dispatched; + return (int) dispatched; quit: m->state = STATE_QUIT; @@ -938,6 +938,7 @@ quit: int pa_mainloop_get_retval(pa_mainloop *m) { pa_assert(m); + return m->retval; } -- cgit From 56f217f3f8b43a02a72bf28e049f9a20738843c8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:05:54 +0200 Subject: macro: introduce PA_INT_TYPE_MIN, PA_INT_TYPE_MAX, PA_INT_TYPE_SIGNED macros --- src/pulsecore/macro.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') 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 -- cgit From f7d38965b355b4932e7a17774e4625f57248f845 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:07:12 +0200 Subject: timeval: introduce PA_USEC_MAX --- src/pulse/timeval.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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 -- cgit From fdec460661faa802c1acf9d985990c2d1b4fa1a3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:08:36 +0200 Subject: core-rtclock: introduce pa_timespec_store() akin pa_timeval_store() --- src/pulsecore/core-rtclock.c | 14 ++++++++++++++ src/pulsecore/core-rtclock.h | 1 + 2 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c index 3b3e3a64..7690ab70 100644 --- a/src/pulsecore/core-rtclock.c +++ b/src/pulsecore/core-rtclock.c @@ -151,6 +151,20 @@ pa_usec_t pa_timespec_load(const struct timespec *ts) { (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) { 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); -- cgit From 05f6236a83414573587c73dbc439e68dae5f529e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:10:26 +0200 Subject: timeval: make pa_timeval_sub saturating --- src/pulse/timeval.c | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c index 376cf13c..1a0d3cef 100644 --- a/src/pulse/timeval.c +++ b/src/pulse/timeval.c @@ -33,6 +33,7 @@ #include #include +#include #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); @@ -128,40 +129,65 @@ 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) { -- cgit From a1da83b206d4a73bfa537ab3694bac7244bd19a1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:11:02 +0200 Subject: timeval: add UNLIKELY annotation --- src/pulse/timeval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c index 1a0d3cef..87569cf1 100644 --- a/src/pulse/timeval.c +++ b/src/pulse/timeval.c @@ -83,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; @@ -95,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; } -- cgit From c024aeaae91c139914dc928df975ea311729052c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:11:59 +0200 Subject: timeval: make timeval conversion routines handle PA_USEC_INVALID special --- src/pulse/timeval.c | 11 ++++++++++- src/pulsecore/core-rtclock.c | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c index 87569cf1..cde4417c 100644 --- a/src/pulse/timeval.c +++ b/src/pulse/timeval.c @@ -193,6 +193,13 @@ underflow: 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); @@ -200,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/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c index 7690ab70..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,7 +146,9 @@ 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 + @@ -176,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 -- cgit From d6291511a25d29c51cc3b22b72b69426f68e461d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 04:21:01 +0200 Subject: mainloop: pass monotonic times back to user if he passed monotonic times to us --- src/pulse/mainloop.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 62659d89..c5443f23 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; @@ -315,17 +316,22 @@ static void mainloop_defer_set_destroy(pa_defer_event *e, pa_defer_event_destroy } /* Time events */ -static pa_usec_t make_rt(const struct timeval *tv) { +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; + } if (tv->tv_usec & PA_TIMEVAL_RTCLOCK) { ttv = *tv; ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK; tv = pa_rtclock_from_wallclock(&ttv); - } + + *use_rtclock = TRUE; + } else + *use_rtclock = FALSE; return pa_timeval_load(tv); } @@ -339,12 +345,13 @@ 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 = make_rt(tv); + t = make_rt(tv, &use_rtclock); m = a->userdata; pa_assert(a == &m->api); @@ -354,6 +361,7 @@ static pa_time_event* mainloop_time_new( if ((e->enabled = (t != PA_USEC_INVALID))) { e->time = t; + e->use_rtclock= use_rtclock; m->n_enabled_time_events++; @@ -379,11 +387,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 = make_rt(tv); + t = make_rt(tv, &use_rtclock); valid = (t != PA_USEC_INVALID); if (e->enabled && !valid) { @@ -394,6 +403,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); } @@ -779,7 +789,7 @@ static unsigned dispatch_timeout(pa_mainloop *m) { /* Disable time event */ mainloop_time_restart(e, NULL); - e->callback(&m->api, e, pa_timeval_rtstore(&tv, e->time, FALSE), e->userdata); + e->callback(&m->api, e, pa_timeval_rtstore(&tv, e->time, e->use_rtclock), e->userdata); r++; } -- cgit From 0323e48fdc31925178ef375652660785328cb08f Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 18 Sep 2009 09:18:04 +0100 Subject: rtp: Remove 'fix me' comment after it was actually fixed in [56b6e1] That's what you get for applying your stash without fully checking if anything else was committed in the mean time :p --- src/modules/rtp/rtsp_client.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c index 88574143..59618064 100644 --- a/src/modules/rtp/rtsp_client.c +++ b/src/modules/rtp/rtsp_client.c @@ -446,8 +446,6 @@ static int rtsp_exec(pa_rtsp_client* c, const char* cmd, pa_ioline_puts(c->ioline, hdrs); pa_xfree(hdrs); - /* FIXME: this is broken, not necessarily all bytes are written */ - return 0; } -- cgit From fd25e8fa8bd22dc3ba4beac0fd12b2fc74bc6902 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 18 Sep 2009 09:22:23 +0100 Subject: alsa: Give all ports a human name to allow UI tools to present the choice to users. --- src/modules/alsa/alsa-mixer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c index 8d54d583..f3ce681f 100644 --- a/src/modules/alsa/alsa-mixer.c +++ b/src/modules/alsa/alsa-mixer.c @@ -1708,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); -- cgit From 8f299687882a33093cad32936672ba649306739b Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Fri, 18 Sep 2009 16:10:13 +0100 Subject: conf: Fix typo in daemon.conf: rlimit-rtttime - too many t's Spotted by peol on IRC --- src/daemon/daemon.conf.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') 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 -- cgit From c010172c6649f6f9e6f00aea3cc963ef1b34e3c3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 21:24:26 +0200 Subject: memblock: modernizations --- src/pulsecore/memblock.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c index 47f298a4..2b187f04 100644 --- a/src/pulsecore/memblock.c +++ b/src/pulsecore/memblock.c @@ -898,7 +898,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); @@ -906,10 +906,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; } -- cgit From cd5d6e7b42096272780261492ac9f1e00b6706c8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 21:24:58 +0200 Subject: socket-client: modernizations --- src/pulsecore/socket-client.c | 60 +++++++++++++++++-------------------------- src/pulsecore/socket-client.h | 2 -- 2 files changed, 24 insertions(+), 38 deletions(-) (limited to 'src') 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); -- cgit From f84d755d6a90ce8752e063a8a04a5d91239eb348 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 22:14:55 +0200 Subject: mainloop: fix detection of rt clocks --- src/pulse/mainloop.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index c5443f23..090ac8c2 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -324,16 +324,15 @@ static pa_usec_t make_rt(const struct timeval *tv, pa_bool_t *use_rtclock) { return PA_USEC_INVALID; } - if (tv->tv_usec & PA_TIMEVAL_RTCLOCK) { - ttv = *tv; - ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK; - tv = pa_rtclock_from_wallclock(&ttv); + ttv = *tv; + *use_rtclock = !!(ttv.tv_usec & PA_TIMEVAL_RTCLOCK); - *use_rtclock = TRUE; - } else - *use_rtclock = FALSE; + if (*use_rtclock) + ttv.tv_usec &= ~PA_TIMEVAL_RTCLOCK; + else + pa_rtclock_from_wallclock(&ttv); - return pa_timeval_load(tv); + return pa_timeval_load(&ttv); } static pa_time_event* mainloop_time_new( -- cgit From 9697c5dc18e8fcc270c2e1871826940b17ecc07e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 22:15:33 +0200 Subject: memblock: don't try to reuse PA_MEMBLOCK_APPENDED memblocks since they usually are much bigger than we want them --- src/pulsecore/memblock.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c index 2b187f04..f38b17c6 100644 --- a/src/pulsecore/memblock.c +++ b/src/pulsecore/memblock.c @@ -368,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; @@ -394,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; @@ -506,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; @@ -546,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; -- cgit From 8ad8e393f135f294942347dd66ec5e6c53329764 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 22:42:37 +0200 Subject: namereg: choose default sink/source as soon as one becomes available --- src/pulsecore/namereg.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c index 37755777..d9821876 100644 --- a/src/pulsecore/namereg.c +++ b/src/pulsecore/namereg.c @@ -98,7 +98,7 @@ char* pa_namereg_make_valid_name(const char *name) { if (*name == 0) return NULL; - n = pa_xmalloc(strlen(name)+1); + n = pa_xnew(char, strlen(name)+1); for (a = name, b = n; *a && (a-name < PA_NAME_MAX); a++, b++) *b = (char) (is_valid_char(*a) ? *a : '_'); @@ -170,6 +170,17 @@ const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t pa_assert_se(pa_hashmap_put(c->namereg, e->name, e) >= 0); + /* If a sink or source is registered and there was none registered + * before we inform the clients which then can ask for the default + * sink/source which is then assigned. We don't adjust the default + * sink/source here right away to give the module the chance to + * register more sinks/sources before we choose a new default + * sink/source. */ + + if ((!c->default_sink && type == PA_NAMEREG_SINK) || + (!c->default_source && type == PA_NAMEREG_SOURCE)) + pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SERVER|PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX); + return e->name; } -- cgit From 56e1290ef688ed0836d34492bc55c1f41f09c2f5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 Sep 2009 23:31:54 +0200 Subject: gconf: run the wrapper script when running gconf-helper from build tree --- src/modules/gconf/module-gconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/modules/gconf/module-gconf.c b/src/modules/gconf/module-gconf.c index 85523b39..5f31d688 100644 --- a/src/modules/gconf/module-gconf.c +++ b/src/modules/gconf/module-gconf.c @@ -342,7 +342,7 @@ int pa__init(pa_module*m) { if ((u->fd = pa_start_child_for_read( #if defined(__linux__) && !defined(__OPTIMIZE__) - pa_run_from_build_tree() ? PA_BUILDDIR "/.libs/gconf-helper" : + pa_run_from_build_tree() ? PA_BUILDDIR "/gconf-helper" : #endif PA_GCONF_HELPER, NULL, &u->pid)) < 0) goto fail; -- cgit From 996051ebc1883aa335c41a64217794915089a966 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 19 Sep 2009 00:21:34 +0200 Subject: memtrap: properly add items to linked list --- src/pulsecore/memtrap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pulsecore/memtrap.c b/src/pulsecore/memtrap.c index 373872c1..4fc18210 100644 --- a/src/pulsecore/memtrap.c +++ b/src/pulsecore/memtrap.c @@ -107,7 +107,10 @@ static void memtrap_link(pa_memtrap *m, unsigned j) { pa_assert(m); m->prev[j] = NULL; - m->next[j] = memtraps[j]; + + if ((m->next[j] = memtraps[j])) + m->next[j]->prev[j] = m; + memtraps[j] = m; } -- cgit From 88b777311d12502e36e2c74898015bcd55d92155 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 20 Sep 2009 03:17:36 +0200 Subject: alsa: make build gcc clean on 32bit --- src/modules/alsa/alsa-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index 56d60dfb..43a8e829 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -288,7 +288,7 @@ int pa_alsa_set_hw_params( if ((ret = snd_pcm_hw_params_get_buffer_size_max(hwparams, &max_frames)) < 0) pa_log_warn("snd_pcm_hw_params_get_buffer_size_max() failed: %s", pa_alsa_strerror(ret)); else - pa_log_debug("Maximum hw buffer size is %lu ms", (long unsigned) max_frames * PA_MSEC_PER_SEC / _ss.rate); + pa_log_debug("Maximum hw buffer size is %lu ms", (long unsigned) (max_frames * PA_MSEC_PER_SEC / _ss.rate)); /* Some ALSA drivers really don't like if we set the buffer * size first and the number of periods second. (which would -- cgit From e7686a607d167a862a90751767df0c9a271d8c34 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 20 Sep 2009 03:18:03 +0200 Subject: core: dump proplist when creating stream similar to how we already to it for sinks/sources --- src/pulsecore/sink-input.c | 8 ++++++-- src/pulsecore/source-output.c | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 744c47ff..1af2823f 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -153,6 +153,7 @@ int pa_sink_input_new( char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; pa_channel_map original_cm; int r; + char *pt; pa_assert(_i); pa_assert(core); @@ -353,12 +354,15 @@ int pa_sink_input_new( if (i->client) pa_assert_se(pa_idxset_put(i->client->sink_inputs, i, NULL) >= 0); - pa_log_info("Created input %u \"%s\" on %s with sample spec %s and channel map %s", + pt = pa_proplist_to_string_sep(i->proplist, "\n "); + pa_log_info("Created input %u \"%s\" on %s with sample spec %s and channel map %s\n %s", i->index, pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME)), i->sink->name, pa_sample_spec_snprint(st, sizeof(st), &i->sample_spec), - pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map)); + pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), + pt); + pa_xfree(pt); /* Don't forget to call pa_sink_input_put! */ diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 1509807b..57ccc067 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -107,6 +107,7 @@ int pa_source_output_new( pa_resampler *resampler = NULL; char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX]; int r; + char *pt; pa_assert(_o); pa_assert(core); @@ -247,12 +248,15 @@ int pa_source_output_new( if (o->direct_on_input) pa_assert_se(pa_idxset_put(o->direct_on_input->direct_outputs, o, NULL) == 0); - pa_log_info("Created output %u \"%s\" on %s with sample spec %s and channel map %s", + pt = pa_proplist_to_string_sep(o->proplist, "\n "); + pa_log_info("Created output %u \"%s\" on %s with sample spec %s and channel map %s\n %s", o->index, pa_strnull(pa_proplist_gets(o->proplist, PA_PROP_MEDIA_NAME)), o->source->name, pa_sample_spec_snprint(st, sizeof(st), &o->sample_spec), - pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map)); + pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map), + pt); + pa_xfree(pt); /* Don't forget to call pa_source_output_put! */ -- cgit From cc6932c4c8ddf66689f4ee4ecc51a4d41dcef6a7 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 20 Sep 2009 18:07:23 +0100 Subject: stream-restore: Comment fix --- src/modules/module-stream-restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c index d6e3c153..9b6f9143 100644 --- a/src/modules/module-stream-restore.c +++ b/src/modules/module-stream-restore.c @@ -593,7 +593,7 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source, if (!so->source) continue; - /* It might happen that a stream and a sink are set up at the + /* It might happen that a stream and a source are set up at the same time, in which case we want to make sure we don't interfere with that */ if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(so))) -- cgit From 592345fd3653c49438a4637133a500a09d58e081 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Sun, 20 Sep 2009 21:28:23 +0200 Subject: tunnel: fix parsing of sink info from newer servers --- src/modules/module-tunnel.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src') diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index af4b8b2a..1740448a 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -1069,6 +1069,33 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t } } + if (u->version >= 16) { + uint32_t n_ports, j; + const char *s; + + if (pa_tagstruct_getu32(t, &n_ports)) { + pa_log("Parse failure"); + goto fail; + } + + for (j = 0; j < n_ports; j++) { + uint32_t priority; + + if (pa_tagstruct_gets(t, &s) < 0 || /* name */ + pa_tagstruct_gets(t, &s) < 0 || /* description */ + pa_tagstruct_getu32(t, &priority) < 0) { + + pa_log("Parse failure"); + goto fail; + } + } + + if (pa_tagstruct_gets(t, &s) < 0) { /* active port */ + pa_log("Parse failure"); + goto fail; + } + } + if (!pa_tagstruct_eof(t)) { pa_log("Packet too long"); goto fail; -- cgit From c194db71b0ff853b4f46df26e135edf63b215451 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sun, 20 Sep 2009 21:36:14 +0100 Subject: tunnel: fix parsing of source info from newer servers --- src/modules/module-tunnel.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index 1740448a..c97de3a1 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -1070,7 +1070,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t } if (u->version >= 16) { - uint32_t n_ports, j; + uint32_t n_ports; const char *s; if (pa_tagstruct_getu32(t, &n_ports)) { @@ -1078,7 +1078,7 @@ static void sink_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_t goto fail; } - for (j = 0; j < n_ports; j++) { + for (uint32_t j = 0; j < n_ports; j++) { uint32_t priority; if (pa_tagstruct_gets(t, &s) < 0 || /* name */ @@ -1272,6 +1272,33 @@ static void source_info_cb(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa } } + if (u->version >= 16) { + uint32_t n_ports; + const char *s; + + if (pa_tagstruct_getu32(t, &n_ports)) { + pa_log("Parse failure"); + goto fail; + } + + for (uint32_t j = 0; j < n_ports; j++) { + uint32_t priority; + + if (pa_tagstruct_gets(t, &s) < 0 || /* name */ + pa_tagstruct_gets(t, &s) < 0 || /* description */ + pa_tagstruct_getu32(t, &priority) < 0) { + + pa_log("Parse failure"); + goto fail; + } + } + + if (pa_tagstruct_gets(t, &s) < 0) { /* active port */ + pa_log("Parse failure"); + goto fail; + } + } + if (!pa_tagstruct_eof(t)) { pa_log("Packet too long"); goto fail; -- cgit