public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] error in headset capture, patch included
@ 2008-01-09  0:28 Pavel Semerad
  2008-01-09  3:03 ` Johan Hedberg
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pavel Semerad @ 2008-01-09  0:28 UTC (permalink / raw)
  To: bluez-devel


Helo,

I have found error in function bluetooth_hsp_read. frame_size is
correctly set only when data->count is zero. When data->count is
nonzero, frame_size is 0 and condition
'if ((data->count + size * frame_size) <= data->link_mtu)'
is always true and frames_to_write is set incorrectly (1000 instead
max 24 in my case). This results in capture not working for headset,
cycling in endless loop.

Following patch sets frame_size before check to data->count and
'arecord -D bluetooth -f S16_LE' now works.

Pavel Semerad



--- ./audio/pcm_bluetooth.c.capture     2007-12-08 20:04:40.000000000
+0100
+++ ./audio/pcm_bluetooth.c     2008-01-09 01:12:02.000000000 +0100
@ -786,11 +786,11 @@ static snd_pcm_sframes_t bluetooth_hsp_r
        DBG("areas->step=%u areas->first=%u offset=%lu size=%lu
io->nonblock=%u",
                        areas->step, areas->first, offset, size,
io->nonblock);
 
+       frame_size = areas->step / 8;
+
        if (data->count > 0)
                goto proceed;
 
-       frame_size = areas->step / 8;
-
        nrecv = recv(data->stream.fd, data->buffer, data->link_mtu,
                        MSG_WAITALL | (io->nonblock ? MSG_DONTWAIT :
0));
 

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Bluez-devel] error in headset capture, patch included
  2008-01-09  0:28 [Bluez-devel] error in headset capture, patch included Pavel Semerad
@ 2008-01-09  3:03 ` Johan Hedberg
  2008-01-09 10:37 ` [Bluez-devel] [PATCH] HFP - Rejecting a call Alok
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2008-01-09  3:03 UTC (permalink / raw)
  To: BlueZ development

Hi Pavel,

On Jan 9, 2008, at 2:28, Pavel Semerad wrote:
> I have found error in function bluetooth_hsp_read. frame_size is
> correctly set only when data->count is zero. When data->count is
> nonzero, frame_size is 0 and condition
> 'if ((data->count + size * frame_size) <= data->link_mtu)'
> is always true and frames_to_write is set incorrectly (1000 instead
> max 24 in my case). This results in capture not working for headset,
> cycling in endless loop.
>
> Following patch sets frame_size before check to data->count and
> 'arecord -D bluetooth -f S16_LE' now works.

Nice catch! Thanks! Commited to CVS now.

Johan

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bluez-devel] [PATCH] HFP - Rejecting a call
  2008-01-09  0:28 [Bluez-devel] error in headset capture, patch included Pavel Semerad
  2008-01-09  3:03 ` Johan Hedberg
@ 2008-01-09 10:37 ` Alok
  2008-01-10 15:24 ` [Bluez-devel] [PATCH][HFP] - default device as hfp Alok
  2008-01-10 15:36 ` [Bluez-devel] [PATCH][HFP] - Setting the inband Ringtone Alok
  3 siblings, 0 replies; 5+ messages in thread
From: Alok @ 2008-01-09 10:37 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]

Hi Johan, 

Here is a patch which handles the "Call Rejection" use case.
Let me know if anything needs to be changed. 

Alok. 

[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 955 bytes --]

Index: audio/headset.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/headset.c,v
retrieving revision 1.155
diff -u -5 -p -r1.155 headset.c
--- audio/headset.c	9 Jan 2008 03:00:22 -0000	1.155
+++ audio/headset.c	9 Jan 2008 10:05:54 -0000
@@ -250,19 +250,21 @@ static int terminate_call(struct device 
 
 	dbus_connection_emit_signal(device->conn, device->path,
 			AUDIO_HEADSET_INTERFACE, "CallTerminated",
 			DBUS_TYPE_INVALID);
 
+	err = headset_send(hs, "\r\nOK\r\n");
+	if (err < 0)
+		return err;
+
 	if (hs->ring_timer) {
 		g_source_remove(hs->ring_timer);
 		hs->ring_timer = 0;
+		/*+CIEV: (callsetup = 0)*/
+		return headset_send(hs, "\r\n+CIEV:2, 0\r\n");
 	}
 
-	err = headset_send(hs, "\r\nOK\r\n");
-	if (err < 0)
-		return err;
-
 	/*+CIEV: (call = 0)*/
 	return headset_send(hs, "\r\n+CIEV:2, 0\r\n");
 }
 
 static int signal_gain_setting(struct device *device, const char *buf)

[-- Attachment #3: Type: text/plain, Size: 278 bytes --]

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bluez-devel] [PATCH][HFP] - default device as hfp
  2008-01-09  0:28 [Bluez-devel] error in headset capture, patch included Pavel Semerad
  2008-01-09  3:03 ` Johan Hedberg
  2008-01-09 10:37 ` [Bluez-devel] [PATCH] HFP - Rejecting a call Alok
@ 2008-01-10 15:24 ` Alok
  2008-01-10 15:36 ` [Bluez-devel] [PATCH][HFP] - Setting the inband Ringtone Alok
  3 siblings, 0 replies; 5+ messages in thread
From: Alok @ 2008-01-10 15:24 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

Hi Johan, 

Attaching a patch which fixes a HFP bug in headset.c  

When a default device/stored device is registered, it cannot be used as
a handsfree (i.e hs->hfp_active = false) because the following condition
in rfcomm_connect_cb() fails. 

 if (server_is_enabled(HANDSFREE_SVCLASS_ID) && hs->hfp_handle != 0) 

This is because, hs->hfp_handle is not populated for the default
device.As a matter of fact, hs->hsp_handle is not populated either.
verified this by printing the handles.

The 2 handles are ONLY populated through a call to headset_init() with
its 2nd and 3rd arguments not being zero.

I have tested this patch with my setup. 

Let me know if my logic is wrong or the patch needs to be changed.


Thanks, 
Alok. 


[-- Attachment #2: patch --]
[-- Type: text/x-patch, Size: 910 bytes --]

Index: audio/headset.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/headset.c,v
retrieving revision 1.156
diff -u -5 -p -r1.156 headset.c
--- audio/headset.c	9 Jan 2008 12:36:58 -0000	1.156
+++ audio/headset.c	10 Jan 2008 14:43:36 -0000
@@ -752,10 +752,16 @@ static void get_record_reply(DBusPending
 		|| (uuid.type == SDP_UUID16 && uuid.value.uuid16 != id)) {
 		error("Service classes did not contain the expected UUID");
 		goto failed_not_supported;
 	}
 
+	if ((uuid.value.uuid32 == HANDSFREE_SVCLASS_ID)
+		|| (uuid.value.uuid16 == HANDSFREE_SVCLASS_ID)) {
+		hs->hfp_handle = record->handle;
+	}else
+		hs->hsp_handle = record->handle;
+
 	if (!sdp_get_access_protos(record, &protos)) {
 		ch = sdp_get_proto_port(protos, RFCOMM_UUID);
 		sdp_list_foreach(protos, (sdp_list_func_t) sdp_list_free,
 					NULL);
 		sdp_list_free(protos, NULL);

[-- Attachment #3: Type: text/plain, Size: 278 bytes --]

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bluez-devel] [PATCH][HFP] - Setting the inband Ringtone
  2008-01-09  0:28 [Bluez-devel] error in headset capture, patch included Pavel Semerad
                   ` (2 preceding siblings ...)
  2008-01-10 15:24 ` [Bluez-devel] [PATCH][HFP] - default device as hfp Alok
@ 2008-01-10 15:36 ` Alok
  3 siblings, 0 replies; 5+ messages in thread
From: Alok @ 2008-01-10 15:36 UTC (permalink / raw)
  To: BlueZ development

[-- Attachment #1: Type: text/plain, Size: 545 bytes --]

Hi Johan, 

Here is a patch to change the In-BandRingtone setting through a D-Bus
method. 

Let me know if the Method/Signal names are fine with you. 

Ill send the patch for the audio-api.txt next.

Do you think we shud have a DBus method call to Identify the type of
headset i.e HSP/HFP? A method like "IsHFP" which returns the value of
hs->hfp_active will be useful. Otherwise there is no way to know (apart
for reading /etc/bluetooth/audio.conf) what profile is active. 


Let me know if anything in the patch needs to be changed. 
-Alok.  

[-- Attachment #2: patch1 --]
[-- Type: text/x-patch, Size: 2997 bytes --]

Index: audio/headset.c
===================================================================
RCS file: /cvsroot/bluez/utils/audio/headset.c,v
retrieving revision 1.156
diff -u -5 -p -r1.156 headset.c
--- audio/headset.c	9 Jan 2008 12:36:58 -0000	1.156
+++ audio/headset.c	10 Jan 2008 15:04:17 -0000
@@ -1447,10 +1453,67 @@ static DBusHandlerResult hf_setup_call(D
 	send_message_and_unref(conn, reply);
 
 	return DBUS_HANDLER_RESULT_HANDLED;
 }
 
+static DBusHandlerResult hf_set_inband(DBusConnection *conn,
+						DBusMessage *msg,
+						void *data)
+{
+	struct device *device = data;
+	struct headset *hs = device->headset;
+	DBusMessage *reply;
+	DBusError derr;
+	gboolean *active;
+	int err;
+
+	if (!hs->hfp_active)
+		return error_not_supported(device->conn, msg);
+
+	if (hs->state < HEADSET_STATE_CONNECTED)
+		return error_not_connected(conn, msg);
+
+	dbus_error_init(&derr);
+	dbus_message_get_args(msg, &derr, DBUS_TYPE_BOOLEAN, &active,
+				DBUS_TYPE_INVALID);
+
+	if (dbus_error_is_set(&derr)) {
+		error_invalid_arguments(conn, msg, derr.message);
+		dbus_error_free(&derr);
+		return DBUS_HANDLER_RESULT_HANDLED;
+	}
+
+	reply = dbus_message_new_method_return(msg);
+	if (!reply)
+		return DBUS_HANDLER_RESULT_NEED_MEMORY;
+
+	if (active && !(ag_features & AG_FEATURE_INBAND_RINGTONE)) {
+		ag_features |= AG_FEATURE_INBAND_RINGTONE;
+		err = headset_send(hs, "\r\n+BSIR:1\r\n");
+	}
+
+	if (!active && (ag_features & AG_FEATURE_INBAND_RINGTONE)) {
+		ag_features &= ~AG_FEATURE_INBAND_RINGTONE;
+		err = headset_send(hs, "\r\n+BSIR:0\r\n");
+	}
+
+	if (err < 0) {
+		dbus_message_unref(reply);
+		return error_failed(conn, msg, "Unable to send to headset");
+	}
+
+	dbus_connection_emit_signal(conn, device->path,
+						AUDIO_HEADSET_INTERFACE,
+						"InBandSettingChanged",
+						DBUS_TYPE_BOOLEAN, &active,
+						DBUS_TYPE_INVALID);
+
+	send_message_and_unref(conn, reply);
+
+	return DBUS_HANDLER_RESULT_HANDLED;
+}
+
 static DBusMethodVTable headset_methods[] = {
 	{ "Connect",		hs_connect,		"",	""	},
 	{ "Disconnect",		hs_disconnect,		"",	""	},
 	{ "IsConnected",	hs_is_connected,	"",	"b"	},
 	{ "IndicateCall",	hs_ring,		"",	""	},
@@ -1461,10 +1524,11 @@ static DBusMethodVTable headset_methods[
 	{ "GetSpeakerGain",	hs_get_speaker_gain,	"",	"q"	},
 	{ "GetMicrophoneGain",	hs_get_mic_gain,	"",	"q"	},
 	{ "SetSpeakerGain",	hs_set_speaker_gain,	"q",	""	},
 	{ "SetMicrophoneGain",	hs_set_mic_gain,	"q",	""	},
 	{ "SetupCall",		hf_setup_call,		"s",	""	},
+	{ "SetInbandRingtone",	hf_set_inband,		"b",	""	},
 	{ NULL, NULL, NULL, NULL }
 };
 
 static DBusSignalVTable headset_signals[] = {
 	{ "Connected",			""	},
@@ -1473,10 +1537,11 @@ static DBusSignalVTable headset_signals[
 	{ "Stopped",			""	},
 	{ "Playing",			""	},
 	{ "SpeakerGainChanged",		"q"	},
 	{ "MicrophoneGainChanged",	"q"	},
 	{ "CallTerminated",		""	},
+	{ "InBandSettingChanged",	"b"	},
 	{ NULL, NULL }
 };
 
 static void headset_set_channel(struct headset *headset, sdp_record_t *record)
 {

[-- Attachment #3: Type: text/plain, Size: 278 bytes --]

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-01-10 15:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-09  0:28 [Bluez-devel] error in headset capture, patch included Pavel Semerad
2008-01-09  3:03 ` Johan Hedberg
2008-01-09 10:37 ` [Bluez-devel] [PATCH] HFP - Rejecting a call Alok
2008-01-10 15:24 ` [Bluez-devel] [PATCH][HFP] - default device as hfp Alok
2008-01-10 15:36 ` [Bluez-devel] [PATCH][HFP] - Setting the inband Ringtone Alok

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox