[PATCH] avctp: Move state change callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In avctp_set_change the callbacks are happening before the switch.
The callbacks can change the state so they should happen at the end
of the function and not before the switch.
For example when the state is AVCTP_STATE_CONNECTED the
avrcp.c:state_changed callback creates a browsing channel which in
turn is destroyed immediately a few lines below in the
AVCTP_STATE_CONNECTED case.

---
 profiles/audio/avctp.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c
index 41e2f46..2515505 100644
--- a/profiles/audio/avctp.c
+++ b/profiles/audio/avctp.c
@@ -473,13 +473,6 @@ static void avctp_set_state(struct avctp *session, avctp_state_t new_state)
 		return;
 	}
 
-	session->state = new_state;
-
-	for (l = callbacks; l != NULL; l = l->next) {
-		struct avctp_state_callback *cb = l->data;
-		cb->cb(dev, old_state, new_state, cb->user_data);
-	}
-
 	switch (new_state) {
 	case AVCTP_STATE_DISCONNECTED:
 		DBG("AVCTP Disconnected");
@@ -505,6 +498,14 @@ static void avctp_set_state(struct avctp *session, avctp_state_t new_state)
 		error("Invalid AVCTP state %d", new_state);
 		return;
 	}
+
+	session->state = new_state;
+
+	for (l = callbacks; l != NULL; l = l->next) {
+		struct avctp_state_callback *cb = l->data;
+		cb->cb(dev, old_state, new_state, cb->user_data);
+	}
+
 }
 
 static int avctp_send(struct avctp_channel *control, uint8_t transaction,
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux