Closed tfabris closed 6 years ago
CORRECTION: This is fixed by an "A2DP STREAMING START" command. I repro'd it on the debug cable and issued a streaming start command and it worked and the audio came back. Need to investigate places where I can better add streaming start commands.
Here is a debug output, note where you hand-issued streaming start. The audio worked after issuing the streaming start.
I have checked in a change which adds an "A2DP STREAMING START" command which I am hoping will fix this issue. The checkin is in version 1.0.96 in commit number 95bac912b5e978ff5a6ab6ba7a8c8fdee9439bb9 - I am not sure if this will fix it or not.
I am closing this issue until I see it recur. I have high hopes for the fix from 1.0.96.
The issue recurred, I have debug output from it, and the additional "A2DP STREAMING START" from 1.0.96 did not fix the issue.
Note: This issue is exceedingly rare now.
This is not the same thing as issue #70, I don't think, but here is an interesting similarity:
Good playback occurs when this message appears after connection:
A2DP CODEC SBC JOINT_STEREO 44100 BITPOOL 2-53
Bad chipmunk playback (issue #70) occurs when this message appears with the wrong sample rate:
A2DP CODEC SBC JOINT_STEREO 48000 BITPOOL 2-53
Silent playback (issue #67) occurs when NONE of those messages appear.
Also note:
AUDIO ROUTE 1 A2DP LEFT RIGHT
Interesting! Needs more research.
Note: The issue gets fixed if I hand-issue an "a2dp streaming start" command by hand much later. So somehwere this is fixable with a Streaming Start, just... not in the place where I put it originally.
Attached: Debug log output of the session.
Hm. Much like issue #70, this problem seems to occur when the Honda rings up the empeg, as opposed to the other way around. I see this interesting thing in the logs:
NO CARRIER 0 ERROR 9004 L2CAP_CONNECTION_REJ_RESOURCES NO CARRIER 0 ERROR 9004 L2CAP_CONNECTION_REJ_RESOURCES RING 1 48:f0:7b:57:15:20 19 A2DP --^ A2DP STREAMING START RING 0 48:f0:7b:57:15:20 17 AVRCP CONNECT 2 A2DP 19
So what I'm seeing here is that it rings the two channels out of order. It rings "1" first and then "0". It's possible that the problem occurs because I issue the streaming start command too soon, when only one of the A2DP channels is connected. Not sure.
To do: Investigate if there is a way to make the BlueGigaEmpeg to be "non discoverable" mode most of the time when it's trying to reconnect to things, for instance when it thinks it has a pairing buddy. Then depend entirely on the auto reconnect for the BGE to ring the host stereo, and not the other way around.
The trick is that we would want to put the BGE into discoverable mode for the sake of pairing. This might have to be done as part of the pairing process. Non-discoverable most of the time, then press pairing button to put into discoverable mode. But then what about the Honda that doesn't work in Inquriy mode? This might require looking at how to make the Honda work even when the BGE is in Inquriy mode. Hm. Maybe alternate chunks of inquiry mode, a few seconds on, a few seconds off, for example. See about that.
If we can fix this (make it so no one ever rings the BGE, it's always the other way around), then perhaps it will fix both this issue and also long-term root-cause fix issue #70.
Investigating possible ways to make the device either discoverable or non-discoverable on command.
The SET BT LAP command does interesting things, stuff that I'm experimenting with, but it does not solve this problem. I don't know how to keep a pre-paired device from ringing me first, other than to make sure that I'm the one that wins the race to do the calling.
I think the ultimate solution would be to find out how to prevent other folks from ringing us up (a previously paired host stereo doing a successful RING command against us). Then we would depend entirely on our autoReconnect to initiate the reconnect. However I can't figure out how to do this. The SET BT LAP command does not work for this. So continue to test workarounds for this.
To do:
Try to test your theory that this is caused by a them-rings-you-up problem by turning off auto reconnect temporarily. Force the other guy to ring you up and see if the repro frequency goes up.
Try to find a later spot in the code for issuing an A2DP STREAMING START command and see if that fixes the issue.
I got another repro on the debugger but it took a hella long time. I was using the disc/reco steps from the Honda front panel (trying to repro issue #70, using the most recent repro steps from that bug) and stumbled onto a repro. Issue #70 repros quite a bit more often than this one, this one is super extra rare.
Issuing an A2DP streaming start by hand didn't instantly fix it, but doing the A2dp streaming start a couple of times and then pressing some play pauses on the empeg front panel did get it working again.
Need to analyze the attached debug log in more detail.
To do:
Note: the repro is near the END of this log. Earlier in the log will be my attempts at reproing issue #70 and might in fact be some issue #70 repros in the log. You want to look towards the end to see the issue #67 repro.
Issue 67 Silent Playback - Another repro from disco-reco from Honda front panel.txt
You had a theory that it was caused by a too-early "streaming start".
Currently experimenting:
Tested the 2,3 instead of 1,2,3 fix so far on:
Still need to test on:
Okay, can't do the "2,3" fix because that induces bug #70 (chipmunk).
I have found that if I issue Streaming Start too early, i.e., if you issue it on "0" or the "1" while the A2DP channels are still getting set up, then you get silence. GUESS: one of the A2DP channels is a data channel and the other is audio. If this first of the two A2DP channels that connects is the data channel, and you issue the Streaming Start too soon before the second one is set up, then you get no audio because you didn't issue the Streaming Start command after there was an audio channel to start.
Whereas there is some weird thing with the Honda where issuing streaming start too late causes the chipmunk bug. So that's a separate issue.
Working on some custom code now to hopefully handle this permanently. Stay tuned.
Custom code which does intelligent triggering of the A2DP STREAMING START command only on the second A2DP message has been implemented in version 1.1.8, and is awaiting some more testing before final PR into Master branch.
I believe this is fixed with version 1.1.8 with commit aa4714e16631d2e00532451237b136d01a93c956. Closing for now, can reopen if the issue recurs.
Version 1.1.10, commit f2c327aff62d75fea7e1c0d55417f86586be0323, reverts the "streaming start" behavior back to pre-1.1.8 behavior, which is a "dumb" table that may occasionally induce this bug.
Re-opening this bug because it will still recur on rare occasions and I need to fully understand the correct timing with which to induce the Streaming Start command on all devices universally to avoid all possible issues.
Idea:
If the issue is caused when the RINGs come out of order like this:
RING 1 48:f0:7b:57:15:20 19 A2DP --^ A2DP STREAMING START RING 0 48:f0:7b:57:15:20 17 AVRCP CONNECT 2 A2DP 19
... Then maybe what I need to do is simply wait for the second and third ones regardless of their number and regardless of whether they're AVRCP or A2DP and just issue the streaming starts in those cases.
This would end up behaving as sort of a hybrid between the "dumb" method and the prior failed attempt at the "smart" method.
That might possibly fix this without inducing additional repros of issue #70.
No, I have a log of a second repro (above) where the RING commands came in in order and so I don't know the root cause of this one any more. Back to the drawing board.
Attempting to have a conversation with Silicon Labs support as to when exactly the correct time is to issue the command "A2DP STREAMING START" because it seems to be the crux of the issue here. Their documentation does not say. The conversation is not going well, I'm basically asking "When" and they're answering "yes". So we might be stuck on this one.
Another idea is to try issuing the command later on as well, adding back in additional streaming starts in other logical places in the code. I had had a few of those in the past but removed them for various reasons. Consider finding a good spot or two to put some back and see if they can make things work without hurting stuff.
Got a pretty good answer from tech support. Their answer was, essentially:
Though this is a good official answer, I am skeptical because I think this is what induced the 48k problem the most frequently. This is the behavior of the "intelligent" streaming start that I implemented earlier and my memory is telling me that this was the inducer of the 48k problem.
Need to do an experiment to be certain. But I think it's really like this in practice:
Issue streaming start after second and third RING or CONNECT (regardless of a2dp or avrcp):
RING 0 48:f0:7b:57:15:20 19 A2DP
RING 1 48:f0:7b:57:15:20 17 AVRCP
--^ A2DP STREAMING START
RING 2 48:f0:7b:57:15:20 19 A2DP
--^ A2DP STREAMING START
... This seems to be good and rarely if ever induces either issue #67 or issue #70. I think the only reason I ever got issue #67 is becase I was triggering off of "RING 1" or "RING 2" or somesuch, and if the messages came out of order with RING 1 coming first, then I wasn't issuing the command on the second ring receipt and it induced #67. Not sure.
This works well on some devices but I think that this might intermittently induce the 48k problem on the Honda stereo:
RING 0 48:f0:7b:57:15:20 19 A2DP
RING 1 48:f0:7b:57:15:20 17 AVRCP
RING 2 48:f0:7b:57:15:20 19 A2DP
--^ A2DP STREAMING START
To do:
I anticipate that this will be permanently fixed in the long term by the new streaming start behavior in 1.1.13. This is on a side branch at the moment but will be checked in when it's had more bake time on my test systems.
This was extremely rare to begin with and I haven't had a repro since 1.1.13. Can close as soon as you merge 1.1.13 to master.
On extremely rare occasions, I encounter silent playback after a cold boot up on starting the car.
Note: This might be related to issue #70 - Perhaps it is the same root cause with a slightly different manifestation.
Avrcp works fully (track change commands, track titles, etc.), and everything is connected, but there is no audio coming out of the Honda stereo despite the fact that the empeg is playing songs and its volume is turned up.
I vaguely remember a situation once before where this happened when I was on the debug cable, and I think that, at the time, it did not help to issue a "streaming start" command to the Bluetooth chip at that time. Though I feel like I need to double check this. Will need to repro this with debug connected.
In the meantime, a power cycle of the Bluetooth will definitely fix it (long press on top button puts empeg to sleep which removes power from the Bluetooth chip which forces a reboot).
To try, if it repros: