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(-) (limited to 'src/modules') 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(-) (limited to 'src/modules') 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(-) (limited to 'src/modules') 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(+) (limited to 'src/modules') 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 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(-) (limited to 'src/modules') 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(+) (limited to 'src/modules') 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(-) (limited to 'src/modules') 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 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(-) (limited to 'src/modules') 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 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(-) (limited to 'src/modules') 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 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(+) (limited to 'src/modules') 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 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(-) (limited to 'src/modules') 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 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(-) (limited to 'src/modules') 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