public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: "Sébastien Viande" <sviande@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: "Sébastien Viande" <sviande@gmail.com>
Subject: [PATCH BlueZ] [BlueZ] audio/a2dp: refcount
Date: Wed, 21 Jul 2021 11:17:27 +0200	[thread overview]
Message-ID: <20210721091727.177872-1-sviande@gmail.com> (raw)

Fix a2dp setup.

I'm not the initial author of the code you can find the source on
https://patches.linaro.org/patch/285268/

This patch fix my problem the a2dp source not available there was only
HSP/HFP.
---
 profiles/audio/a2dp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 86bc02994..be707edda 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1568,6 +1568,8 @@ static void channel_free(void *data)
 	}
 
 	avdtp_remove_state_cb(chan->state_id);
+	if (chan->session)
+		avdtp_unref(chan->session);
 
 	queue_destroy(chan->seps, remove_remote_sep);
 	free(chan->last_used);
@@ -2149,7 +2151,7 @@ static void avdtp_state_cb(struct btd_device *dev, struct avdtp *session,
 		break;
 	case AVDTP_SESSION_STATE_CONNECTED:
 		if (!chan->session)
-			chan->session = session;
+			chan->session = avdtp_ref(session);
 		load_remote_seps(chan);
 		break;
 	}
@@ -2229,6 +2231,7 @@ found:
 		channel_remove(chan);
 		return NULL;
 	}
+	avdtp_ref(chan->session);
 
 	return avdtp_ref(chan->session);
 }
@@ -2249,6 +2252,7 @@ static void connect_cb(GIOChannel *io, GError *err, gpointer user_data)
 			error("Unable to create AVDTP session");
 			goto fail;
 		}
+		avdtp_ref(chan->session);
 	}
 
 	g_io_channel_unref(chan->io);
-- 
2.32.0


             reply	other threads:[~2021-07-21  9:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21  9:17 Sébastien Viande [this message]
2021-07-21  9:58 ` [BlueZ,BlueZ] audio/a2dp: refcount bluez.test.bot
2021-07-21 17:02 ` [PATCH BlueZ] [BlueZ] " Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210721091727.177872-1-sviande@gmail.com \
    --to=sviande@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox