[pulseaudio-commits] 4 commits - src/modules
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Tue Nov 21 13:18:56 UTC 2017
src/modules/echo-cancel/module-echo-cancel.c | 22 ++++++++++++++++++++++
src/modules/module-card-restore.c | 8 ++++++--
2 files changed, 28 insertions(+), 2 deletions(-)
New commits:
commit 6b92027c194dc719c11f2fc39cfbdca2e5e2d5c4
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Thu Nov 9 14:12:34 2017 +0200
echo-cancel: fix a memory leak
The pa_echo_canceller_msg object was never unreffed.
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index ee3725ab..4fc837d2 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -2164,8 +2164,10 @@ void pa__done(pa_module*m) {
if (u->ec->done)
u->ec->done(u->ec);
- if (u->ec->msg)
+ if (u->ec->msg) {
u->ec->msg->dead = true;
+ pa_echo_canceller_msg_unref(u->ec->msg);
+ }
pa_xfree(u->ec);
}
@@ -2346,6 +2348,7 @@ int main(int argc, char* argv[]) {
u.ec->done(u.ec);
u.ec->msg->dead = true;
+ pa_echo_canceller_msg_unref(u.ec->msg);
out:
if (u.captured_file)
commit 5f29b838ff28939df1fbbb85b13f51b8ad866779
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Thu Nov 9 14:12:33 2017 +0200
echo-cancel: ignore remaining canceller messages after the module has been unloaded
Not ignoring the messages caused crashing due to accessing the userdata
after it had been freed.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=103528
diff --git a/src/modules/echo-cancel/module-echo-cancel.c b/src/modules/echo-cancel/module-echo-cancel.c
index b28d60a6..ee3725ab 100644
--- a/src/modules/echo-cancel/module-echo-cancel.c
+++ b/src/modules/echo-cancel/module-echo-cancel.c
@@ -184,6 +184,7 @@ struct userdata;
struct pa_echo_canceller_msg {
pa_msgobject parent;
+ bool dead;
struct userdata *userdata;
};
@@ -1553,6 +1554,20 @@ static int canceller_process_msg_cb(pa_msgobject *o, int code, void *userdata, i
pa_assert(o);
msg = PA_ECHO_CANCELLER_MSG(o);
+
+ /* When the module is unloaded, there may still remain queued messages for
+ * the canceller. Messages are sent to the main thread using the master
+ * source's asyncmsgq, and that message queue isn't (and can't be, at least
+ * with the current asyncmsgq API) cleared from the canceller messages when
+ * module-echo-cancel is unloaded.
+ *
+ * The userdata may already have been freed at this point, but the
+ * asyncmsgq holds a reference to the pa_echo_canceller_msg object, which
+ * contains a flag to indicate that all remaining messages have to be
+ * ignored. */
+ if (msg->dead)
+ return 0;
+
u = msg->userdata;
switch (code) {
@@ -2149,6 +2164,9 @@ void pa__done(pa_module*m) {
if (u->ec->done)
u->ec->done(u->ec);
+ if (u->ec->msg)
+ u->ec->msg->dead = true;
+
pa_xfree(u->ec);
}
@@ -2327,6 +2345,7 @@ int main(int argc, char* argv[]) {
}
u.ec->done(u.ec);
+ u.ec->msg->dead = true;
out:
if (u.captured_file)
commit d65974d8501052bafb03e65f5df954511e9949a2
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Wed Nov 8 14:20:23 2017 +0200
card-restore: don't restore unavailable profiles
diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 2d3a91c0..b7189ad5 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -561,8 +561,12 @@ static pa_hook_result_t card_choose_initial_profile_callback(pa_core *core, pa_c
profile = pa_hashmap_get(card->profiles, e->profile);
if (profile) {
- pa_log_info("Restoring profile '%s' for card %s.", profile->name, card->name);
- pa_card_set_profile(card, profile, true);
+ if (profile->available != PA_AVAILABLE_NO) {
+ pa_log_info("Restoring profile '%s' for card %s.", profile->name, card->name);
+ pa_card_set_profile(card, profile, true);
+ } else
+ pa_log_debug("Not restoring profile %s for card %s, because the profile is currently unavailable.",
+ profile->name, card->name);
} else {
pa_log_debug("Tried to restore profile %s for card %s, but the card doesn't have such profile.",
e->profile, card->name);
commit 33e31b5b70be30a9b59de155aec59807d5f93bc7
Author: Tanu Kaskinen <tanuk at iki.fi>
Date: Wed Nov 8 14:20:22 2017 +0200
card-restore: log the correct profile name
diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
index 3c0307be..2d3a91c0 100644
--- a/src/modules/module-card-restore.c
+++ b/src/modules/module-card-restore.c
@@ -561,7 +561,7 @@ static pa_hook_result_t card_choose_initial_profile_callback(pa_core *core, pa_c
profile = pa_hashmap_get(card->profiles, e->profile);
if (profile) {
- pa_log_info("Restoring profile '%s' for card %s.", card->active_profile->name, card->name);
+ pa_log_info("Restoring profile '%s' for card %s.", profile->name, card->name);
pa_card_set_profile(card, profile, true);
} else {
pa_log_debug("Tried to restore profile %s for card %s, but the card doesn't have such profile.",
More information about the pulseaudio-commits
mailing list