Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 08/13] android/handsfree: Move clip into device structure
Date: Wed, 8 Oct 2014 11:06:14 +0300	[thread overview]
Message-ID: <20141008080611.GA429@aemeltch-MOBL1> (raw)
In-Reply-To: <1412752343-7001-8-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Wed, Oct 08, 2014 at 09:12:18AM +0200, Szymon Janc wrote:
> ---
>  android/handsfree.c | 36 ++++++++++++++++++++++++------------
>  1 file changed, 24 insertions(+), 12 deletions(-)

This one would benefit from small commit msg.

> 
> diff --git a/android/handsfree.c b/android/handsfree.c
> index d83f0a2..e7b8a6e 100644
> --- a/android/handsfree.c
> +++ b/android/handsfree.c
> @@ -131,6 +131,7 @@ struct hf_device {
>  	struct hfp_codec codecs[CODECS_COUNT];
>  
>  	guint ring;
> +	char *clip;
>  	bool hsp;
>  
>  	struct hfp_gw *gw;
> @@ -255,6 +256,11 @@ static void device_cleanup(struct hf_device *dev)
>  	if (dev->ring) {
>  		g_source_remove(dev->ring);
>  		dev->ring = 0;
> +
> +		if (dev->clip) {
> +			g_free(dev->clip);
> +			dev->clip = NULL;

Is this needed? apparently there is memset(dev,0,) after that.

Best regards 
Andrei Emeltchenko 

> +		}
>  	}
>  
>  	set_audio_state(dev, HAL_EV_HANDSFREE_AUDIO_STATE_DISCONNECTED);
> @@ -2018,12 +2024,12 @@ done:
>  
>  static gboolean ring_cb(gpointer user_data)
>  {
> -	char *clip = user_data;
> +	struct hf_device *dev = user_data;
>  
> -	hfp_gw_send_info(device.gw, "RING");
> +	hfp_gw_send_info(dev->gw, "RING");
>  
> -	if (device.clip_enabled && clip)
> -		hfp_gw_send_info(device.gw, "%s", clip);
> +	if (dev->clip_enabled && dev->clip)
> +		hfp_gw_send_info(dev->gw, "%s", dev->clip);
>  
>  	return TRUE;
>  }
> @@ -2065,7 +2071,7 @@ static void phone_state_waiting(int num_active, int num_held, uint8_t type,
>  static void phone_state_incoming(int num_active, int num_held, uint8_t type,
>  					const uint8_t *number, int number_len)
>  {
> -	char *clip, *num;
> +	char *num;
>  
>  	if (device.setup_state == HAL_HANDSFREE_CALL_STATE_INCOMING) {
>  		if (device.num_active != num_active ||
> @@ -2096,19 +2102,20 @@ static void phone_state_incoming(int num_active, int num_held, uint8_t type,
>  	num = number_len ? (char *) number : "";
>  
>  	if (type == HAL_HANDSFREE_CALL_ADDRTYPE_INTERNATIONAL && num[0] != '+')
> -		clip = g_strdup_printf("+CLIP: \"+%s\",%u", num, type);
> +		device.clip = g_strdup_printf("+CLIP: \"+%s\",%u", num, type);
>  	else
> -		clip = g_strdup_printf("+CLIP: \"%s\",%u", num, type);
> +		device.clip = g_strdup_printf("+CLIP: \"%s\",%u", num, type);
>  
>  	/* send first RING */
> -	ring_cb(clip);
> +	ring_cb(&device);
>  
>  	device.ring = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT,
>  							RING_TIMEOUT, ring_cb,
> -							clip, g_free);
> -
> -	if (!device.ring)
> -		g_free(clip);
> +							&device, NULL);
> +	if (!device.ring) {
> +		g_free(device.clip);
> +		device.clip = NULL;
> +	}
>  }
>  
>  static void phone_state_idle(int num_active, int num_held)
> @@ -2116,6 +2123,11 @@ static void phone_state_idle(int num_active, int num_held)
>  	if (device.ring) {
>  		g_source_remove(device.ring);
>  		device.ring = 0;
> +
> +		if (device.clip) {
> +			g_free(device.clip);
> +			device.clip = NULL;
> +		}
>  	}
>  
>  	switch (device.setup_state) {
> -- 
> 1.9.1
> 
> --
> 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

  reply	other threads:[~2014-10-08  8:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-08  7:12 [PATCH 01/13] android/handsfree: Define proper type for device structure Szymon Janc
2014-10-08  7:12 ` [PATCH 02/13] android/handsfree: Make init, cleanup and state functions static less Szymon Janc
2014-10-08  7:12 ` [PATCH 03/13] android/handsfree: Pass device as user data to AT handlers Szymon Janc
2014-10-08  7:12 ` [PATCH 04/13] android/handsfree: Pass device to connection handling functions Szymon Janc
2014-10-08  7:12 ` [PATCH 05/13] android/handsfree: Pass device pointer when registering AT commands Szymon Janc
2014-10-08  7:12 ` [PATCH 06/13] android/handsfree: Pass device pointer to codec handling functions Szymon Janc
2014-10-08  7:12 ` [PATCH 07/13] android/handsfree: Pass device to SCO " Szymon Janc
2014-10-08  7:12 ` [PATCH 08/13] android/handsfree: Move clip into device structure Szymon Janc
2014-10-08  8:06   ` Andrei Emeltchenko [this message]
2014-10-08  7:12 ` [PATCH 09/13] android/handsfree: Pass device to SCO handling functions Szymon Janc
2014-10-08  8:10   ` Andrei Emeltchenko
2014-10-08  7:12 ` [PATCH 10/13] android/handsfree: Pass device object to disconnect watch Szymon Janc
2014-10-08  7:12 ` [PATCH 11/13] android/handsfree: Pass device to phone state and indicators functions Szymon Janc
2014-10-08  7:12 ` [PATCH 12/13] android/handsfree: Add helper for getting device Szymon Janc
2014-10-08  8:23   ` Andrei Emeltchenko
2014-10-08  9:44     ` Szymon Janc
2014-10-08  7:12 ` [PATCH 13/13] android/handsfree: Make remote device non-static Szymon Janc
2014-10-08  8:30   ` Andrei Emeltchenko

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=20141008080611.GA429@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=szymon.janc@tieto.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