From e1ce365cd9cdcdfd1535aa58882de249c6274ed4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 29 Aug 2009 06:11:02 +0200 Subject: native: make sure clients cannot trigger an assert by sending us invalid volume info --- src/pulsecore/protocol-native.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index a5e952a3..179e62e2 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3390,12 +3390,18 @@ static void command_set_volume( client_name = pa_strnull(pa_proplist_gets(c->client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY)); if (sink) { + CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &sink->sample_spec), tag, PA_ERR_INVALID); + pa_log_debug("Client %s changes volume of sink %s.", client_name, sink->name); pa_sink_set_volume(sink, &volume, TRUE, TRUE); } else if (source) { + CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &source->sample_spec), tag, PA_ERR_INVALID); + pa_log_debug("Client %s changes volume of source %s.", client_name, source->name); pa_source_set_volume(source, &volume, TRUE); } else if (si) { + CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); + pa_log_debug("Client %s changes volume of sink input %s.", client_name, pa_strnull(pa_proplist_gets(si->proplist, PA_PROP_MEDIA_NAME))); @@ -3441,7 +3447,6 @@ static void command_set_mute( switch (command) { case PA_COMMAND_SET_SINK_MUTE: - if (idx != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx); else -- cgit From 2970c11902b46414d9ff28db1e850d94b137157c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 31 Aug 2009 21:40:59 +0200 Subject: core: always allow volume setting with single-channel pa_cvolume --- src/pulsecore/protocol-native.c | 6 +++--- src/pulsecore/sink-input.c | 14 ++++++++++++-- src/pulsecore/sink.c | 10 ++++++++-- src/pulsecore/source.c | 13 ++++++++++--- 4 files changed, 33 insertions(+), 10 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 179e62e2..d961dba2 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3390,17 +3390,17 @@ static void command_set_volume( client_name = pa_strnull(pa_proplist_gets(c->client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY)); if (sink) { - CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &sink->sample_spec), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &sink->sample_spec), tag, PA_ERR_INVALID); pa_log_debug("Client %s changes volume of sink %s.", client_name, sink->name); pa_sink_set_volume(sink, &volume, TRUE, TRUE); } else if (source) { - CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &source->sample_spec), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &source->sample_spec), tag, PA_ERR_INVALID); pa_log_debug("Client %s changes volume of source %s.", client_name, source->name); pa_source_set_volume(source, &volume, TRUE); } else if (si) { - CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); pa_log_debug("Client %s changes volume of sink input %s.", client_name, diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index d3e7a45c..adda2aff 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -941,12 +941,22 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, pa_boo pa_assert(PA_SINK_INPUT_IS_LINKED(i->state)); pa_assert(volume); pa_assert(pa_cvolume_valid(volume)); - pa_assert(pa_cvolume_compatible(volume, &i->sample_spec)); + pa_assert(volume->channels == 1 || pa_cvolume_compatible(volume, &i->sample_spec)); if ((i->sink->flags & PA_SINK_FLAT_VOLUME) && !absolute) { v = i->sink->reference_volume; pa_cvolume_remap(&v, &i->sink->channel_map, &i->channel_map); - volume = pa_sw_cvolume_multiply(&v, &v, volume); + + if (pa_cvolume_compatible(volume, &i->sample_spec)) + volume = pa_sw_cvolume_multiply(&v, &v, volume); + else + volume = pa_sw_cvolume_multiply_scalar(&v, &v, pa_cvolume_max(volume)); + } else { + + if (!pa_cvolume_compatible(volume, &i->sample_spec)) { + v = i->volume; + volume = pa_cvolume_scale(&v, pa_cvolume_max(volume)); + } } if (pa_cvolume_equal(volume, &i->volume)) { diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 48c50b0b..f5a6fc50 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1408,8 +1408,11 @@ void pa_sink_set_volume( pa_assert_ctl_context(); pa_assert(PA_SINK_IS_LINKED(s->state)); pa_assert(!volume || pa_cvolume_valid(volume)); - pa_assert(!volume || pa_cvolume_compatible(volume, &s->sample_spec)); pa_assert(volume || (s->flags & PA_SINK_FLAT_VOLUME)); + pa_assert(!volume || volume->channels == 1 || pa_cvolume_compatible(volume, &s->sample_spec)); + + /* As a special exception we accept mono volumes on all sinks -- + * even on those with more complex channel maps */ /* If volume is NULL we synchronize the sink's real and reference * volumes with the stream volumes. If it is not NULL we update @@ -1419,7 +1422,10 @@ void pa_sink_set_volume( if (volume) { - s->reference_volume = *volume; + if (pa_cvolume_compatible(volume, &s->sample_spec)) + s->reference_volume = *volume; + else + pa_cvolume_scale(&s->reference_volume, pa_cvolume_max(volume)); if (s->flags & PA_SINK_FLAT_VOLUME) { /* OK, propagate this volume change back to the inputs */ diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index 1c77e0b9..415c54bc 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -760,15 +760,22 @@ void pa_source_set_volume( pa_bool_t save) { pa_bool_t real_changed; + pa_cvolume old_volume; pa_source_assert_ref(s); pa_assert_ctl_context(); pa_assert(PA_SOURCE_IS_LINKED(s->state)); pa_assert(pa_cvolume_valid(volume)); - pa_assert(pa_cvolume_compatible(volume, &s->sample_spec)); + pa_assert(volume->channels == 1 || pa_cvolume_compatible(volume, &s->sample_spec)); - real_changed = !pa_cvolume_equal(volume, &s->volume); - s->volume = *volume; + old_volume = s->volume; + + if (pa_cvolume_compatible(volume, &s->sample_spec)) + s->volume = *volume; + else + pa_cvolume_scale(&s->volume, pa_cvolume_max(volume)); + + real_changed = !pa_cvolume_equal(&old_volume, &s->volume); s->save_volume = (!real_changed && s->save_volume) || save; if (s->set_volume) { -- cgit From 7c6a0ec66cd168b423bb66ef1ed266c4fbbcf3f3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 31 Aug 2009 21:41:36 +0200 Subject: cli: apply single-channel volume changes equally to all channels --- src/pulsecore/cli-command.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 6ec74647..06a83b53 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -529,7 +529,7 @@ static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *bu return -1; } - pa_cvolume_set(&cvolume, sink->sample_spec.channels, volume); + pa_cvolume_set(&cvolume, 1, volume); pa_sink_set_volume(sink, &cvolume, TRUE, TRUE); return 0; } @@ -571,7 +571,7 @@ static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strb return -1; } - pa_cvolume_set(&cvolume, si->sample_spec.channels, volume); + pa_cvolume_set(&cvolume, 1, volume); pa_sink_input_set_volume(si, &cvolume, TRUE, TRUE); return 0; } @@ -607,7 +607,7 @@ static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf * return -1; } - pa_cvolume_set(&cvolume, source->sample_spec.channels, volume); + pa_cvolume_set(&cvolume, 1, volume); pa_source_set_volume(source, &cvolume, TRUE); return 0; } -- cgit From e20d9068a31c7456e292aedec735dc776c44d0b6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 31 Aug 2009 21:42:09 +0200 Subject: cli: make sure 'dump' uses pa_cvolume_max() to deduce a single-channel volume from a multi-channel volume --- src/pulsecore/cli-command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 06a83b53..3c94960c 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -1586,7 +1586,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b nl = 1; } - pa_strbuf_printf(buf, "set-sink-volume %s 0x%03x\n", sink->name, pa_cvolume_avg(pa_sink_get_volume(sink, FALSE))); + pa_strbuf_printf(buf, "set-sink-volume %s 0x%03x\n", sink->name, pa_cvolume_max(pa_sink_get_volume(sink, FALSE))); pa_strbuf_printf(buf, "set-sink-mute %s %s\n", sink->name, pa_yes_no(pa_sink_get_mute(sink, FALSE))); pa_strbuf_printf(buf, "suspend-sink %s %s\n", sink->name, pa_yes_no(pa_sink_get_state(sink) == PA_SINK_SUSPENDED)); } @@ -1598,7 +1598,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b nl = 1; } - pa_strbuf_printf(buf, "set-source-volume %s 0x%03x\n", source->name, pa_cvolume_avg(pa_source_get_volume(source, FALSE))); + pa_strbuf_printf(buf, "set-source-volume %s 0x%03x\n", source->name, pa_cvolume_max(pa_source_get_volume(source, FALSE))); pa_strbuf_printf(buf, "set-source-mute %s %s\n", source->name, pa_yes_no(pa_source_get_mute(source, FALSE))); pa_strbuf_printf(buf, "suspend-source %s %s\n", source->name, pa_yes_no(pa_source_get_state(source) == PA_SOURCE_SUSPENDED)); } -- cgit From dc221f204b89fca85c0125e55f3afea4a807ffa7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 29 Aug 2009 12:22:42 +0200 Subject: remap: fix counters for mmx and sse remap Take the size of the sample into account when calculating the amount of samples we process in parallel. --- src/pulsecore/remap_mmx.c | 34 +++++++++++++++++++++------------- src/pulsecore/remap_sse.c | 34 +++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 26 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/remap_mmx.c b/src/pulsecore/remap_mmx.c index b5fe82ee..79e4f1fc 100644 --- a/src/pulsecore/remap_mmx.c +++ b/src/pulsecore/remap_mmx.c @@ -65,16 +65,24 @@ " add $32, %1 \n\t" \ " add $64, %0 \n\t" -#define HANDLE_SINGLE(s) \ +#define HANDLE_SINGLE_dq() \ " movd (%1), %%mm0 \n\t" \ - " punpckl"#s" %%mm0, %%mm0 \n\t" \ + " punpckldq %%mm0, %%mm0 \n\t" \ " movq %%mm0, (%0) \n\t" \ " add $4, %1 \n\t" \ " add $8, %0 \n\t" -#define MONO_TO_STEREO(s) \ - " mov %3, %2 \n\t" \ - " sar $3, %2 \n\t" \ +#define HANDLE_SINGLE_wd() \ + " movw (%1), %w3 \n\t" \ + " movd %3, %%mm0 \n\t" \ + " punpcklwd %%mm0, %%mm0 \n\t" \ + " movd %%mm0, (%0) \n\t" \ + " add $2, %1 \n\t" \ + " add $4, %0 \n\t" + +#define MONO_TO_STEREO(s,shift,mask) \ + " mov %4, %2 \n\t" \ + " sar $"#shift", %2 \n\t" \ " cmp $0, %2 \n\t" \ " je 2f \n\t" \ "1: \n\t" \ @@ -84,11 +92,11 @@ " dec %2 \n\t" \ " jne 1b \n\t" \ "2: \n\t" \ - " mov %3, %2 \n\t" \ - " and $7, %2 \n\t" \ + " mov %4, %2 \n\t" \ + " and $"#mask", %2 \n\t" \ " je 4f \n\t" \ "3: \n\t" \ - HANDLE_SINGLE(s) \ + HANDLE_SINGLE_##s() \ " dec %2 \n\t" \ " jne 3b \n\t" \ "4: \n\t" \ @@ -96,14 +104,14 @@ #if defined (__i386__) || defined (__amd64__) static void remap_mono_to_stereo_mmx (pa_remap_t *m, void *dst, const void *src, unsigned n) { - pa_reg_x86 temp; + pa_reg_x86 temp, temp2; switch (*m->format) { case PA_SAMPLE_FLOAT32NE: { __asm__ __volatile__ ( - MONO_TO_STEREO(dq) /* do doubles to quads */ - : "+r" (dst), "+r" (src), "=&r" (temp) + MONO_TO_STEREO(dq,3,7) /* do doubles to quads */ + : "+r" (dst), "+r" (src), "=&r" (temp), "=&r" (temp2) : "r" ((pa_reg_x86)n) : "cc" ); @@ -112,8 +120,8 @@ static void remap_mono_to_stereo_mmx (pa_remap_t *m, void *dst, const void *src, case PA_SAMPLE_S16NE: { __asm__ __volatile__ ( - MONO_TO_STEREO(wd) /* do words to doubles */ - : "+r" (dst), "+r" (src), "=&r" (temp) + MONO_TO_STEREO(wd,4,15) /* do words to doubles */ + : "+r" (dst), "+r" (src), "=&r" (temp), "=&r" (temp2) : "r" ((pa_reg_x86)n) : "cc" ); diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c index 97f2476e..d6003571 100644 --- a/src/pulsecore/remap_sse.c +++ b/src/pulsecore/remap_sse.c @@ -65,16 +65,24 @@ " add $64, %1 \n\t" \ " add $128, %0 \n\t" -#define HANDLE_SINGLE(s) \ +#define HANDLE_SINGLE_dq() \ " movd (%1), %%xmm0 \n\t" \ - " punpckl"#s" %%xmm0, %%xmm0 \n\t" \ + " punpckldq %%xmm0, %%xmm0 \n\t" \ " movq %%xmm0, (%0) \n\t" \ " add $4, %1 \n\t" \ " add $8, %0 \n\t" -#define MONO_TO_STEREO(s) \ - " mov %3, %2 \n\t" \ - " sar $4, %2 \n\t" \ +#define HANDLE_SINGLE_wd() \ + " movw (%1), %w3 \n\t" \ + " movd %3, %%xmm0 \n\t" \ + " punpcklwd %%xmm0, %%xmm0 \n\t" \ + " movd %%xmm0, (%0) \n\t" \ + " add $2, %1 \n\t" \ + " add $4, %0 \n\t" + +#define MONO_TO_STEREO(s,shift,mask) \ + " mov %4, %2 \n\t" \ + " sar $"#shift", %2 \n\t" \ " cmp $0, %2 \n\t" \ " je 2f \n\t" \ "1: \n\t" \ @@ -84,24 +92,24 @@ " dec %2 \n\t" \ " jne 1b \n\t" \ "2: \n\t" \ - " mov %3, %2 \n\t" \ - " and $15, %2 \n\t" \ + " mov %4, %2 \n\t" \ + " and $"#mask", %2 \n\t" \ " je 4f \n\t" \ "3: \n\t" \ - HANDLE_SINGLE(s) \ + HANDLE_SINGLE_##s() \ " dec %2 \n\t" \ " jne 3b \n\t" \ "4: \n\t" static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, unsigned n) { - pa_reg_x86 temp; + pa_reg_x86 temp, temp2; switch (*m->format) { case PA_SAMPLE_FLOAT32NE: { __asm__ __volatile__ ( - MONO_TO_STEREO(dq) /* do doubles to quads */ - : "+r" (dst), "+r" (src), "=&r" (temp) + MONO_TO_STEREO(dq,3,7) /* do doubles to quads */ + : "+r" (dst), "+r" (src), "=&r" (temp), "=&r" (temp2) : "r" ((pa_reg_x86)n) : "cc" ); @@ -110,8 +118,8 @@ static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, case PA_SAMPLE_S16NE: { __asm__ __volatile__ ( - MONO_TO_STEREO(wd) /* do words to doubles */ - : "+r" (dst), "+r" (src), "=&r" (temp) + MONO_TO_STEREO(wd,4,15) /* do words to doubles */ + : "+r" (dst), "+r" (src), "=&r" (temp), "=&r" (temp2) : "r" ((pa_reg_x86)n) : "cc" ); -- cgit From ce6dff4ee0a3fe6e0339eb1f5d605caf8af3f989 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 1 Sep 2009 22:18:01 +0200 Subject: core: add missing sink_unref() --- src/pulsecore/sink.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index f5a6fc50..2362db8d 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -893,6 +893,8 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) { result->memblock = pa_memblock_ref(s->silence.memblock); result->index = s->silence.index; result->length = PA_MIN(s->silence.length, length); + + pa_sink_unref(s); return; } @@ -980,6 +982,7 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) { if (s->thread_info.state == PA_SINK_SUSPENDED) { pa_silence_memchunk(target, &s->sample_spec); + pa_sink_unref(s); return; } -- cgit From 17f609ac830a4a6be9658c7220292a038b2c59ac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 1 Sep 2009 22:18:55 +0200 Subject: core: handle suspended state in pa_sink_render_full() similar to the other render functions --- src/pulsecore/sink.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 2362db8d..e1ab96db 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1099,7 +1099,16 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { pa_assert(!s->thread_info.rewind_requested); pa_assert(s->thread_info.rewind_nbytes == 0); - pa_assert(length > 0); + if (s->thread_info.state == PA_SINK_SUSPENDED) { + pa_silence_memchunk_get(&s->core->silence_cache, + s->core->mempool, + result, + &s->sample_spec, + length1st); + + pa_sink_unref(s); + return; + } n = fill_mix_info(s, &length1st, info, MAX_MIX_CHANNELS); -- cgit From 45513a2077719850353a9eb34f32ac4548c0dbea Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 1 Sep 2009 22:19:30 +0200 Subject: core: fill up memblock with pa_sink_render_into_full() in pa_sink_render_full() instead of doing our own loop --- src/pulsecore/sink.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index e1ab96db..9388d309 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1163,21 +1163,15 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { if (result->length < length) { pa_memchunk chunk; - size_t l, d; + pa_memchunk_make_writable(result, length); - l = length - result->length; - d = result->index + result->length; - while (l > 0) { - chunk = *result; - chunk.index = d; - chunk.length = l; + chunk.memblock = result->memblock; + chunk.index = result->index + result->length; + chunk.length = length - result->length; - pa_sink_render_into(s, &chunk); + pa_sink_render_into_full(s, &chunk); - d += chunk.length; - l -= chunk.length; - } result->length = length; } -- cgit From 5f929963d12c70193a923d620177125d8608f18a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2009 00:34:27 +0200 Subject: core-util: add api for setting env vars and record them so that we can undo them n fork --- src/pulsecore/core-util.c | 30 ++++++++++++++++++++++++++++++ src/pulsecore/core-util.h | 2 ++ 2 files changed, 32 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 67823019..9034dc32 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -116,6 +116,7 @@ #include #include #include +#include #include "core-util.h" @@ -124,6 +125,8 @@ #define MSG_NOSIGNAL 0 #endif +static pa_strlist *recorded_env = NULL; + #ifdef OS_IS_WIN32 #define PULSE_ROOTENV "PULSE_ROOT" @@ -2451,9 +2454,36 @@ void pa_set_env(const char *key, const char *value) { pa_assert(key); pa_assert(value); + /* This is not thread-safe */ + putenv(pa_sprintf_malloc("%s=%s", key, value)); } +void pa_set_env_and_record(const char *key, const char *value) { + pa_assert(key); + pa_assert(value); + + /* This is not thread-safe */ + + pa_set_env(key, value); + recorded_env = pa_strlist_prepend(recorded_env, key); +} + +void pa_unset_env_recorded(void) { + + /* This is not thread-safe */ + + for (;;) { + char *s = NULL; + + if (!(recorded_env = pa_strlist_pop(recorded_env, &s))) + break; + + unsetenv(s); + pa_xfree(s); + } +} + pa_bool_t pa_in_system_mode(void) { const char *e; diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index 2551f794..ccc9a38e 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -195,6 +195,8 @@ int pa_reset_sigs(int except, ...); int pa_reset_sigsv(const int except[]); void pa_set_env(const char *key, const char *value); +void pa_set_env_and_record(const char *key, const char *value); +void pa_unset_env_recorded(void); pa_bool_t pa_in_system_mode(void); -- cgit From a8c0f65faecd7058de3bd704ed90985ae2c842f0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2009 00:42:54 +0200 Subject: daemon: clean up environment when forking off children --- src/pulsecore/start-child.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/start-child.c b/src/pulsecore/start-child.c index b3bce131..4a70aea1 100644 --- a/src/pulsecore/start-child.c +++ b/src/pulsecore/start-child.c @@ -86,6 +86,11 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) { pa_reset_sigs(-1); pa_unblock_sigs(-1); pa_reset_priority(); + pa_unset_env_recorded(); + + /* Make sure our children are not influenced by the + * LD_BIND_NOW we set for ourselves. */ + unsetenv("LD_BIND_NOW"); #ifdef PR_SET_PDEATHSIG /* On Linux we can use PR_SET_PDEATHSIG to have the helper -- cgit From 1200a0b143c370c1a9351add5f72ecabfd8630cf Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2009 00:54:22 +0200 Subject: sink: simplify pa_sink_render_full() by replacing it by a pa_sink_render() plus a couple of pa_sink_render_full() --- src/pulsecore/sink.c | 90 ++++++++-------------------------------------------- 1 file changed, 14 insertions(+), 76 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 9388d309..b4ecdfcc 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -790,7 +790,7 @@ static void inputs_drop(pa_sink *s, pa_mix_info *info, unsigned n, pa_memchunk * /* We optimize for the case where the order of the inputs has not changed */ - while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL))) { + PA_HASHMAP_FOREACH(i, s->thread_info.inputs, state) { unsigned j; pa_mix_info* m = NULL; @@ -884,8 +884,6 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) { pa_assert(pa_frame_aligned(length, &s->sample_spec)); pa_assert(result); - pa_sink_ref(s); - pa_assert(!s->thread_info.rewind_requested); pa_assert(s->thread_info.rewind_nbytes == 0); @@ -893,11 +891,11 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) { result->memblock = pa_memblock_ref(s->silence.memblock); result->index = s->silence.index; result->length = PA_MIN(s->silence.length, length); - - pa_sink_unref(s); return; } + pa_sink_ref(s); + if (length <= 0) length = pa_frame_align(MIX_BUFFER_LENGTH, &s->sample_spec); @@ -975,17 +973,16 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) { pa_assert(target->length > 0); pa_assert(pa_frame_aligned(target->length, &s->sample_spec)); - pa_sink_ref(s); - pa_assert(!s->thread_info.rewind_requested); pa_assert(s->thread_info.rewind_nbytes == 0); if (s->thread_info.state == PA_SINK_SUSPENDED) { pa_silence_memchunk(target, &s->sample_spec); - pa_sink_unref(s); return; } + pa_sink_ref(s); + length = target->length; block_size_max = pa_mempool_block_size_max(s->core->mempool); if (length > block_size_max) @@ -1060,11 +1057,16 @@ void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target) { pa_assert(target->length > 0); pa_assert(pa_frame_aligned(target->length, &s->sample_spec)); - pa_sink_ref(s); - pa_assert(!s->thread_info.rewind_requested); pa_assert(s->thread_info.rewind_nbytes == 0); + if (s->thread_info.state == PA_SINK_SUSPENDED) { + pa_silence_memchunk(target, &s->sample_spec); + return; + } + + pa_sink_ref(s); + l = target->length; d = 0; while (l > 0) { @@ -1083,10 +1085,6 @@ void pa_sink_render_into_full(pa_sink *s, pa_memchunk *target) { /* Called from IO thread context */ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { - pa_mix_info info[MAX_MIX_CHANNELS]; - size_t length1st = length; - unsigned n; - pa_sink_assert_ref(s); pa_sink_assert_io_context(s); pa_assert(PA_SINK_IS_LINKED(s->thread_info.state)); @@ -1094,72 +1092,12 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) { pa_assert(pa_frame_aligned(length, &s->sample_spec)); pa_assert(result); - pa_sink_ref(s); - pa_assert(!s->thread_info.rewind_requested); pa_assert(s->thread_info.rewind_nbytes == 0); - if (s->thread_info.state == PA_SINK_SUSPENDED) { - pa_silence_memchunk_get(&s->core->silence_cache, - s->core->mempool, - result, - &s->sample_spec, - length1st); - - pa_sink_unref(s); - return; - } - - n = fill_mix_info(s, &length1st, info, MAX_MIX_CHANNELS); - - if (n == 0) { - pa_silence_memchunk_get(&s->core->silence_cache, - s->core->mempool, - result, - &s->sample_spec, - length1st); - } else if (n == 1) { - pa_cvolume volume; - - *result = info[0].chunk; - pa_memblock_ref(result->memblock); - - if (result->length > length) - result->length = length; - - pa_sw_cvolume_multiply(&volume, &s->thread_info.soft_volume, &info[0].volume); - - if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&volume)) { - if (s->thread_info.soft_muted || pa_cvolume_is_muted(&volume)) { - pa_memblock_unref(result->memblock); - pa_silence_memchunk_get(&s->core->silence_cache, - s->core->mempool, - result, - &s->sample_spec, - result->length); - } else { - pa_memchunk_make_writable(result, length); - pa_volume_memchunk(result, &s->sample_spec, &volume); - } - } - } else { - void *ptr; - - result->index = 0; - result->memblock = pa_memblock_new(s->core->mempool, length); - - ptr = pa_memblock_acquire(result->memblock); - - result->length = pa_mix(info, n, - (uint8_t*) ptr + result->index, length1st, - &s->sample_spec, - &s->thread_info.soft_volume, - s->thread_info.soft_muted); - - pa_memblock_release(result->memblock); - } + pa_sink_ref(s); - inputs_drop(s, info, n, result); + pa_sink_render(s, length, result); if (result->length < length) { pa_memchunk chunk; -- cgit From 767c7c7cf42463c591edaa5e5cdc7930fa0f6026 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2009 04:03:18 +0200 Subject: core-util: call dbus_connection_set_exit_on_disconnect() on shared busses to make sure dbus_shutdown() isn't fatal --- src/pulsecore/core-util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 9034dc32..eeb81a60 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -612,6 +612,11 @@ static int set_scheduler(int rtprio) { return -1; } + /* We need to disable exit on disconnect because otherwise + * dbus_shutdown will kill us. See + * https://bugs.freedesktop.org/show_bug.cgi?id=16924 */ + dbus_connection_set_exit_on_disconnect(bus, FALSE); + r = rtkit_make_realtime(bus, 0, rtprio); dbus_connection_unref(bus); @@ -680,6 +685,11 @@ static int set_nice(int nice_level) { return -1; } + /* We need to disable exit on disconnect because otherwise + * dbus_shutdown will kill us. See + * https://bugs.freedesktop.org/show_bug.cgi?id=16924 */ + dbus_connection_set_exit_on_disconnect(bus, FALSE); + r = rtkit_make_high_priority(bus, 0, nice_level); dbus_connection_unref(bus); -- cgit From 297afadbef238f7a37f65bd3740a2ce24861c414 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2009 04:05:34 +0200 Subject: core-util: don't leak memory in pa_unset_env_recorded() --- src/pulsecore/core-util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 9034dc32..a3c60130 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2474,9 +2474,11 @@ void pa_unset_env_recorded(void) { /* This is not thread-safe */ for (;;) { - char *s = NULL; + char *s; - if (!(recorded_env = pa_strlist_pop(recorded_env, &s))) + recorded_env = pa_strlist_pop(recorded_env, &s); + + if (!s) break; unsetenv(s); -- cgit From 26164ff05178db3aec351452b038f9d49fd0c5af Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 2 Sep 2009 19:42:17 +0200 Subject: sconv_sse: fix leftover counter --- src/pulsecore/sconv_sse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sconv_sse.c b/src/pulsecore/sconv_sse.c index ef78fc26..7c3aa199 100644 --- a/src/pulsecore/sconv_sse.c +++ b/src/pulsecore/sconv_sse.c @@ -83,7 +83,7 @@ static void pa_sconv_s16le_from_f32ne_sse(unsigned n, const float *a, int16_t *b "2: \n\t" " mov %4, %1 \n\t" /* prepare for leftovers */ - " and $15, %1 \n\t" + " and $7, %1 \n\t" " je 4f \n\t" "3: \n\t" @@ -142,7 +142,7 @@ static void pa_sconv_s16le_from_f32ne_sse2(unsigned n, const float *a, int16_t * "2: \n\t" " mov %4, %1 \n\t" /* prepare for leftovers */ - " and $15, %1 \n\t" + " and $7, %1 \n\t" " je 4f \n\t" "3: \n\t" -- cgit From 51423cae52333f604de198691d487c7de65cd096 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 3 Sep 2009 00:13:21 +0200 Subject: remap_sse: reindent macro so that diff to MMX is nicer Completely useless, but diff -u remap_mmx.c remap_sse.c is much nicer this way. --- src/pulsecore/remap_sse.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c index d6003571..fa21c6c8 100644 --- a/src/pulsecore/remap_sse.c +++ b/src/pulsecore/remap_sse.c @@ -80,25 +80,25 @@ " add $2, %1 \n\t" \ " add $4, %0 \n\t" -#define MONO_TO_STEREO(s,shift,mask) \ - " mov %4, %2 \n\t" \ - " sar $"#shift", %2 \n\t" \ - " cmp $0, %2 \n\t" \ - " je 2f \n\t" \ - "1: \n\t" \ - LOAD_SAMPLES \ - UNPACK_SAMPLES(s) \ - STORE_SAMPLES \ - " dec %2 \n\t" \ - " jne 1b \n\t" \ - "2: \n\t" \ - " mov %4, %2 \n\t" \ - " and $"#mask", %2 \n\t" \ - " je 4f \n\t" \ - "3: \n\t" \ - HANDLE_SINGLE_##s() \ - " dec %2 \n\t" \ - " jne 3b \n\t" \ +#define MONO_TO_STEREO(s,shift,mask) \ + " mov %4, %2 \n\t" \ + " sar $"#shift", %2 \n\t" \ + " cmp $0, %2 \n\t" \ + " je 2f \n\t" \ + "1: \n\t" \ + LOAD_SAMPLES \ + UNPACK_SAMPLES(s) \ + STORE_SAMPLES \ + " dec %2 \n\t" \ + " jne 1b \n\t" \ + "2: \n\t" \ + " mov %4, %2 \n\t" \ + " and $"#mask", %2 \n\t" \ + " je 4f \n\t" \ + "3: \n\t" \ + HANDLE_SINGLE_##s() \ + " dec %2 \n\t" \ + " jne 3b \n\t" \ "4: \n\t" static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, unsigned n) { -- cgit From 9f4f374a19e808ba4f7d4bb04266526bf5ed428b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 3 Sep 2009 00:17:28 +0200 Subject: remap_sse: fix inner loop increment on SSE In each iteration we can process 2^4 S16NE samples and 2^5 F32NE samples, that's twice as much as in MMX, hence correct the increments. --- src/pulsecore/remap_sse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c index fa21c6c8..368a3196 100644 --- a/src/pulsecore/remap_sse.c +++ b/src/pulsecore/remap_sse.c @@ -108,7 +108,7 @@ static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, case PA_SAMPLE_FLOAT32NE: { __asm__ __volatile__ ( - MONO_TO_STEREO(dq,3,7) /* do doubles to quads */ + MONO_TO_STEREO(dq, 4, 15) /* do doubles to quads */ : "+r" (dst), "+r" (src), "=&r" (temp), "=&r" (temp2) : "r" ((pa_reg_x86)n) : "cc" @@ -118,7 +118,7 @@ static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, case PA_SAMPLE_S16NE: { __asm__ __volatile__ ( - MONO_TO_STEREO(wd,4,15) /* do words to doubles */ + MONO_TO_STEREO(wd, 5, 31) /* do words to doubles */ : "+r" (dst), "+r" (src), "=&r" (temp), "=&r" (temp2) : "r" ((pa_reg_x86)n) : "cc" -- cgit From 14a97716891706d2f4984b0d1da10b354b3042db Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 3 Sep 2009 00:21:19 +0200 Subject: core: drop unnecessary variable initialization --- src/pulsecore/sink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index b4ecdfcc..bda92fcc 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -778,7 +778,7 @@ static unsigned fill_mix_info(pa_sink *s, size_t *length, pa_mix_info *info, uns /* Called from IO thread context */ static void inputs_drop(pa_sink *s, pa_mix_info *info, unsigned n, pa_memchunk *result) { pa_sink_input *i; - void *state = NULL; + void *state; unsigned p = 0; unsigned n_unreffed = 0; -- cgit From 6f396c89ab48c4897ebbcb846c5914b06a8225fb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 3 Sep 2009 01:48:30 +0200 Subject: remap: build sse code only on x86 --- src/pulsecore/remap_sse.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c index 368a3196..bf22df7c 100644 --- a/src/pulsecore/remap_sse.c +++ b/src/pulsecore/remap_sse.c @@ -101,6 +101,7 @@ " jne 3b \n\t" \ "4: \n\t" +#if defined (__i386__) || defined (__amd64__) static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, unsigned n) { pa_reg_x86 temp, temp2; @@ -144,6 +145,7 @@ static void init_remap_sse (pa_remap_t *m) { pa_log_info("Using SSE mono to stereo remapping"); } } +#endif /* defined (__i386__) || defined (__amd64__) */ void pa_remap_func_init_sse (pa_cpu_x86_flag_t flags) { #if defined (__i386__) || defined (__amd64__) -- cgit From e6a666d8d5fffbc9847b51b35349b88d74970079 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 6 Sep 2009 22:33:04 +0200 Subject: libpulse: introduce PA_BYTES_SNPRINT_MAX and make use of it wherever applicable --- src/pulsecore/cli-command.c | 12 ++++++------ src/pulsecore/memblock.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 3c94960c..143db3b2 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -328,7 +328,7 @@ static int pa_cli_command_source_outputs(pa_core *c, pa_tokenizer *t, pa_strbuf static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) { char ss[PA_SAMPLE_SPEC_SNPRINT_MAX]; char cm[PA_CHANNEL_MAP_SNPRINT_MAX]; - char s[256]; + char bytes[PA_BYTES_SNPRINT_MAX]; const pa_mempool_stat *stat; unsigned k; pa_sink *def_sink; @@ -352,22 +352,22 @@ static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_strbuf_printf(buf, "Memory blocks currently allocated: %u, size: %s.\n", (unsigned) pa_atomic_load(&stat->n_allocated), - pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->allocated_size))); + pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_atomic_load(&stat->allocated_size))); pa_strbuf_printf(buf, "Memory blocks allocated during the whole lifetime: %u, size: %s.\n", (unsigned) pa_atomic_load(&stat->n_accumulated), - pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->accumulated_size))); + pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_atomic_load(&stat->accumulated_size))); pa_strbuf_printf(buf, "Memory blocks imported from other processes: %u, size: %s.\n", (unsigned) pa_atomic_load(&stat->n_imported), - pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->imported_size))); + pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_atomic_load(&stat->imported_size))); pa_strbuf_printf(buf, "Memory blocks exported to other processes: %u, size: %s.\n", (unsigned) pa_atomic_load(&stat->n_exported), - pa_bytes_snprint(s, sizeof(s), (unsigned) pa_atomic_load(&stat->exported_size))); + pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_atomic_load(&stat->exported_size))); pa_strbuf_printf(buf, "Total sample cache size: %s.\n", - pa_bytes_snprint(s, sizeof(s), (unsigned) pa_scache_total_size(c))); + pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_scache_total_size(c))); pa_strbuf_printf(buf, "Default sample spec: %s\n", pa_sample_spec_snprint(ss, sizeof(ss), &c->default_sample_spec)); diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c index 441b397b..0e40d12b 100644 --- a/src/pulsecore/memblock.c +++ b/src/pulsecore/memblock.c @@ -694,7 +694,7 @@ static void memblock_replace_import(pa_memblock *b) { pa_mempool* pa_mempool_new(pa_bool_t shared, size_t size) { pa_mempool *p; - char t1[64], t2[64]; + char t1[PA_BYTES_SNPRINT_MAX], t2[PA_BYTES_SNPRINT_MAX]; p = pa_xnew(pa_mempool, 1); -- cgit From b5ac3839e18524524fa3e0da7ec68dbce16e8203 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 7 Sep 2009 17:21:21 +0200 Subject: x86: only install some functions when SSE2 Remap and volume functions use SSE2 instructions so only install them when SSE2 is present. --- src/pulsecore/remap_sse.c | 9 +++++---- src/pulsecore/svolume_sse.c | 10 ++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c index bf22df7c..dac072ec 100644 --- a/src/pulsecore/remap_sse.c +++ b/src/pulsecore/remap_sse.c @@ -102,7 +102,7 @@ "4: \n\t" #if defined (__i386__) || defined (__amd64__) -static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, unsigned n) { +static void remap_mono_to_stereo_sse2 (pa_remap_t *m, void *dst, const void *src, unsigned n) { pa_reg_x86 temp, temp2; switch (*m->format) { @@ -132,7 +132,7 @@ static void remap_mono_to_stereo_sse (pa_remap_t *m, void *dst, const void *src, } /* set the function that will execute the remapping based on the matrices */ -static void init_remap_sse (pa_remap_t *m) { +static void init_remap_sse2 (pa_remap_t *m) { unsigned n_oc, n_ic; n_oc = m->o_ss->channels; @@ -141,7 +141,7 @@ static void init_remap_sse (pa_remap_t *m) { /* find some common channel remappings, fall back to full matrix operation. */ if (n_ic == 1 && n_oc == 2 && m->map_table_f[0][0] >= 1.0 && m->map_table_f[1][0] >= 1.0) { - m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_sse; + m->do_remap = (pa_do_remap_func_t) remap_mono_to_stereo_sse2; pa_log_info("Using SSE mono to stereo remapping"); } } @@ -151,6 +151,7 @@ void pa_remap_func_init_sse (pa_cpu_x86_flag_t flags) { #if defined (__i386__) || defined (__amd64__) pa_log_info("Initialising SSE optimized remappers."); - pa_set_init_remap_func ((pa_init_remap_func_t) init_remap_sse); + if (flags & PA_CPU_X86_SSE2) + pa_set_init_remap_func ((pa_init_remap_func_t) init_remap_sse2); #endif /* defined (__i386__) || defined (__amd64__) */ } diff --git a/src/pulsecore/svolume_sse.c b/src/pulsecore/svolume_sse.c index 54af4a57..d9dcf476 100644 --- a/src/pulsecore/svolume_sse.c +++ b/src/pulsecore/svolume_sse.c @@ -75,7 +75,7 @@ " por %%xmm5, "#s2" \n\t" static void -pa_volume_s16ne_sse (int16_t *samples, int32_t *volumes, unsigned channels, unsigned length) +pa_volume_s16ne_sse2 (int16_t *samples, int32_t *volumes, unsigned channels, unsigned length) { pa_reg_x86 channel, temp; @@ -155,7 +155,7 @@ pa_volume_s16ne_sse (int16_t *samples, int32_t *volumes, unsigned channels, unsi } static void -pa_volume_s16re_sse (int16_t *samples, int32_t *volumes, unsigned channels, unsigned length) +pa_volume_s16re_sse2 (int16_t *samples, int32_t *volumes, unsigned channels, unsigned length) { pa_reg_x86 channel, temp; @@ -308,7 +308,9 @@ void pa_volume_func_init_sse (pa_cpu_x86_flag_t flags) { run_test (); #endif - pa_set_volume_func (PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_sse); - pa_set_volume_func (PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_sse); + if (flags & PA_CPU_X86_SSE2) { + pa_set_volume_func (PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_sse2); + pa_set_volume_func (PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_sse2); + } #endif /* defined (__i386__) || defined (__amd64__) */ } -- cgit From 723499439f575f744f07c85a42b47d95cdc98de6 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 7 Sep 2009 17:28:19 +0200 Subject: x86: also call see init for SSE2 --- src/pulsecore/cpu-x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/cpu-x86.c b/src/pulsecore/cpu-x86.c index 1ba9f1a4..f194a608 100644 --- a/src/pulsecore/cpu-x86.c +++ b/src/pulsecore/cpu-x86.c @@ -115,7 +115,7 @@ void pa_cpu_init_x86 (void) { pa_remap_func_init_mmx (flags); } - if (flags & PA_CPU_X86_SSE) { + if (flags & (PA_CPU_X86_SSE | PA_CPU_X86_SSE2)) { pa_volume_func_init_sse (flags); pa_remap_func_init_sse (flags); pa_convert_func_init_sse (flags); -- cgit From 3bbc5e6a4d0211d8cedd2fe6698c2e2c07d1c4b9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 7 Sep 2009 19:53:39 +0200 Subject: volume: fix definition of PA_VOLUME_MAX and introduce PA_VOLUME_INVALID and use it wherever applicable --- src/pulsecore/core-scache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/core-scache.c b/src/pulsecore/core-scache.c index fde12ecf..1fb81d0d 100644 --- a/src/pulsecore/core-scache.c +++ b/src/pulsecore/core-scache.c @@ -335,12 +335,12 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t pass_volume = TRUE; - if (e->volume_is_set && volume != (pa_volume_t) -1) { + if (e->volume_is_set && volume != PA_VOLUME_INVALID) { pa_cvolume_set(&r, e->sample_spec.channels, volume); pa_sw_cvolume_multiply(&r, &r, &e->volume); } else if (e->volume_is_set) r = e->volume; - else if (volume != (pa_volume_t) -1) + else if (volume != PA_VOLUME_INVALID) pa_cvolume_set(&r, e->sample_spec.channels, volume); else pass_volume = FALSE; -- cgit From b705a9bb8dfd7f859b0aca98833010f831ba2e6a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 7 Sep 2009 22:32:11 +0200 Subject: vector: don't try to build vector stuff on altivec --- src/pulsecore/vector.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/vector.h b/src/pulsecore/vector.h index 924e3cb8..9de3b8cd 100644 --- a/src/pulsecore/vector.h +++ b/src/pulsecore/vector.h @@ -23,7 +23,8 @@ #include /* First, define HAVE_VECTOR if we have the gcc vector extensions at all */ -#if defined(__SSE2__) || defined(__ALTIVEC__) +#if defined(__SSE2__) + /* || defined(__ALTIVEC__)*/ #define HAVE_VECTOR -- cgit From f5046759cdd72daf5ba3b31c9dfc7b8d5be6bc9b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:46:23 +0200 Subject: llvm-clang-analyzer: drop a few unnecessary assignments and other trivial fixes --- src/pulsecore/core-util.c | 13 +++++-------- src/pulsecore/flist.c | 22 ++++++++++++++++++---- src/pulsecore/memtrap.c | 4 ++-- src/pulsecore/pid.c | 4 +--- src/pulsecore/protocol-esound.c | 4 +--- src/pulsecore/protocol-native.c | 3 +-- src/pulsecore/protocol-simple.c | 2 +- src/pulsecore/sink-input.c | 3 --- src/pulsecore/socket-client.c | 4 +--- 9 files changed, 30 insertions(+), 29 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 1daa46eb..d64c7388 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -591,13 +591,13 @@ static int set_scheduler(int rtprio) { sp.sched_priority = rtprio; #ifdef SCHED_RESET_ON_FORK - if ((r = pthread_setschedparam(pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, &sp)) == 0) { + if (pthread_setschedparam(pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, &sp) == 0) { pa_log_debug("SCHED_RR|SCHED_RESET_ON_FORK worked."); return 0; } #endif - if ((r = pthread_setschedparam(pthread_self(), SCHED_RR, &sp)) == 0) { + if (pthread_setschedparam(pthread_self(), SCHED_RR, &sp) == 0) { pa_log_debug("SCHED_RR worked."); return 0; } @@ -786,7 +786,6 @@ int pa_match(const char *expr, const char *v) { /* Try to parse a boolean string value.*/ int pa_parse_boolean(const char *v) { const char *expr; - int r; pa_assert(v); /* First we check language independant */ @@ -798,12 +797,12 @@ int pa_parse_boolean(const char *v) { /* And then we check language dependant */ if ((expr = nl_langinfo(YESEXPR))) if (expr[0]) - if ((r = pa_match(expr, v)) > 0) + if (pa_match(expr, v) > 0) return 1; if ((expr = nl_langinfo(NOEXPR))) if (expr[0]) - if ((r = pa_match(expr, v)) > 0) + if (pa_match(expr, v) > 0) return 0; errno = EINVAL; @@ -1195,7 +1194,7 @@ char* pa_strip_nl(char *s) { /* Create a temporary lock file and lock it. */ int pa_lock_lockfile(const char *fn) { - int fd = -1; + int fd; pa_assert(fn); for (;;) { @@ -1238,8 +1237,6 @@ int pa_lock_lockfile(const char *fn) { fd = -1; goto fail; } - - fd = -1; } return fd; diff --git a/src/pulsecore/flist.c b/src/pulsecore/flist.c index 6fb944f9..7e5ee244 100644 --- a/src/pulsecore/flist.c +++ b/src/pulsecore/flist.c @@ -130,15 +130,22 @@ void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb) { } int pa_flist_push(pa_flist*l, void *p) { - unsigned idx, n, len; + unsigned idx, n; pa_atomic_ptr_t*cells; +#ifdef PROFILE + unsigned len; +#endif pa_assert(l); pa_assert(p); cells = PA_FLIST_CELLS(l); - n = len = l->size + N_EXTRA_SCAN - (unsigned) pa_atomic_load(&l->length); + n = l->size + N_EXTRA_SCAN - (unsigned) pa_atomic_load(&l->length); + +#ifdef PROFILE + len = n; +#endif _Y; idx = reduce(l, (unsigned) pa_atomic_load(&l->write_idx)); @@ -171,14 +178,21 @@ int pa_flist_push(pa_flist*l, void *p) { } void* pa_flist_pop(pa_flist*l) { - unsigned idx, len, n; + unsigned idx, n; pa_atomic_ptr_t *cells; +#ifdef PROFILE + unsigned len; +#endif pa_assert(l); cells = PA_FLIST_CELLS(l); - n = len = (unsigned) pa_atomic_load(&l->length) + N_EXTRA_SCAN; + n = (unsigned) pa_atomic_load(&l->length) + N_EXTRA_SCAN; + +#ifdef PROFILE + len = n; +#endif _Y; idx = reduce(l, (unsigned) pa_atomic_load(&l->read_idx)); diff --git a/src/pulsecore/memtrap.c b/src/pulsecore/memtrap.c index c647e507..373872c1 100644 --- a/src/pulsecore/memtrap.c +++ b/src/pulsecore/memtrap.c @@ -200,13 +200,13 @@ pa_memtrap *pa_memtrap_update(pa_memtrap *m, const void *start, size_t size) { goto unlock; memtrap_unlink(m, j); - j = pa_aupdate_write_swap(aupdate); + pa_aupdate_write_swap(aupdate); m->start = (void*) start; m->size = size; pa_atomic_store(&m->bad, 0); - j = pa_aupdate_write_swap(aupdate); + pa_assert_se(pa_aupdate_write_swap(aupdate) == j); memtrap_link(m, j); unlock: diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c index 00878462..996946c2 100644 --- a/src/pulsecore/pid.c +++ b/src/pulsecore/pid.c @@ -81,7 +81,7 @@ static pid_t read_pid(const char *fn, int fd) { } static int open_pid_file(const char *fn, int mode) { - int fd = -1; + int fd; pa_assert(fn); @@ -123,8 +123,6 @@ static int open_pid_file(const char *fn, int mode) { fd = -1; goto fail; } - - fd = -1; } return fd; diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c index 480af6d5..2326eb3a 100644 --- a/src/pulsecore/protocol-esound.c +++ b/src/pulsecore/protocol-esound.c @@ -771,7 +771,6 @@ static int esd_proto_stream_pan(connection *c, esd_proto_t request, const void * memcpy(&rvolume, data, sizeof(uint32_t)); rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume); - data = (const char*)data + sizeof(uint32_t); if ((conn = pa_idxset_get_by_index(c->protocol->connections, idx)) && conn->sink_input) { pa_cvolume volume; @@ -809,7 +808,6 @@ static int esd_proto_sample_pan(connection *c, esd_proto_t request, const void * memcpy(&rvolume, data, sizeof(uint32_t)); rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume); - data = (const char*)data + sizeof(uint32_t); volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE; @@ -1123,7 +1121,7 @@ static int do_read(connection *c) { ssize_t r; size_t l; void *p; - size_t space; + size_t space = 0; pa_assert(c->input_memblockq); diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index d961dba2..0215c233 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -628,7 +628,6 @@ static record_stream* record_stream_new( record_stream *s; pa_source_output *source_output = NULL; - size_t base; pa_source_output_new_data data; pa_assert(c); @@ -682,7 +681,7 @@ static record_stream* record_stream_new( 0, s->buffer_attr.maxlength, 0, - base = pa_frame_size(&source_output->sample_spec), + pa_frame_size(&source_output->sample_spec), 1, 0, 0, diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c index d66db4b7..a9f73896 100644 --- a/src/pulsecore/protocol-simple.c +++ b/src/pulsecore/protocol-simple.c @@ -154,7 +154,7 @@ static int do_read(connection *c) { ssize_t r; size_t l; void *p; - size_t space; + size_t space = 0; connection_assert_ref(c); diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index adda2aff..5f79ab1e 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -1152,7 +1152,6 @@ pa_bool_t pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest) { /* Called from main context */ int pa_sink_input_start_move(pa_sink_input *i) { pa_source_output *o, *p = NULL; - pa_sink *origin; int r; pa_sink_input_assert_ref(i); @@ -1166,8 +1165,6 @@ int pa_sink_input_start_move(pa_sink_input *i) { if ((r = pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_START], i)) < 0) return r; - origin = i->sink; - /* Kill directly connected outputs */ while ((o = pa_idxset_first(i->direct_outputs, NULL))) { pa_assert(o != p); diff --git a/src/pulsecore/socket-client.c b/src/pulsecore/socket-client.c index 24535157..c9cfdbe3 100644 --- a/src/pulsecore/socket-client.c +++ b/src/pulsecore/socket-client.c @@ -202,8 +202,6 @@ static void connect_io_cb(pa_mainloop_api*m, pa_io_event *e, int fd, pa_io_event } static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t len) { - int r; - pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(sa); @@ -211,7 +209,7 @@ static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t pa_make_fd_nonblock(c->fd); - if ((r = connect(c->fd, sa, len)) < 0) { + if (connect(c->fd, sa, len) < 0) { #ifdef OS_IS_WIN32 if (WSAGetLastError() != EWOULDBLOCK) { pa_log_debug("connect(): %d", WSAGetLastError()); -- cgit From 5fd751fc2ee44db50c26adc6d1881508c1ab04f5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:50:14 +0200 Subject: cli-command: modernizations --- src/pulsecore/cli-command.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 143db3b2..3941cc85 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -1549,7 +1549,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_sink *sink; pa_source *source; pa_card *card; - int nl; + pa_bool_t nl; uint32_t idx; char txt[256]; time_t now; @@ -1567,7 +1567,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_strbuf_printf(buf, "### Configuration dump generated at %s\n", ctime(&now)); #endif - for (m = pa_idxset_first(c->modules, &idx); m; m = pa_idxset_next(c->modules, &idx)) { + PA_IDXSET_FOREACH(m, c->modules, idx) { pa_strbuf_printf(buf, "load-module %s", m->name); @@ -1577,13 +1577,12 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_strbuf_puts(buf, "\n"); } - nl = 0; - - for (sink = pa_idxset_first(c->sinks, &idx); sink; sink = pa_idxset_next(c->sinks, &idx)) { + nl = FALSE; + PA_IDXSET_FOREACH(sink, c->sinks, idx) { if (!nl) { pa_strbuf_puts(buf, "\n"); - nl = 1; + nl = TRUE; } pa_strbuf_printf(buf, "set-sink-volume %s 0x%03x\n", sink->name, pa_cvolume_max(pa_sink_get_volume(sink, FALSE))); @@ -1591,11 +1590,12 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_strbuf_printf(buf, "suspend-sink %s %s\n", sink->name, pa_yes_no(pa_sink_get_state(sink) == PA_SINK_SUSPENDED)); } - for (source = pa_idxset_first(c->sources, &idx); source; source = pa_idxset_next(c->sources, &idx)) { + nl = FALSE; + PA_IDXSET_FOREACH(source, c->sources, idx) { if (!nl) { pa_strbuf_puts(buf, "\n"); - nl = 1; + nl = TRUE; } pa_strbuf_printf(buf, "set-source-volume %s 0x%03x\n", source->name, pa_cvolume_max(pa_source_get_volume(source, FALSE))); @@ -1603,32 +1603,32 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_strbuf_printf(buf, "suspend-source %s %s\n", source->name, pa_yes_no(pa_source_get_state(source) == PA_SOURCE_SUSPENDED)); } - for (card = pa_idxset_first(c->cards, &idx); card; card = pa_idxset_next(c->cards, &idx)) { + nl = FALSE; + PA_IDXSET_FOREACH(card, c->cards, idx) { if (!nl) { pa_strbuf_puts(buf, "\n"); - nl = 1; + nl = TRUE; } if (card->active_profile) pa_strbuf_printf(buf, "set-card-profile %s %s\n", card->name, card->active_profile->name); } - nl = 0; - + nl = FALSE; if ((sink = pa_namereg_get_default_sink(c))) { if (!nl) { pa_strbuf_puts(buf, "\n"); - nl = 1; + nl = TRUE; } + pa_strbuf_printf(buf, "set-default-sink %s\n", sink->name); } if ((source = pa_namereg_get_default_source(c))) { - if (!nl) { + if (!nl) pa_strbuf_puts(buf, "\n"); - nl = 1; - } + pa_strbuf_printf(buf, "set-default-source %s\n", source->name); } -- cgit From 3c9a09bc45608eb333e67bd44c3b69049f4d4ed7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:51:00 +0200 Subject: cli-command: don't necessarily ovveride failure code of files (llvm-clang-analyzer) --- src/pulsecore/cli-command.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 3941cc85..b57919a4 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -1813,8 +1813,6 @@ int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, pa_b ret = pa_cli_command_execute_file_stream(c, f, buf, fail); - ret = 0; - fail: if (f) fclose(f); -- cgit From 1516b7c047464e406ec983f10dcd3b854c4f3331 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:51:39 +0200 Subject: conf-parser: properly initialize variable we free() later (llvm-clang-analyzer) --- src/pulsecore/conf-parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c index b4ab23cc..dd4a99ee 100644 --- a/src/pulsecore/conf-parser.c +++ b/src/pulsecore/conf-parser.c @@ -113,7 +113,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const return 0; if (pa_startswith(b, ".include ")) { - char *path, *fn; + char *path = NULL, *fn; int r; fn = strip(b+9); -- cgit From 31ae7deefa72288b0c250b3ddc68c39e8eb840eb Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:52:58 +0200 Subject: core-util: properly fill in exception array for pa_reset_sigs() (llvm-clang-analyzer) --- src/pulsecore/core-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index d64c7388..7a9f458c 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2404,7 +2404,7 @@ int pa_reset_sigs(int except, ...) { p[i++] = except; while ((sig = va_arg(ap, int)) >= 0) - sig = p[i++]; + p[i++] = sig; } p[i] = -1; -- cgit From 31d1d9088e18b9d59a259230e0e49e6a5908586a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:53:28 +0200 Subject: protocol-native: log explicitly when someone asks us to quit --- src/pulsecore/protocol-native.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 0215c233..17aee4b1 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -2273,6 +2273,8 @@ static void command_exit(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta ret = pa_core_exit(c->protocol->core, FALSE, 0); CHECK_VALIDITY(c->pstream, ret >= 0, tag, PA_ERR_ACCESS); + pa_log_debug("Client %s asks us to terminate.", pa_strnull(pa_proplist_gets(c->client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY))); + pa_pstream_send_simple_ack(c->pstream, tag); /* nonsense */ } -- cgit From 12df6860ad1103bf1e90fee4501568e45c882ee2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Sep 2009 02:41:34 +0200 Subject: ratelimit: allow non-static ratelimit structs --- src/pulsecore/ratelimit.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/ratelimit.h b/src/pulsecore/ratelimit.h index ec3b5a38..9857a291 100644 --- a/src/pulsecore/ratelimit.h +++ b/src/pulsecore/ratelimit.h @@ -26,21 +26,31 @@ #include typedef struct pa_ratelimit { - const pa_usec_t interval; - const unsigned burst; + pa_usec_t interval; + unsigned burst; unsigned n_printed, n_missed; pa_usec_t begin; } pa_ratelimit; #define PA_DEFINE_RATELIMIT(_name, _interval, _burst) \ pa_ratelimit _name = { \ - .interval = _interval, \ - .burst = _burst, \ + .interval = (_interval), \ + .burst = (_burst), \ .n_printed = 0, \ .n_missed = 0, \ .begin = 0 \ } +#define PA_INIT_RATELIMIT(v, _interval, _burst) \ + do { \ + pa_ratelimit *r = &(v); \ + r->interval = (_interval); \ + r->burst = (_burst); \ + r->n_printed = 0; \ + r->n_missed = 0; \ + r->begin = 0; \ + } while (FALSE); + pa_bool_t pa_ratelimit_test(pa_ratelimit *r); #endif -- cgit From 1f0904b800d9d69698e79ce0435a2777d5f7ec27 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Sep 2009 04:27:16 +0200 Subject: sample-util: add pa_convert_size() call for converting sizes between two sample specs --- src/pulsecore/sample-util.c | 10 ++++++++++ src/pulsecore/sample-util.h | 2 ++ 2 files changed, 12 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c index 5fae1928..a26dc876 100644 --- a/src/pulsecore/sample-util.c +++ b/src/pulsecore/sample-util.c @@ -1056,3 +1056,13 @@ void pa_memchunk_sine(pa_memchunk *c, pa_mempool *pool, unsigned rate, unsigned calc_sine(p, c->length, freq * l / rate); pa_memblock_release(c->memblock); } + +size_t pa_convert_size(size_t size, const pa_sample_spec *from, const pa_sample_spec *to) { + pa_usec_t usec; + + pa_assert(from); + pa_assert(to); + + usec = pa_bytes_to_usec_round_up(size, from); + return pa_usec_to_bytes_round_up(usec, to); +} diff --git a/src/pulsecore/sample-util.h b/src/pulsecore/sample-util.h index 34df5cf3..d0235d60 100644 --- a/src/pulsecore/sample-util.h +++ b/src/pulsecore/sample-util.h @@ -91,6 +91,8 @@ typedef void (*pa_do_volume_func_t) (void *samples, void *volumes, unsigned chan pa_do_volume_func_t pa_get_volume_func(pa_sample_format_t f); void pa_set_volume_func(pa_sample_format_t f, pa_do_volume_func_t func); +size_t pa_convert_size(size_t size, const pa_sample_spec *from, const pa_sample_spec *to); + #define PA_CHANNEL_POSITION_MASK_LEFT \ (PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_FRONT_LEFT) \ | PA_CHANNEL_POSITION_MASK(PA_CHANNEL_POSITION_REAR_LEFT) \ -- cgit From 71e066c873e5bd31bd446ac0f8d0e97cc0b12ace Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 9 Sep 2009 04:28:22 +0200 Subject: simd: be more precise which SIMD optimizations we activate --- src/pulsecore/remap_mmx.c | 8 ++++++-- src/pulsecore/remap_sse.c | 8 +++++--- src/pulsecore/sconv_sse.c | 12 +++++++----- src/pulsecore/svolume_mmx.c | 9 ++++++--- src/pulsecore/svolume_sse.c | 7 ++++--- 5 files changed, 28 insertions(+), 16 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/remap_mmx.c b/src/pulsecore/remap_mmx.c index 79e4f1fc..d358a58b 100644 --- a/src/pulsecore/remap_mmx.c +++ b/src/pulsecore/remap_mmx.c @@ -150,8 +150,12 @@ static void init_remap_mmx (pa_remap_t *m) { void pa_remap_func_init_mmx (pa_cpu_x86_flag_t flags) { #if defined (__i386__) || defined (__amd64__) - pa_log_info("Initialising MMX optimized remappers."); - pa_set_init_remap_func ((pa_init_remap_func_t) init_remap_mmx); + if (flags & PA_CPU_X86_MMX) { + pa_log_info("Initialising MMX optimized remappers."); + + pa_set_init_remap_func ((pa_init_remap_func_t) init_remap_mmx); + } + #endif /* defined (__i386__) || defined (__amd64__) */ } diff --git a/src/pulsecore/remap_sse.c b/src/pulsecore/remap_sse.c index dac072ec..0ccf3161 100644 --- a/src/pulsecore/remap_sse.c +++ b/src/pulsecore/remap_sse.c @@ -149,9 +149,11 @@ static void init_remap_sse2 (pa_remap_t *m) { void pa_remap_func_init_sse (pa_cpu_x86_flag_t flags) { #if defined (__i386__) || defined (__amd64__) - pa_log_info("Initialising SSE optimized remappers."); - if (flags & PA_CPU_X86_SSE2) - pa_set_init_remap_func ((pa_init_remap_func_t) init_remap_sse2); + if (flags & PA_CPU_X86_SSE2) { + pa_log_info("Initialising SSE2 optimized remappers."); + pa_set_init_remap_func ((pa_init_remap_func_t) init_remap_sse2); + } + #endif /* defined (__i386__) || defined (__amd64__) */ } diff --git a/src/pulsecore/sconv_sse.c b/src/pulsecore/sconv_sse.c index 7c3aa199..3737af2a 100644 --- a/src/pulsecore/sconv_sse.c +++ b/src/pulsecore/sconv_sse.c @@ -218,16 +218,18 @@ static void run_test (void) { void pa_convert_func_init_sse (pa_cpu_x86_flag_t flags) { #if defined (__i386__) || defined (__amd64__) - pa_log_info("Initialising SSE optimized conversions."); #ifdef RUN_TEST run_test (); #endif - if (flags & PA_CPU_X86_SSE2) - pa_set_convert_from_float32ne_function (PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse2); - else - pa_set_convert_from_float32ne_function (PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse); + if (flags & PA_CPU_X86_SSE2) { + pa_log_info("Initialising SSE2 optimized conversions."); + pa_set_convert_from_float32ne_function (PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse2); + } else { + pa_log_info("Initialising SSE optimized conversions."); + pa_set_convert_from_float32ne_function (PA_SAMPLE_S16LE, (pa_convert_func_t) pa_sconv_s16le_from_f32ne_sse); + } #endif /* defined (__i386__) || defined (__amd64__) */ } diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c index 8510b0c4..74918e78 100644 --- a/src/pulsecore/svolume_mmx.c +++ b/src/pulsecore/svolume_mmx.c @@ -301,13 +301,16 @@ static void run_test (void) { void pa_volume_func_init_mmx (pa_cpu_x86_flag_t flags) { #if defined (__i386__) || defined (__amd64__) - pa_log_info("Initialising MMX optimized functions."); #ifdef RUN_TEST run_test (); #endif - pa_set_volume_func (PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_mmx); - pa_set_volume_func (PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_mmx); + if (flags & PA_CPU_X86_MMX) { + pa_log_info("Initialising MMX optimized functions."); + + pa_set_volume_func (PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_mmx); + pa_set_volume_func (PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_mmx); + } #endif /* defined (__i386__) || defined (__amd64__) */ } diff --git a/src/pulsecore/svolume_sse.c b/src/pulsecore/svolume_sse.c index d9dcf476..bbd73a9b 100644 --- a/src/pulsecore/svolume_sse.c +++ b/src/pulsecore/svolume_sse.c @@ -302,15 +302,16 @@ static void run_test (void) { void pa_volume_func_init_sse (pa_cpu_x86_flag_t flags) { #if defined (__i386__) || defined (__amd64__) - pa_log_info("Initialising SSE optimized functions."); #ifdef RUN_TEST run_test (); #endif if (flags & PA_CPU_X86_SSE2) { - pa_set_volume_func (PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_sse2); - pa_set_volume_func (PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_sse2); + pa_log_info("Initialising SSE2 optimized functions."); + + pa_set_volume_func (PA_SAMPLE_S16NE, (pa_do_volume_func_t) pa_volume_s16ne_sse2); + pa_set_volume_func (PA_SAMPLE_S16RE, (pa_do_volume_func_t) pa_volume_s16re_sse2); } #endif /* defined (__i386__) || defined (__amd64__) */ } -- cgit From 807f2a9923572a8d88e10672d0cb5886688bb9ff Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 10 Sep 2009 02:15:12 +0200 Subject: native: send PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED messages only to clients that understand it --- src/pulsecore/protocol-native.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 17aee4b1..d06dd4eb 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -826,24 +826,26 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata, pa_pstream_send_simple_ack(s->connection->pstream, PA_PTR_TO_UINT(userdata)); break; - case PLAYBACK_STREAM_MESSAGE_UPDATE_TLENGTH: { - pa_tagstruct *t; + case PLAYBACK_STREAM_MESSAGE_UPDATE_TLENGTH: s->buffer_attr.tlength = (uint32_t) offset; - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED); - pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */ - pa_tagstruct_putu32(t, s->index); - pa_tagstruct_putu32(t, s->buffer_attr.maxlength); - pa_tagstruct_putu32(t, s->buffer_attr.tlength); - pa_tagstruct_putu32(t, s->buffer_attr.prebuf); - pa_tagstruct_putu32(t, s->buffer_attr.minreq); - pa_tagstruct_put_usec(t, s->configured_sink_latency); - pa_pstream_send_tagstruct(s->connection->pstream, t); + if (s->connection->version >= 15) { + pa_tagstruct *t; + + t = pa_tagstruct_new(NULL, 0); + pa_tagstruct_putu32(t, PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED); + pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */ + pa_tagstruct_putu32(t, s->index); + pa_tagstruct_putu32(t, s->buffer_attr.maxlength); + pa_tagstruct_putu32(t, s->buffer_attr.tlength); + pa_tagstruct_putu32(t, s->buffer_attr.prebuf); + pa_tagstruct_putu32(t, s->buffer_attr.minreq); + pa_tagstruct_put_usec(t, s->configured_sink_latency); + pa_pstream_send_tagstruct(s->connection->pstream, t); + } break; - } } return 0; -- cgit From a015d56fac4a9af5296afe69825168cd1ce486b7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 11 Sep 2009 03:26:25 +0200 Subject: core: add an additional volume factor that is applied after resampling took place --- src/pulsecore/sink-input.c | 59 +++++++++++++++++++++++++++++++++++++++------- src/pulsecore/sink-input.h | 7 ++++-- 2 files changed, 56 insertions(+), 10 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 5f79ab1e..744c47ff 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -92,6 +92,18 @@ void pa_sink_input_new_data_apply_volume_factor(pa_sink_input_new_data *data, co } } +void pa_sink_input_new_data_apply_volume_factor_sink(pa_sink_input_new_data *data, const pa_cvolume *volume_factor) { + pa_assert(data); + pa_assert(volume_factor); + + if (data->volume_factor_sink_is_set) + pa_sw_cvolume_multiply(&data->volume_factor_sink, &data->volume_factor_sink, volume_factor); + else { + data->volume_factor_sink_is_set = TRUE; + data->volume_factor_sink = *volume_factor; + } +} + void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute) { pa_assert(data); @@ -176,7 +188,6 @@ int pa_sink_input_new( pa_channel_map_init_extend(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT); } - pa_return_val_if_fail(pa_channel_map_valid(&data->channel_map), -PA_ERR_INVALID); pa_return_val_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec), -PA_ERR_INVALID); if (!data->volume_is_set) { @@ -185,15 +196,18 @@ int pa_sink_input_new( data->save_volume = FALSE; } - pa_return_val_if_fail(pa_cvolume_valid(&data->volume), -PA_ERR_INVALID); pa_return_val_if_fail(pa_cvolume_compatible(&data->volume, &data->sample_spec), -PA_ERR_INVALID); if (!data->volume_factor_is_set) pa_cvolume_reset(&data->volume_factor, data->sample_spec.channels); - pa_return_val_if_fail(pa_cvolume_valid(&data->volume_factor), -PA_ERR_INVALID); pa_return_val_if_fail(pa_cvolume_compatible(&data->volume_factor, &data->sample_spec), -PA_ERR_INVALID); + if (!data->volume_factor_sink_is_set) + pa_cvolume_reset(&data->volume_factor_sink, data->sink->sample_spec.channels); + + pa_return_val_if_fail(pa_cvolume_compatible(&data->volume_factor_sink, &data->sink->sample_spec), -PA_ERR_INVALID); + if (!data->muted_is_set) data->muted = FALSE; @@ -283,6 +297,7 @@ int pa_sink_input_new( i->volume = data->volume; i->volume_factor = data->volume_factor; + i->volume_factor_sink = data->volume_factor_sink; i->real_ratio = i->reference_ratio = data->volume; pa_cvolume_reset(&i->soft_volume, i->sample_spec.channels); pa_cvolume_reset(&i->real_ratio, i->sample_spec.channels); @@ -576,7 +591,7 @@ pa_usec_t pa_sink_input_get_latency(pa_sink_input *i, pa_usec_t *sink_latency) { /* Called from thread context */ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, pa_memchunk *chunk, pa_cvolume *volume) { - pa_bool_t do_volume_adj_here; + pa_bool_t do_volume_adj_here, need_volume_factor_sink; pa_bool_t volume_is_norm; size_t block_size_max_sink, block_size_max_sink_input; size_t ilength; @@ -624,6 +639,7 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p do_volume_adj_here = !pa_channel_map_equal(&i->channel_map, &i->sink->channel_map); volume_is_norm = pa_cvolume_is_norm(&i->thread_info.soft_volume) && !i->thread_info.muted; + need_volume_factor_sink = !pa_cvolume_is_norm(&i->volume_factor_sink); while (!pa_memblockq_is_readable(i->thread_info.render_memblockq)) { pa_memchunk tchunk; @@ -655,6 +671,7 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p while (tchunk.length > 0) { pa_memchunk wchunk; + pa_bool_t nvfs = need_volume_factor_sink; wchunk = tchunk; pa_memblock_ref(wchunk.memblock); @@ -666,18 +683,41 @@ void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, p if (do_volume_adj_here && !volume_is_norm) { pa_memchunk_make_writable(&wchunk, 0); - if (i->thread_info.muted) + if (i->thread_info.muted) { pa_silence_memchunk(&wchunk, &i->thread_info.sample_spec); - else + nvfs = FALSE; + + } else if (!i->thread_info.resampler && nvfs) { + pa_cvolume v; + + /* If we don't need a resampler we can merge the + * post and the pre volume adjustment into one */ + + pa_sw_cvolume_multiply(&v, &i->thread_info.soft_volume, &i->volume_factor_sink); + pa_volume_memchunk(&wchunk, &i->thread_info.sample_spec, &v); + nvfs = FALSE; + + } else pa_volume_memchunk(&wchunk, &i->thread_info.sample_spec, &i->thread_info.soft_volume); } - if (!i->thread_info.resampler) + if (!i->thread_info.resampler) { + + if (nvfs) { + pa_memchunk_make_writable(&wchunk, 0); + pa_volume_memchunk(&wchunk, &i->sink->sample_spec, &i->volume_factor_sink); + } + pa_memblockq_push_align(i->thread_info.render_memblockq, &wchunk); - else { + } else { pa_memchunk rchunk; pa_resampler_run(i->thread_info.resampler, &wchunk, &rchunk); + if (nvfs) { + pa_memchunk_make_writable(&rchunk, 0); + pa_volume_memchunk(&rchunk, &i->sink->sample_spec, &i->volume_factor_sink); + } + /* pa_log_debug("pushing %lu", (unsigned long) rchunk.length); */ if (rchunk.memblock) { @@ -1186,6 +1226,7 @@ int pa_sink_input_start_move(pa_sink_input *i) { pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i->sink), PA_SINK_MESSAGE_START_MOVE, i, 0, NULL) == 0); pa_sink_update_status(i->sink); + pa_cvolume_remap(&i->volume_factor_sink, &i->sink->channel_map, &i->channel_map); i->sink = NULL; pa_sink_input_unref(i); @@ -1240,6 +1281,8 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) { i->save_sink = save; pa_idxset_put(dest->inputs, pa_sink_input_ref(i), NULL); + pa_cvolume_remap(&i->volume_factor_sink, &i->channel_map, &i->sink->channel_map); + if (pa_sink_input_get_state(i) == PA_SINK_INPUT_CORKED) i->sink->n_corked++; diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h index 59eabe36..415a801f 100644 --- a/src/pulsecore/sink-input.h +++ b/src/pulsecore/sink-input.h @@ -100,6 +100,8 @@ struct pa_sink_input { pa_cvolume volume_factor; /* An internally used volume factor that can be used by modules to apply effects and suchlike without having that visible to the outside */ pa_cvolume soft_volume; /* The internal software volume we apply to all PCM data while it passes through. Usually calculated as real_ratio * volume_factor */ + pa_cvolume volume_factor_sink; /* A second volume factor in format of the sink this stream is connected to */ + pa_bool_t muted:1; /* if TRUE then the source we are connected to and/or the volume @@ -273,13 +275,13 @@ typedef struct pa_sink_input_new_data { pa_sample_spec sample_spec; pa_channel_map channel_map; - pa_cvolume volume, volume_factor; + pa_cvolume volume, volume_factor, volume_factor_sink; pa_bool_t muted:1; pa_bool_t sample_spec_is_set:1; pa_bool_t channel_map_is_set:1; - pa_bool_t volume_is_set:1, volume_factor_is_set:1; + pa_bool_t volume_is_set:1, volume_factor_is_set:1, volume_factor_sink_is_set:1; pa_bool_t muted_is_set:1; pa_bool_t volume_is_absolute:1; @@ -292,6 +294,7 @@ void pa_sink_input_new_data_set_sample_spec(pa_sink_input_new_data *data, const void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map); void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume); void pa_sink_input_new_data_apply_volume_factor(pa_sink_input_new_data *data, const pa_cvolume *volume_factor); +void pa_sink_input_new_data_apply_volume_factor_sink(pa_sink_input_new_data *data, const pa_cvolume *volume_factor); void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute); void pa_sink_input_new_data_done(pa_sink_input_new_data *data); -- cgit 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/pulsecore') 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/pulsecore') 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 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/pulsecore') 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 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/pulsecore') 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 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pulsecore') 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 (;;) { -- 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 ++ 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'src/pulsecore') 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 -- 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/pulsecore') 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 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/pulsecore') 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 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/pulsecore/core-rtclock.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/pulsecore') 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 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/pulsecore') 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/pulsecore') 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 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/pulsecore') 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/pulsecore') 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 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/pulsecore') 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 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/pulsecore') 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 5eecd8ea7dcaca7536240b8a5800c686db51eee5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 23 Sep 2009 17:16:04 +0200 Subject: svolume: tweak constraints for 32 bits Tweak the constraints a little so that register starved 32bit systems can select a stack variable for the channel paramter instead of reusing one of the registers we're using in the code. --- src/pulsecore/svolume_mmx.c | 4 ++-- src/pulsecore/svolume_sse.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/pulsecore') diff --git a/src/pulsecore/svolume_mmx.c b/src/pulsecore/svolume_mmx.c index 62f3397e..1768eb50 100644 --- a/src/pulsecore/svolume_mmx.c +++ b/src/pulsecore/svolume_mmx.c @@ -152,7 +152,7 @@ pa_volume_s16ne_mmx (int16_t *samples, int32_t *volumes, unsigned channels, unsi " emms \n\t" : "+r" (samples), "+r" (volumes), "+r" (length), "=D" ((pa_reg_x86)channel), "=&r" (temp) - : "r" ((pa_reg_x86)channels) + : "X" ((pa_reg_x86)channels) : "cc" ); } @@ -228,7 +228,7 @@ pa_volume_s16re_mmx (int16_t *samples, int32_t *volumes, unsigned channels, unsi " emms \n\t" : "+r" (samples), "+r" (volumes), "+r" (length), "=D" ((pa_reg_x86)channel), "=&r" (temp) - : "r" ((pa_reg_x86)channels) + : "X" ((pa_reg_x86)channels) : "cc" ); } diff --git a/src/pulsecore/svolume_sse.c b/src/pulsecore/svolume_sse.c index 5276bda4..ab9394fb 100644 --- a/src/pulsecore/svolume_sse.c +++ b/src/pulsecore/svolume_sse.c @@ -149,7 +149,7 @@ pa_volume_s16ne_sse2 (int16_t *samples, int32_t *volumes, unsigned channels, uns "8: \n\t" : "+r" (samples), "+r" (volumes), "+r" (length), "=D" (channel), "=&r" (temp) - : "r" ((pa_reg_x86)channels) + : "X" ((pa_reg_x86)channels) : "cc" ); } @@ -237,7 +237,7 @@ pa_volume_s16re_sse2 (int16_t *samples, int32_t *volumes, unsigned channels, uns "8: \n\t" : "+r" (samples), "+r" (volumes), "+r" (length), "=D" (channel), "=&r" (temp) - : "r" ((pa_reg_x86)channels) + : "X" ((pa_reg_x86)channels) : "cc" ); } -- cgit