2008-10-19 15:55:53

by Patryk Zawadzki

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

After some digging in the current GIT head:

bluetoothd[20589]: AVCTP: connected to 00:0D:FD:15:F0:3E
bluetoothd[20589]: AVRCP: uinput initialized for 00:0D:FD:15:F0:3E
bluetoothd[20589]: AVDTP: incoming connect from 00:0D:FD:15:F0:3E
DEBUG: trying to change from OPEN to OPEN
bluetoothd[20589]: stream state change failed: Input/output error

So for me it tries to change the stream state top OPEN twice.

Another debugging effort with pulseaudio bluetooth init:

bluetoothd[20589]: Received SET_CONFIGURATION_CMD
DEBUG: initializing stream sock to -1
[...]
bluetoothd[20851]: Audio API: received BT_SETCONFIGURATION_REQ
bluetoothd[20851]: config a2dp - device = 00:0D:FD:15:F0:3E access_mode = 2
bluetoothd[20851]: codec sbc - frequency = 2 channel_mode = 1
allocation = 1 subbands = 1 blocks = 1 bitpool = 44
bluetoothd[20851]: a2dp_source_config: selected SEP 0xb851c630
bluetoothd[20851]: avdtp_ref(0xb8521398): ref=4
bluetoothd[20851]: setup_ref(0xb8519490): ref=1
bluetoothd[20851]: setup_ref(0xb8519490): ref=2
bluetoothd[20851]: SEP 0xb851c630 locked
DEBUG: stream sock is -1
bluetoothd[20851]: Unable to get stream transport
bluetoothd[20851]: config failed

The stream socket does not seem to be set anywhere else along the way
(added debug prints to all stream socket changes in bluez code).
That's why get_transport returns FALSE. Still not sure if the bug is
in pulseaudio or in bluez.

Also sending this to bluez-devel, please don't shoot me for crossposting.

--
Patryk Zawadzki

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2008-10-20 21:05:36

by Johan Hedberg

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

Hi Luiz,

On Oct 20, 2008, at 23:53, Luiz Augusto von Dentz wrote:
> Im interested to know why the spec just don't say you need the
> transport to be OPEN as the state means, since from CONFIGURED to OPEN
> there is nothing else relevant to do regarding the state machine or
> does it? Well for now we could just create yet another state so sink.c
> could be notified when the transport is connected.

I don't really understand either why the spec is as it is with regard =

to the OPEN state. OTOH I think the current solution of going to OPEN =

when we have the transport seems to work well enough so unless =

something doesn't work with this approach I wouldn't go making the =

code more complicated by adding another state.

Johan

P.S. Parab=E9ns sobre o casamento! ;)
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great priz=
es
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=3D100&url=3D/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2008-10-20 20:53:47

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

Yes and no, it could be set to OPEN state before going really
connected, but it cannot emit the signal Connected otherwise
application will just try to get the fd which could not be available
thus a race condition could cause the problem. So if Connected signal
is mapped to OPEN state it wont work always. The problem could be that
the device simple want to go to STREAMING state which probably creates
the same situation on media transport, where headset and pulse are
competing to set the same state.

Im interested to know why the spec just don't say you need the
transport to be OPEN as the state means, since from CONFIGURED to OPEN
there is nothing else relevant to do regarding the state machine or
does it? Well for now we could just create yet another state so sink.c
could be notified when the transport is connected.


-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great priz=
es
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=3D100&url=3D/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2008-10-19 17:16:46

by Johan Hedberg

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

Hi,

On Oct 19, 2008, at 20:06, Patryk Zawadzki wrote:
> bluetoothd[24705]: Audio API: sending BT_STREAMSTART_RSP
> bluetoothd[24705]: Audio API: sending BT_STREAMFD_IND
> bluetoothd[24705]: setup_unref(0xb9c67a70): ref=1
> bluetoothd[24705]: setup_unref(0xb9c67a70): ref=0
> bluetoothd[24705]: setup_free(0xb9c67a70)
> bluetoothd[24705]: avdtp_unref(0xb9c5d468): ref=3
> DEBUG: trying to change stream state from 3 to 3
> bluetoothd[24705]: stream state change failed: Input/output error

Could you give some more info of what events triggered this than just
these few lines? Also, if possible come to #bluez on freenode.net so
we can discuss this in more detail there.

Johan

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2008-10-19 17:06:06

by Patryk Zawadzki

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

On Sun, Oct 19, 2008 at 6:54 PM, Patryk Zawadzki <[email protected]> wrote:
> On Sun, Oct 19, 2008 at 6:35 PM, Johan Hedberg <[email protected]> wrote:
>> Hi,
>>
>> I'm still investigating this, but it seems it's caused by patch
>> e303ffce67951a29d822c8c819e74e2c70c297d7 from Luiz which forgot to
>> remove set_state(OPEN) from avdtp_open_cmd() (his patch changes OPEN
>> state change for the initiator case from the response reveiving to the
>> stream L2CAP channel establishment). All in all looking at the AVDTP
>> spec 1.2 it seems Luiz's patch isn't correct since according to figure
>> 6.9 (page 35) the OPEN state should be entered *before* the stream
>> L2CAP channel is established.
> Ineed removing the set_state call from avdtp_open_cmd causes the
> device to initialize correctly and even work with pulseaudio. If this
> is correct according to the specification it is indeed the fix for the
> case of Motorola S9.

Also after getting the device to connect I get a second duplicate:

bluetoothd[24705]: Audio API: sending BT_STREAMSTART_RSP
bluetoothd[24705]: Audio API: sending BT_STREAMFD_IND
bluetoothd[24705]: setup_unref(0xb9c67a70): ref=1
bluetoothd[24705]: setup_unref(0xb9c67a70): ref=0
bluetoothd[24705]: setup_free(0xb9c67a70)
bluetoothd[24705]: avdtp_unref(0xb9c5d468): ref=3
DEBUG: trying to change stream state from 3 to 3
bluetoothd[24705]: stream state change failed: Input/output error

--
Patryk Zawadzki

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2008-10-19 16:54:18

by Patryk Zawadzki

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

On Sun, Oct 19, 2008 at 6:35 PM, Johan Hedberg <[email protected]> wrote:
> Hi,
>
> I'm still investigating this, but it seems it's caused by patch
> e303ffce67951a29d822c8c819e74e2c70c297d7 from Luiz which forgot to
> remove set_state(OPEN) from avdtp_open_cmd() (his patch changes OPEN
> state change for the initiator case from the response reveiving to the
> stream L2CAP channel establishment). All in all looking at the AVDTP
> spec 1.2 it seems Luiz's patch isn't correct since according to figure
> 6.9 (page 35) the OPEN state should be entered *before* the stream
> L2CAP channel is established.

Ineed removing the set_state call from avdtp_open_cmd causes the
device to initialize correctly and even work with pulseaudio. If this
is correct according to the specification it is indeed the fix for the
case of Motorola S9.

--
Patryk Zawadzki

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2008-10-19 16:35:26

by Johan Hedberg

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

Hi,

I'm still investigating this, but it seems it's caused by patch
e303ffce67951a29d822c8c819e74e2c70c297d7 from Luiz which forgot to
remove set_state(OPEN) from avdtp_open_cmd() (his patch changes OPEN
state change for the initiator case from the response reveiving to the
stream L2CAP channel establishment). All in all looking at the AVDTP
spec 1.2 it seems Luiz's patch isn't correct since according to figure
6.9 (page 35) the OPEN state should be entered *before* the stream
L2CAP channel is established.

Johan

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2008-10-19 16:09:58

by Patryk Zawadzki

[permalink] [raw]
Subject: Re: [Bluez-devel] [Bluez-users] Motorola S9 and BlueZ 4.14

And here's a full instrumented run:

bluetoothd[22394]: link_key_request (sba=00:1D:60:69:91:18,
dba=00:0D:FD:15:F0:3E)
bluetoothd[22394]: kernel auth requirements = 0x00
bluetoothd[22394]: stored link key type = 0x00
bluetoothd[22394]: adapter_get_device(00:0D:FD:15:F0:3E)
bluetoothd[22394]: hcid_dbus_bonding_process_complete: status=00
bluetoothd[22394]: adapter_get_device(00:0D:FD:15:F0:3E)
bluetoothd[22394]: hcid_dbus_bonding_process_complete: no pending auth request
bluetoothd[22394]: AVDTP: incoming connect from 00:0D:FD:15:F0:3E
bluetoothd[22394]: session_cb
bluetoothd[22394]: Received DISCOVER_CMD
bluetoothd[22394]: session_cb
bluetoothd[22394]: Received GET_CAPABILITIES_CMD
bluetoothd[22394]: Source 0xb9232388: Get_Capability_Ind
bluetoothd[22394]: session_cb
bluetoothd[22394]: Received SET_CONFIGURATION_CMD
DEBUG: setting stream sock to -1
bluetoothd[22394]: Source 0xb9232388: Set_Configuration_Ind
bluetoothd[22394]: avdtp_ref(0xb92374d8): ref=2
bluetoothd[22394]: stream state changed: IDLE -> CONFIGURED
bluetoothd[22394]: session_cb
bluetoothd[22394]: Received OPEN_CMD
bluetoothd[22394]: Source 0xb9232388: Open_Ind
bluetoothd[22394]: stream state changed: CONFIGURED -> OPEN
bluetoothd[22394]: Accepted new client connection on unix socket (fd=24)
bluetoothd[22394]: Audio API: received BT_GETCAPABILITIES_REQ
bluetoothd[22394]: avdtp_ref(0xb92374d8): ref=3
bluetoothd[22394]: AVCTP: connected to 00:0D:FD:15:F0:3E
bluetoothd[22394]: AVRCP: uinput initialized for 00:0D:FD:15:F0:3E
bluetoothd[22394]: session_cb
bluetoothd[22394]: DISCOVER request succeeded
bluetoothd[22394]: seid 1 type 1 media 0 in use 1
bluetoothd[22394]: seid 2 type 1 media 0 in use 1
bluetoothd[22394]: session_cb
bluetoothd[22394]: GET_CAPABILITIES request succeeded
bluetoothd[22394]: seid 1 type 1 media 0
bluetoothd[22394]: Audio API: sending BT_GETCAPABILITIES_RSP
bluetoothd[22394]: Audio API: received BT_SETCONFIGURATION_REQ
bluetoothd[22394]: config a2dp - device = 00:0D:FD:15:F0:3E access_mode = 2
bluetoothd[22394]: codec sbc - frequency = 2 channel_mode = 1
allocation = 1 subbands = 1 blocks = 1 bitpool = 44
bluetoothd[22394]: a2dp_source_config: selected SEP 0xb9232388
bluetoothd[22394]: avdtp_ref(0xb92374d8): ref=4
bluetoothd[22394]: setup_ref(0xb9234250): ref=1
bluetoothd[22394]: setup_ref(0xb9234250): ref=2
bluetoothd[22394]: SEP 0xb9232388 locked
DEBUG: stream sock is -1
bluetoothd[22394]: Unable to get stream transport
bluetoothd[22394]: config failed
bluetoothd[22394]: SEP 0xb9232388 unlocked
bluetoothd[22394]: Audio API: sending BT_SETCONFIGURATION_RSP
bluetoothd[22394]: avdtp_unref(0xb92374d8): ref=3
bluetoothd[22394]: setup_unref(0xb9234250): ref=1
bluetoothd[22394]: setup_unref(0xb9234250): ref=0
bluetoothd[22394]: setup_free(0xb9234250)
bluetoothd[22394]: avdtp_unref(0xb92374d8): ref=2
bluetoothd[22394]: Unix client disconnected (fd=24)
bluetoothd[22394]: AVDTP: incoming connect from 00:0D:FD:15:F0:3E
DEBUG: setting stream sock to 24
DEBUG: trying to change stream state from 2 to 2
bluetoothd[22394]: stream state change failed: Input/output error
bluetoothd[22394]: session_cb
bluetoothd[22394]: Received START_CMD
bluetoothd[22394]: Source 0xb9232388: Start_Ind
bluetoothd[22394]: avdtp_ref(0xb92374d8): ref=3
bluetoothd[22394]: stream state changed: OPEN -> STREAMING
bluetoothd[22394]: avdtp_unref(0xb92374d8): ref=2
bluetoothd[22394]: session_cb
bluetoothd[22394]: SUSPEND request succeeded
bluetoothd[22394]: stream state changed: STREAMING -> OPEN
bluetoothd[22394]: Source 0xb9232388: Suspend_Cfm
bluetoothd[22394]: session_cb
bluetoothd[22394]: CLOSE request succeeded
bluetoothd[22394]: stream state changed: OPEN -> CLOSING
DEBUG: setting stream sock to -1
bluetoothd[22394]: Source 0xb9232388: Close_Cfm
bluetoothd[22394]: stream state changed: CLOSING -> IDLE
bluetoothd[22394]: avdtp_unref(0xb92374d8): ref=1
bluetoothd[22394]: Disconnected from 00:0D:FD:15:F0:3E
bluetoothd[22394]: avdtp_unref(0xb92374d8): ref=0
bluetoothd[22394]: avdtp_unref(0xb92374d8): freeing session and
removing from list

What's interesting is the "connected to X"/"incoming connect from X"
pair that seems to cause double stream state change to OPEN. Also
there seems to be a race condition between bluez and pulseaudio's
bluetooth-discovery agent (notice where it tries to get stream
properties long before setting the connection socket).

--
Patryk Zawadzki

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel