From 0b8a6c66dc0dec79110f40ffa6ee791b4c557ca8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 13 Feb 2009 00:14:48 +0200 Subject: bluetooth: fix message queue/rtpoll --- src/modules/bluetooth/module-bluetooth-device.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 6daae83c..35338dcf 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1349,9 +1349,6 @@ static int add_sink(struct userdata *u) { u->sink->userdata = u; u->sink->parent.process_msg = sink_process_msg; - - pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq); - pa_sink_set_rtpoll(u->sink, u->rtpoll); } /* u->sink->get_volume = sink_get_volume_cb; */ @@ -1396,9 +1393,6 @@ static int add_source(struct userdata *u) { u->source->userdata = u; u->source->parent.process_msg = source_process_msg; - - pa_source_set_asyncmsgq(u->source, u->thread_mq.inq); - pa_source_set_rtpoll(u->source, u->rtpoll); } /* u->source->get_volume = source_get_volume_cb; */ @@ -1559,11 +1553,17 @@ static int start_thread(struct userdata *u) { return -1; } - if (u->sink) + if (u->sink) { + pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq); + pa_sink_set_rtpoll(u->sink, u->rtpoll); pa_sink_put(u->sink); + } - if (u->source) + if (u->source) { + pa_source_set_asyncmsgq(u->source, u->thread_mq.inq); + pa_source_set_rtpoll(u->source, u->rtpoll); pa_source_put(u->source); + } return 0; } -- cgit From b51e6135e87221b05acb1e8796d28bec1cf06dff Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 15:20:08 +0200 Subject: bluetooth: update SBC from upstream --- src/modules/bluetooth/sbc.c | 18 ++++++++++++++++-- src/modules/bluetooth/sbc.h | 1 + src/modules/bluetooth/sbc_primitives.c | 1 + src/modules/bluetooth/sbc_primitives.h | 1 + src/modules/bluetooth/sbc_primitives_mmx.c | 1 + src/modules/bluetooth/sbc_primitives_neon.c | 1 + 6 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/modules/bluetooth/sbc.c b/src/modules/bluetooth/sbc.c index 29258d05..a33ed571 100644 --- a/src/modules/bluetooth/sbc.c +++ b/src/modules/bluetooth/sbc.c @@ -985,7 +985,7 @@ int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output, char *ptr; int i, ch, framelen, samples; - if (!sbc && !input) + if (!sbc || !input) return -EIO; priv = sbc->priv; @@ -1053,7 +1053,7 @@ int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output, const uint8_t *pcm, int16_t X[2][SBC_X_BUFFER_SIZE], int nsamples, int nchannels); - if (!sbc && !input) + if (!sbc || !input) return -EIO; priv = sbc->priv; @@ -1221,6 +1221,20 @@ uint16_t sbc_get_codesize(sbc_t *sbc) return subbands * blocks * channels * 2; } +const char *sbc_get_implementation_info(sbc_t *sbc) +{ + struct sbc_priv *priv; + + if (!sbc) + return NULL; + + priv = sbc->priv; + if (!priv) + return NULL; + + return priv->enc_state.implementation_info; +} + int sbc_reinit(sbc_t *sbc, unsigned long flags) { struct sbc_priv *priv; diff --git a/src/modules/bluetooth/sbc.h b/src/modules/bluetooth/sbc.h index b0a14888..f9d506bc 100644 --- a/src/modules/bluetooth/sbc.h +++ b/src/modules/bluetooth/sbc.h @@ -89,6 +89,7 @@ int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output, int sbc_get_frame_length(sbc_t *sbc); int sbc_get_frame_duration(sbc_t *sbc); uint16_t sbc_get_codesize(sbc_t *sbc); +const char *sbc_get_implementation_info(sbc_t *sbc); void sbc_finish(sbc_t *sbc); #ifdef __cplusplus diff --git a/src/modules/bluetooth/sbc_primitives.c b/src/modules/bluetooth/sbc_primitives.c index 303f3fee..6b0be3f5 100644 --- a/src/modules/bluetooth/sbc_primitives.c +++ b/src/modules/bluetooth/sbc_primitives.c @@ -456,6 +456,7 @@ void sbc_init_primitives(struct sbc_encoder_state *state) /* Default implementation for scale factors calculation */ state->sbc_calc_scalefactors = sbc_calc_scalefactors; + state->implementation_info = "Generic C"; /* X86/AMD64 optimizations */ #ifdef SBC_BUILD_WITH_MMX_SUPPORT diff --git a/src/modules/bluetooth/sbc_primitives.h b/src/modules/bluetooth/sbc_primitives.h index 2708c829..3d01c115 100644 --- a/src/modules/bluetooth/sbc_primitives.h +++ b/src/modules/bluetooth/sbc_primitives.h @@ -62,6 +62,7 @@ struct sbc_encoder_state { void (*sbc_calc_scalefactors)(int32_t sb_sample_f[16][2][8], uint32_t scale_factor[2][8], int blocks, int channels, int subbands); + const char *implementation_info; }; /* diff --git a/src/modules/bluetooth/sbc_primitives_mmx.c b/src/modules/bluetooth/sbc_primitives_mmx.c index 1870a9ba..08e9ca28 100644 --- a/src/modules/bluetooth/sbc_primitives_mmx.c +++ b/src/modules/bluetooth/sbc_primitives_mmx.c @@ -313,6 +313,7 @@ void sbc_init_primitives_mmx(struct sbc_encoder_state *state) if (check_mmx_support()) { state->sbc_analyze_4b_4s = sbc_analyze_4b_4s_mmx; state->sbc_analyze_4b_8s = sbc_analyze_4b_8s_mmx; + state->implementation_info = "MMX"; } } diff --git a/src/modules/bluetooth/sbc_primitives_neon.c b/src/modules/bluetooth/sbc_primitives_neon.c index d9c12f9e..f1bc7b48 100644 --- a/src/modules/bluetooth/sbc_primitives_neon.c +++ b/src/modules/bluetooth/sbc_primitives_neon.c @@ -240,6 +240,7 @@ void sbc_init_primitives_neon(struct sbc_encoder_state *state) { state->sbc_analyze_4b_4s = sbc_analyze_4b_4s_neon; state->sbc_analyze_4b_8s = sbc_analyze_4b_8s_neon; + state->implementation_info = "NEON"; } #endif -- cgit From b4c391ee5eaa61c31fa297b6b3f6e3a65d662948 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Fri, 13 Feb 2009 12:18:14 +0200 Subject: bluetooth: don't crash on pa_thread_mq_done() if pa_init() fail --- src/modules/bluetooth/module-bluetooth-device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 35338dcf..748a2d4d 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1517,9 +1517,9 @@ static void stop_thread(struct userdata *u) { u->source = NULL; } - pa_thread_mq_done(&u->thread_mq); - if (u->rtpoll) { + pa_thread_mq_done(&u->thread_mq); + pa_rtpoll_free(u->rtpoll); u->rtpoll = NULL; } -- cgit From 38ded3bb31bc49664641965f856a35f432a8a956 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Fri, 13 Feb 2009 15:09:16 +0200 Subject: bluetooth: print SBC encoder implementation info The encoder initialization is done lazily, so we can only get the information once encoding start. This is abit annoying.. --- src/modules/bluetooth/module-bluetooth-device.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 748a2d4d..b8f67299 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -904,6 +904,11 @@ static int a2dp_process_render(struct userdata *u) { (void*) p, u->write_memchunk.length, d, left, &written); + + PA_ONCE_BEGIN { + pa_log_debug("Using SBC encoder implementation: %s", pa_strnull(sbc_get_implementation_info(&a2dp->sbc))); + } PA_ONCE_END; + pa_memblock_release(u->write_memchunk.memblock); if (encoded <= 0) { -- cgit From 05b74404813931744e1479c96f039ae2a79b0c7d Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 16:51:37 +0200 Subject: pulse/context: add --enable-legacy-runtime-dir --- configure.ac | 6 ++++++ src/pulse/context.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c28a72cd..2ac40cc6 100644 --- a/configure.ac +++ b/configure.ac @@ -1220,6 +1220,12 @@ AC_SUBST(PA_SYSTEM_STATE_PATH) # Output # ################################### +AC_ARG_ENABLE([legacy-runtime-dir], + AS_HELP_STRING([--disable-legacy-runtime-dir], [Try to connect on legacy (< 0.9.12) socket paths.])) +if test "x$enable_legacy_runtime_dir" != "xno" ; then + AC_DEFINE(ENABLE_LEGACY_RUNTIME_DIR, [1], [Legacy runtime dir]) +fi + AC_ARG_ENABLE( [static-bins], AS_HELP_STRING([--enable-static-bins],[Statically link executables.]), diff --git a/src/pulse/context.c b/src/pulse/context.c index 8686e0de..9cc1ea78 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -555,6 +555,7 @@ static void setup_context(pa_context *c, pa_iochannel *io) { pa_context_unref(c); } +#if ENABLE_LEGACY_RUNTIME_DIR static char *get_old_legacy_runtime_dir(void) { char *p, u[128]; struct stat st; @@ -598,10 +599,12 @@ static char *get_very_old_legacy_runtime_dir(void) { return p; } - +#endif static pa_strlist *prepend_per_user(pa_strlist *l) { char *ufn; + +#if ENABLE_LEGACY_RUNTIME_DIR static char *legacy_dir; /* The very old per-user instance path (< 0.9.11). This is supported only to ease upgrades */ @@ -619,6 +622,7 @@ static pa_strlist *prepend_per_user(pa_strlist *l) { pa_xfree(p); pa_xfree(legacy_dir); } +#endif /* The per-user instance */ if ((ufn = pa_runtime_path(PA_NATIVE_DEFAULT_UNIX_SOCKET))) { -- cgit From 7d16dcb6cc8dc931020186f5dab37f32ecc815d9 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 19:19:07 +0200 Subject: dbus-util: avoid double free --- src/modules/dbus-util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/dbus-util.c b/src/modules/dbus-util.c index f6a986a5..4218bca5 100644 --- a/src/modules/dbus-util.c +++ b/src/modules/dbus-util.c @@ -403,8 +403,7 @@ void pa_dbus_pending_free(pa_dbus_pending *p) { pa_assert(p); if (p->pending) { - dbus_pending_call_cancel(p->pending); - dbus_pending_call_unref(p->pending); + dbus_pending_call_cancel(p->pending); /* p->pending is freed by cancel() */ } if (p->message) -- cgit From 7737b10ac6cd03d844c6de77c58f2d39b60a7ad3 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 19:26:21 +0200 Subject: hal-detect: make sure r is initialized, so we don't take random path --- src/modules/module-hal-detect.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c index e6037381..ce04f367 100644 --- a/src/modules/module-hal-detect.c +++ b/src/modules/module-hal-detect.c @@ -370,6 +370,7 @@ static struct device* hal_device_add(struct userdata *u, const char *udi) { d->originating_udi = NULL; d->module = PA_INVALID_INDEX; d->sink_name = d->source_name = d->card_name = NULL; + r = -1; #ifdef HAVE_ALSA if (pa_streq(u->capability, CAPABILITY_ALSA)) -- cgit From 83cdcf2f53f4a449cd4d6eb67c1e079a5db0257a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 19:35:01 +0200 Subject: alsa-util: make sure we check an initialized cn variable --- src/modules/alsa/alsa-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index 1bb7ddfd..c53fd10d 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -1,7 +1,7 @@ /*** This file is part of PulseAudio. - Copyright 2004-2006 Lennart Poettering + Copyright 2004-2009 Lennart Poettering Copyright 2006 Pierre Ossman for Cendio AB PulseAudio is free software; you can redistribute it and/or modify @@ -1388,7 +1388,7 @@ void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t * snd_pcm_class_t class; snd_pcm_subclass_t subclass; - const char *n, *id, *sdn, *cn; + const char *n, *id, *sdn, *cn = NULL; int card; pa_assert(p); -- cgit From ee0b5f71861f3ebad0c24f8c27000210fd986e54 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:06:35 +0200 Subject: log: don't leak bt --- src/pulsecore/log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c index 1ae43839..89b75da3 100644 --- a/src/pulsecore/log.c +++ b/src/pulsecore/log.c @@ -351,6 +351,7 @@ void pa_log_levelv_meta( } errno = saved_errno; + pa_xfree(bt); } void pa_log_level_meta( -- cgit From 01f81d697346d3cb052d11137913aaa59a854c0b Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Thu, 19 Feb 2009 04:49:58 +0100 Subject: card-restore: it's not useful to check an array, let's check the length --- src/modules/module-card-restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c index 909c0957..c7696058 100644 --- a/src/modules/module-card-restore.c +++ b/src/modules/module-card-restore.c @@ -191,7 +191,7 @@ static pa_hook_result_t card_new_hook_callback(pa_core *c, pa_card_new_data *new pa_assert(new_data); - if ((e = read_entry(u, new_data->name)) && e->profile) { + if ((e = read_entry(u, new_data->name)) && e->profile[0]) { if (!new_data->active_profile) { pa_card_new_data_set_profile(new_data, e->profile); -- cgit From 6c8d851643a8413678c7557abc9758cc1bee94c0 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:18:56 +0200 Subject: protocol-native: fix get_info() for cards --- src/pulsecore/protocol-native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 79b9b069..39b82826 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3011,7 +3011,7 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p source_fill_tagstruct(c, reply, source); else if (client) client_fill_tagstruct(c, reply, client); - else if (client) + else if (card) card_fill_tagstruct(c, reply, card); else if (module) module_fill_tagstruct(c, reply, module); -- cgit From 2aeab75c6893c882800975866178c79dfe85202a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:27:45 +0200 Subject: paplay: check if pa_context_connect() succeed --- src/utils/paplay.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/paplay.c b/src/utils/paplay.c index df2edf62..dec80e5c 100644 --- a/src/utils/paplay.c +++ b/src/utils/paplay.c @@ -400,7 +400,10 @@ int main(int argc, char *argv[]) { pa_context_set_state_callback(context, context_state_callback, NULL); /* Connect the context */ - pa_context_connect(context, server, 0, NULL); + if (pa_context_connect(context, server, 0, NULL) < 0) { + fprintf(stderr, _("pa_context_connect() failed: %s"), pa_strerror(pa_context_errno(context))); + goto quit; + } /* Run the main loop */ if (pa_mainloop_run(m, &ret) < 0) { -- cgit From 93ed27d5617202441bd9be346ce916289fe7128d Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:31:06 +0200 Subject: pactl: check if pa_context_connect succeed --- src/utils/pactl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 154e7f9c..e020f372 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -1029,7 +1029,10 @@ int main(int argc, char *argv[]) { } pa_context_set_state_callback(context, context_state_callback, NULL); - pa_context_connect(context, server, 0, NULL); + if (pa_context_connect(context, server, 0, NULL) < 0) { + fprintf(stderr, _("pa_context_connect() failed: %s"), pa_strerror(pa_context_errno(context))); + goto quit; + } if (pa_mainloop_run(m, &ret) < 0) { fprintf(stderr, _("pa_mainloop_run() failed.\n")); -- cgit From a8369274952ad81ed2b05800d182e35efd26e41d Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:34:05 +0200 Subject: tests/sync-playback: check if pa_context_connect succeed --- src/tests/sync-playback.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tests/sync-playback.c b/src/tests/sync-playback.c index 42c479a1..f2a15601 100644 --- a/src/tests/sync-playback.c +++ b/src/tests/sync-playback.c @@ -174,11 +174,16 @@ int main(int argc, char *argv[]) { pa_context_set_state_callback(context, context_state_callback, NULL); - pa_context_connect(context, NULL, 0, NULL); + /* Connect the context */ + if (pa_context_connect(context, NULL, 0, NULL) < 0) { + fprintf(stderr, "pa_context_connect() failed.\n"); + goto quit; + } if (pa_mainloop_run(m, &ret) < 0) fprintf(stderr, "pa_mainloop_run() failed.\n"); +quit: pa_context_unref(context); for (i = 0; i < NSTREAMS; i++) -- cgit From 5ea7dac11c225aa26367974d7cf37e71a096ef27 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:36:38 +0200 Subject: tests/interpol-test: check if mainloop_start() succeed --- src/tests/interpol-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/interpol-test.c b/src/tests/interpol-test.c index 20d2c230..d7da660c 100644 --- a/src/tests/interpol-test.c +++ b/src/tests/interpol-test.c @@ -126,7 +126,8 @@ int main(int argc, char *argv[]) { pa_gettimeofday(&start); - pa_threaded_mainloop_start(m); + r = pa_threaded_mainloop_start(m); + assert(r >= 0); for (k = 0; k < 5000; k++) { pa_bool_t success = FALSE, changed = FALSE; -- cgit From 25bbea67492cb7c6e9b8e78beb6553864c290a1a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:38:51 +0200 Subject: tests/thread-mainloop-test: check if threaded_mainloop_start() succeed --- src/tests/thread-mainloop-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/thread-mainloop-test.c b/src/tests/thread-mainloop-test.c index 263cd57d..3bcf4f16 100644 --- a/src/tests/thread-mainloop-test.c +++ b/src/tests/thread-mainloop-test.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { pa_assert_se(m = pa_threaded_mainloop_new()); pa_assert_se(a = pa_threaded_mainloop_get_api(m)); - pa_threaded_mainloop_start(m); + pa_assert_se(pa_threaded_mainloop_start(m) >= 0); pa_threaded_mainloop_lock(m); -- cgit From c3eb9086b819eb7abb0248e0a253c21e5853fe99 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 20:52:11 +0200 Subject: pactl: return in case of error reading file (avoid using freed d) --- src/utils/pactl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/utils/pactl.c b/src/utils/pactl.c index e020f372..d3da90e6 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -649,6 +649,7 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) { pa_xfree(d); fprintf(stderr, _("Premature end of file\n")); quit(1); + return; } pa_stream_write(s, d, length, pa_xfree, 0, PA_SEEK_RELATIVE); -- cgit From a252b61be1d81f833a3cca87a2294d7fe65532fd Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 21:59:45 +0200 Subject: main: remove unused lf variable --- src/daemon/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/daemon/main.c b/src/daemon/main.c index d3e02fa0..5f94ec66 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -348,7 +348,6 @@ int main(int argc, char *argv[]) { pa_time_event *win32_timer; struct timeval win32_tv; #endif - char *lf = NULL; int autospawn_fd = -1; pa_bool_t autospawn_locked = FALSE; @@ -1000,9 +999,6 @@ finish: pa_autospawn_lock_done(FALSE); } - if (lf) - pa_xfree(lf); - #ifdef OS_IS_WIN32 if (win32_timer) pa_mainloop_get_api(mainloop)->time_free(win32_timer); -- cgit From 927e501920f629eca1f73627b0d7a5a03a9e8bdc Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 22:07:57 +0200 Subject: pulsecore: remove unused variable from cli_command_load() --- src/pulsecore/cli-command.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 1df0bd63..5e45c1aa 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -401,7 +401,6 @@ static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b } static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) { - pa_module *m; const char *name; pa_core_assert_ref(c); @@ -414,7 +413,7 @@ static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b return -1; } - if (!(m = pa_module_load(c, name, pa_tokenizer_get(t, 2)))) { + if (!pa_module_load(c, name, pa_tokenizer_get(t, 2))) { pa_strbuf_puts(buf, "Module load failed.\n"); return -1; } -- cgit From 4512a2ce9ce15bdcded9d5aa457016716edd459a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 22:06:25 +0200 Subject: rtp-recv: remove unused variable assignment --- src/modules/rtp/module-rtp-recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c index 063ba725..0d86459e 100644 --- a/src/modules/rtp/module-rtp-recv.c +++ b/src/modules/rtp/module-rtp-recv.c @@ -562,7 +562,7 @@ static void sap_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event } else { if (!(s = pa_hashmap_get(u->by_origin, info.origin))) { - if (!(s = session_new(u, &info))) + if (!session_new(u, &info)) pa_sdp_info_destroy(&info); } else { -- cgit From 67b0baecc41745afcf8591949fbdffb8678fe83f Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 22:17:10 +0200 Subject: pacat: remove unused variable --- src/utils/pacat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 10015ce4..2224da9a 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -336,7 +336,6 @@ static void context_drain_complete(pa_context*c, void *userdata) { /* Stream draining complete */ static void stream_drain_complete(pa_stream*s, int success, void *userdata) { - pa_operation *o; if (!success) { fprintf(stderr, _("Failed to drain stream: %s\n"), pa_strerror(pa_context_errno(context))); @@ -350,7 +349,7 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) { pa_stream_unref(stream); stream = NULL; - if (!(o = pa_context_drain(context, context_drain_complete, NULL))) + if (!pa_context_drain(context, context_drain_complete, NULL)) pa_context_disconnect(context); else { if (verbose) -- cgit From d1306e3020137251fc0aa57386dd79ee1ec5ebb0 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 22:32:40 +0200 Subject: pulsecore: fix check for cb (m is already checked before) --- src/pulsecore/protocol-native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 39b82826..59fae984 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -4070,7 +4070,7 @@ static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag, CHECK_VALIDITY(c->pstream, m->load_once || idx != PA_INVALID_INDEX, tag, PA_ERR_INVALID); cb = (pa_native_protocol_ext_cb_t) (unsigned long) pa_hashmap_get(c->protocol->extensions, m); - CHECK_VALIDITY(c->pstream, m, tag, PA_ERR_NOEXTENSION); + CHECK_VALIDITY(c->pstream, cb, tag, PA_ERR_NOEXTENSION); if (cb(c->protocol, m, c, tag, t) < 0) protocol_error(c); -- cgit From bb52a6753b907e18b0de31bffd424b8ed273c5a9 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 22:37:16 +0200 Subject: padsp: don't use si if it's NULL --- src/utils/padsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/padsp.c b/src/utils/padsp.c index 046bae45..76e86c8d 100644 --- a/src/utils/padsp.c +++ b/src/utils/padsp.c @@ -1202,7 +1202,7 @@ fail: static void sink_info_cb(pa_context *context, const pa_sink_info *si, int eol, void *userdata) { fd_info *i = userdata; - if (!si && eol < 0) { + if (!si || eol < 0) { i->operation_success = 0; pa_threaded_mainloop_signal(i->mainloop, 0); return; @@ -1224,7 +1224,7 @@ static void sink_info_cb(pa_context *context, const pa_sink_info *si, int eol, v static void source_info_cb(pa_context *context, const pa_source_info *si, int eol, void *userdata) { fd_info *i = userdata; - if (!si && eol < 0) { + if (!si || eol < 0) { i->operation_success = 0; pa_threaded_mainloop_signal(i->mainloop, 0); return; -- cgit From 60d53c6523dfd59fbcc99ff443ba993e285ca366 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Tue, 17 Feb 2009 22:58:59 +0200 Subject: tests/ipacl-test: check inet_pton() --- src/tests/ipacl-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/ipacl-test.c b/src/tests/ipacl-test.c index 7b7564a4..f89665cd 100644 --- a/src/tests/ipacl-test.c +++ b/src/tests/ipacl-test.c @@ -25,6 +25,7 @@ #endif #include "../pulsecore/winsock.h" +#include "../pulsecore/macro.h" #include @@ -96,7 +97,7 @@ int main(int argc, char *argv[]) { memset(&sa6, 0, sizeof(sa6)); sa6.sin6_family = AF_INET6; sa6.sin6_port = htons(22); - inet_pton(AF_INET6, "::1", &sa6.sin6_addr); + pa_assert_se(inet_pton(AF_INET6, "::1", &sa6.sin6_addr) == 1); r = connect(fd, (struct sockaddr*) &sa6, sizeof(sa6)); assert(r >= 0); -- cgit From 204083cb325ba3db09ca75b70e9d3d6adfb67e0d Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 18:16:45 +0200 Subject: pulsecore: unused variable e in hashmap_put() --- src/pulsecore/hashmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c index 3c6f41ec..57607b69 100644 --- a/src/pulsecore/hashmap.c +++ b/src/pulsecore/hashmap.c @@ -138,7 +138,7 @@ int pa_hashmap_put(pa_hashmap *h, const void *key, void *value) { hash = h->hash_func(key) % NBUCKETS; - if ((e = hash_scan(h, hash, key))) + if (hash_scan(h, hash, key)) return -1; if (!(e = pa_flist_pop(PA_STATIC_FLIST_GET(entries)))) -- cgit From 4f1380b7138d5862e8f12c9060ef46f0355c160b Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 18:21:25 +0200 Subject: pulsecore: use r returned from fgets() --- src/pulsecore/core-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 61f9a656..432ee3b7 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2459,7 +2459,7 @@ char *pa_machine_id(void) { pa_strip_nl(ln); - if (ln[0]) + if (r && ln[0]) return pa_xstrdup(ln); } -- cgit From 2c6abb87938d2172963a99979449c1ff0b63a9f3 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 19:15:43 +0200 Subject: daemon-conf: make sure c->log_level < LEVEL_MAX --- src/daemon/daemon-conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 7d3b89f0..7dfef27f 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -639,7 +639,7 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) { if (c->config_file) pa_strbuf_printf(s, _("### Read from configuration file: %s ###\n"), c->config_file); - pa_assert(c->log_level <= PA_LOG_LEVEL_MAX); + pa_assert(c->log_level < PA_LOG_LEVEL_MAX); pa_strbuf_printf(s, "daemonize = %s\n", pa_yes_no(c->daemonize)); pa_strbuf_printf(s, "fail = %s\n", pa_yes_no(c->fail)); -- cgit From c0cf22d0812d766fb7528449be1351ca2e030a8c Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 19:26:21 +0200 Subject: protocol-esound: don't accept a request of PROTOCOL_MAX --- src/pulsecore/protocol-esound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c index e1643cbb..840f4581 100644 --- a/src/pulsecore/protocol-esound.c +++ b/src/pulsecore/protocol-esound.c @@ -924,7 +924,7 @@ static int do_read(connection *c) { c->request = PA_MAYBE_INT32_SWAP(c->swap_byte_order, c->request); - if (c->request < ESD_PROTO_CONNECT || c->request > ESD_PROTO_MAX) { + if (c->request < ESD_PROTO_CONNECT || c->request >= ESD_PROTO_MAX) { pa_log("recieved invalid request."); return -1; } -- cgit From 0684b236f0ad2fc367971bfa02cb466c2170aafd Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 19:44:55 +0200 Subject: stream-resotre: don't leak a name --- src/modules/module-stream-restore.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c index 434dc7a0..d935caf6 100644 --- a/src/modules/module-stream-restore.c +++ b/src/modules/module-stream-restore.c @@ -532,6 +532,7 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) { pa_xfree(n); continue; } + pa_xfree(n); if (u->restore_volume) { pa_cvolume v; @@ -581,6 +582,7 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) { pa_xfree(n); continue; } + pa_xfree(n); if (u->restore_device && e->device_valid && -- cgit From 88fc458393e00834cec5abe6c26a3cf114398532 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 20:00:57 +0200 Subject: protocol-native: don't leak a proplist --- src/pulsecore/protocol-native.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 59fae984..a963f78a 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -2560,7 +2560,10 @@ static void command_create_upload_stream(pa_pdispatch *pd, uint32_t command, uin if (!(name = pa_proplist_gets(p, PA_PROP_EVENT_ID))) name = pa_proplist_gets(p, PA_PROP_MEDIA_NAME); - CHECK_VALIDITY(c->pstream, name && pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID); + if (!name || !pa_namereg_is_valid_name(name)) { + pa_proplist_free(p); + CHECK_VALIDITY(c->pstream, FALSE, tag, PA_ERR_INVALID); + } s = upload_stream_new(c, &ss, &map, name, length, p); pa_proplist_free(p); @@ -3590,24 +3593,30 @@ static void command_update_proplist(pa_pdispatch *pd, uint32_t command, uint32_t } } - CHECK_VALIDITY(c->pstream, mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE, tag, PA_ERR_INVALID); + if (!(mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE)) { + pa_proplist_free(p); + CHECK_VALIDITY(c->pstream, FALSE, tag, PA_ERR_INVALID); + } if (command == PA_COMMAND_UPDATE_PLAYBACK_STREAM_PROPLIST) { playback_stream *s; s = pa_idxset_get_by_index(c->output_streams, idx); - CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY); - CHECK_VALIDITY(c->pstream, playback_stream_isinstance(s), tag, PA_ERR_NOENTITY); - + if (!s || !playback_stream_isinstance(s)) { + pa_proplist_free(p); + CHECK_VALIDITY(c->pstream, FALSE, tag, PA_ERR_NOENTITY); + } pa_sink_input_update_proplist(s->sink_input, mode, p); } else if (command == PA_COMMAND_UPDATE_RECORD_STREAM_PROPLIST) { record_stream *s; - s = pa_idxset_get_by_index(c->record_streams, idx); - CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY); - + if (!(s = pa_idxset_get_by_index(c->record_streams, idx))) { + pa_proplist_free(p); + CHECK_VALIDITY(c->pstream, FALSE, tag, PA_ERR_NOENTITY); + } pa_source_output_update_proplist(s->source_output, mode, p); + } else { pa_assert(command == PA_COMMAND_UPDATE_CLIENT_PROPLIST); @@ -3615,6 +3624,7 @@ static void command_update_proplist(pa_pdispatch *pd, uint32_t command, uint32_t } pa_pstream_send_simple_ack(c->pstream, tag); + pa_proplist_free(p); } static void command_remove_proplist(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { -- cgit From 4722fecb993440db4df6a87203aee5eb796c5763 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 20:31:54 +0200 Subject: rtp: remove unused variable a --- src/modules/rtp/sdp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/rtp/sdp.c b/src/modules/rtp/sdp.c index 643361f2..7c547430 100644 --- a/src/modules/rtp/sdp.c +++ b/src/modules/rtp/sdp.c @@ -44,7 +44,7 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, uint16_t port, uint8_t payload, const pa_sample_spec *ss) { uint32_t ntp; char buf_src[64], buf_dst[64], un[64]; - const char *u, *f, *a; + const char *u, *f; pa_assert(src); pa_assert(dst); @@ -62,8 +62,8 @@ char *pa_sdp_build(int af, const void *src, const void *dst, const char *name, u ntp = (uint32_t) time(NULL) + 2208988800U; - pa_assert_se(a = inet_ntop(af, src, buf_src, sizeof(buf_src))); - pa_assert_se(a = inet_ntop(af, dst, buf_dst, sizeof(buf_dst))); + pa_assert_se(inet_ntop(af, src, buf_src, sizeof(buf_src))); + pa_assert_se(inet_ntop(af, dst, buf_dst, sizeof(buf_dst))); return pa_sprintf_malloc( PA_SDP_HEADER -- cgit From f1dcbe0f5d363f96d7ad44dcb5bd84d09b54ba3a Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 21:21:25 +0200 Subject: pulsecore: don't leak d in case of error --- src/pulsecore/core-util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 432ee3b7..623a4888 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -1443,6 +1443,7 @@ char *pa_get_runtime_dir(void) { if (pa_make_secure_dir(d, m, (uid_t) -1, (gid_t) -1) < 0) { pa_log_error("Failed to create secure directory: %s", pa_cstrerror(errno)); + pa_xfree(d); goto fail; } -- cgit From 800489eea907815427d08659034ad69dbb56b5e6 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 21:23:41 +0200 Subject: pulsecore: don't leak p when make_random_dir_and_link() --- src/pulsecore/core-util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 623a4888..a184bebd 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -1411,6 +1411,7 @@ static int make_random_dir_and_link(mode_t m, const char *k) { return -1; } + pa_xfree(p); return 0; } -- cgit From 7c78c3f6589eeba9e2a4d7f7abbcaaeb6a89d833 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Wed, 18 Feb 2009 21:35:18 +0200 Subject: alsa-util: check if mixer_poll_descriptors_count() < 0 --- src/modules/alsa/alsa-util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c index c53fd10d..a0907c4d 100644 --- a/src/modules/alsa/alsa-util.c +++ b/src/modules/alsa/alsa-util.c @@ -113,7 +113,7 @@ static void io_cb(pa_mainloop_api*a, pa_io_event* e, int fd, pa_io_event_flags_t static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) { struct pa_alsa_fdlist *fdl = userdata; unsigned num_fds, i; - int err; + int err, n; struct pollfd *temp; pa_assert(a); @@ -122,7 +122,11 @@ static void defer_cb(pa_mainloop_api*a, pa_defer_event* e, void *userdata) { a->defer_enable(fdl->defer, 0); - num_fds = (unsigned) snd_mixer_poll_descriptors_count(fdl->mixer); + if ((n = snd_mixer_poll_descriptors_count(fdl->mixer)) < 0) { + pa_log("snd_mixer_poll_descriptors_count() failed: %s", snd_strerror(n)); + return; + } + num_fds = (unsigned) n; if (num_fds != fdl->num_fds) { if (fdl->fds) -- cgit