From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 01/12] android/avrcp-lib: Change API to register callbacks instead of PDU handlers
Date: Mon, 17 Mar 2014 10:38:39 +0200 [thread overview]
Message-ID: <20140317083837.GA16561@aemeltch-MOBL1> (raw)
In-Reply-To: <1395043737-8905-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Mar 17, 2014 at 10:08:46AM +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This adds avrcp_register_player function to register callbacks for
> requests and responses, the fundamental difference is that the
> callbacks are called after the original PDU is parsed and the parameter
> are converted to host byte order making us able to unit test the
> parsing itself.
> ---
> android/avrcp-lib.c | 27 +++++++++++++++++++++++++++
> android/avrcp-lib.h | 11 +++++++++++
> 2 files changed, 38 insertions(+)
>
> diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
> index 7b043ce..ca01b50 100644
> --- a/android/avrcp-lib.c
> +++ b/android/avrcp-lib.c
> @@ -73,6 +73,7 @@ struct avrcp_header {
>
> struct avrcp {
> struct avctp *conn;
> + struct avrcp_player *player;
>
> size_t tx_mtu;
> uint8_t *tx_buf;
> @@ -89,6 +90,13 @@ struct avrcp {
> void *destroy_data;
> };
>
> +struct avrcp_player {
> + const struct avrcp_control_ind *ind;
> + const struct avrcp_control_cfm *cfm;
> +
> + void *user_data;
> +};
> +
> void avrcp_shutdown(struct avrcp *session)
> {
> if (session->conn) {
> @@ -107,6 +115,7 @@ void avrcp_shutdown(struct avrcp *session)
> if (session->destroy)
> session->destroy(session->destroy_data);
>
> + g_free(session->player);
The player seems not allocated by default, so it should not be clean here.
I would also make player_unregister() to make it consistent with
player_register()
Best regards
Andrei Emeltchenko
> g_free(session->tx_buf);
> g_free(session);
> }
> @@ -162,6 +171,9 @@ static ssize_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
> switch (ret) {
> case -EAGAIN:
> return ret;
> + case -ENOSYS:
> + pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
> + goto reject;
> case -EINVAL:
> pdu->params[0] = AVRCP_STATUS_INVALID_PARAM;
> goto reject;
> @@ -249,6 +261,21 @@ void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
> session->destroy_data = user_data;
> }
>
> +void avrcp_register_player(struct avrcp *session,
> + const struct avrcp_control_ind *ind,
> + const struct avrcp_control_cfm *cfm,
> + void *user_data)
> +{
> + struct avrcp_player *player;
> +
> + player = g_new0(struct avrcp_player, 1);
> + player->ind = ind;
> + player->cfm = cfm;
> + player->user_data = user_data;
> +
> + session->player = player;
> +}
> +
> void avrcp_set_control_handlers(struct avrcp *session,
> const struct avrcp_control_handler *handlers,
> void *user_data)
> diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
> index 4adf4bf..6e33a75 100644
> --- a/android/avrcp-lib.h
> +++ b/android/avrcp-lib.h
> @@ -100,6 +100,12 @@ struct avrcp_control_handler {
> uint16_t params_len, uint8_t *params, void *user_data);
> };
>
> +struct avrcp_control_ind {
> +};
> +
> +struct avrcp_control_cfm {
> +};
> +
> struct avrcp_passthrough_handler {
> uint8_t op;
> bool (*func) (struct avrcp *session, bool pressed, void *user_data);
> @@ -123,6 +129,11 @@ struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version);
> void avrcp_shutdown(struct avrcp *session);
> void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
> void *user_data);
> +
> +void avrcp_register_player(struct avrcp *session,
> + const struct avrcp_control_ind *ind,
> + const struct avrcp_control_cfm *cfm,
> + void *user_data);
> void avrcp_set_control_handlers(struct avrcp *session,
> const struct avrcp_control_handler *handlers,
> void *user_data);
> --
> 1.8.5.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-03-17 8:38 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-17 8:08 [PATCH BlueZ 01/12] android/avrcp-lib: Change API to register callbacks instead of PDU handlers Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 02/12] android/avrcp-lib: Add support for parsing GetCapabilities PDU Luiz Augusto von Dentz
2014-03-17 8:42 ` Andrei Emeltchenko
2014-03-17 9:25 ` Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 03/12] android/avrcp-lib: Add support for parsing ListPlayerAttributes PDU Luiz Augusto von Dentz
2014-03-17 8:47 ` Andrei Emeltchenko
2014-03-17 8:54 ` Andrei Emeltchenko
2014-03-17 8:08 ` [PATCH BlueZ 04/12] android/avrcp-lib: Add support for parsing GetPlayerAttributeText PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 05/12] android/avrcp-lib: Add support for parsing ListPlayerValues PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 06/12] android/avrcp-lib: Add support for parsing GetPlayerValueText PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 07/12] android/avrcp-lib: Add support for parsing GetCurrentPlayerValue PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 08/12] android/avrcp-lib: Add support for parsing SetPlayerValue PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 09/12] android/avrcp-lib: Add support for parsing GetPlayStatus PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 10/12] android/avrcp-lib: Add support for parsing GetElementAttributes PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 11/12] android/avrcp-lib: Add support for parsing ResgisterNotification PDU Luiz Augusto von Dentz
2014-03-17 8:08 ` [PATCH BlueZ 12/12] android/avrcp-lib: Add support for parsing SetAddressedPlayer PDU Luiz Augusto von Dentz
2014-03-17 8:38 ` Andrei Emeltchenko [this message]
2014-03-17 9:22 ` [PATCH BlueZ 01/12] android/avrcp-lib: Change API to register callbacks instead of PDU handlers Luiz Augusto von Dentz
2014-03-17 13:01 ` 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=20140317083837.GA16561@aemeltch-MOBL1 \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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