Possible A2DP skipping solution!

Search This thread

crushsuitandtie

Senior Member
Apr 21, 2009
54
6
Headset: Motorola S9-HD
ROM: Haykuro 6.0
Radio: ota-radio-2_22_19_26I

Issue: a2dp audio skips due to location of phone... or so it seemed. The audio would skip if the phone was placed across my body from the antenna or in a pocket.

Resolution: I began researching the bluez stack and found several places in the code that alluded to the hfp and a2dp being intertwined. This lead me to remember that android also attempts to switch between the hfp and a2dp for incoming calls.

I found that my headset was connected by default with both profiles active (not one at a time).

Thus after several test i found that disabling the hfp will eliminate the skipping.

Explanation: My best analysis is that the phone is keeping both profiles open at the expense of splitting the channel. Thus when the phone has gsm related events (incoming calls, tower hopping, background edge data) it is tying up the hfp by error thus causing a2dp to get reduced resources, low signal strength, and possibly packet collisions. Try for yourself. The skipping instantly stopped for me. Let me know how it goes for you! Thanks to all the devs for these great roms and info.
 
Last edited:

alapapa

Senior Member
Dec 18, 2007
456
8
interesting, plausible explanation

where in the code do you make the change?
 

crushsuitandtie

Senior Member
Apr 21, 2009
54
6
noob translation: turning off the headphone profile possibly frees up room for audio to stream uninterrupted...

ps. that might still confuse some... lol
 

crushsuitandtie

Senior Member
Apr 21, 2009
54
6
interesting, plausible explanation

where in the code do you make the change?

no changes were made yet... the bluez stack is written to have a bridge between a2dp and headphone profile. i think android is sending packets to the headset via hfp for gsm events. I would think android should discard the packets instead of sending them out and relying on the headset to ignore them.

i would think the code can't be changed without making LOTS of other changes... i would be essentially rewriting how android handles the two profiles at the same time. (ALOT of work)

if this ends up fixing it for everyone... then i might look into trying to increase a2dp's priority in transmitting or some other solutions...
 
Last edited:

alapapa

Senior Member
Dec 18, 2007
456
8
no changes were made yet... the bluez stack is written to have a bridge between a2dp and headphone profile. i think android is sending packets to the headset via hfp for gsm events. I would think android should discard the packets instead of sending them out and relying on the headset to ignore them.

i would think the code can't be changed without making LOTS of other changes... i would be essentially rewriting how android handles the two profiles at the same time. (ALOT of work)

if this ends up fixing it for everyone... then i might look into trying to increase a2dp's priority in transmitting or some other solutions...

i think I gotcha...you just killed the hfp profile on your PC or w/e...?
 

crushsuitandtie

Senior Member
Apr 21, 2009
54
6
Menu button>Settings>Wireless Controls>Bluetooth Settings>(long press) Your headset name>Options...>uncheck phone....
 

crazythunder

Senior Member
Apr 2, 2007
855
83
55
buffalo,ny
thanks for that tip. i was cutting my grass the other day. g1 in rear pocket. stereo bluetooth headphones on. signal kept cutting out on me. i'm gonna try this and see if it helps.
 

DOHCtor

Senior Member
Apr 10, 2009
1,109
121
Southern California
Hey you're right! I just connected my S9 to "media" only (disabling the phone connection in bluetooth settings) and it doesn't skip anymore, even with wifi on! I'm going to give this a try on my sony head unit in my car when I get the chance and I'll report back.
 

crushsuitandtie

Senior Member
Apr 21, 2009
54
6
Hey you're right! I just connected my S9 to "media" only (disabling the phone connection in bluetooth settings) and it doesn't skip anymore, even with wifi on! I'm going to give this a try on my sony head unit in my car when I get the chance and I'll report back.

Glad to hear that! im back at work and its heavily laced with wifi and the building gets poor edge/3G signal.So if you walk out the entrance toward the parking lot, the phone would connect to the cell towers (plus the wifi antennas are strong here) and my headphones would skip almost non-stop. This no longer happens. I'm quite happy.
 

atoy74

Senior Member
Oct 22, 2007
495
57
Interresting hypothesis. I have my phone relatively close to my headphones so it hasnt been a big problem. Wifi had to be off or it didnt matter how close.

Eventhough it defeats the purpose of my S9's I'm going to give it a try.
 

crushsuitandtie

Senior Member
Apr 21, 2009
54
6
Interresting hypothesis. I have my phone relatively close to my headphones so it hasnt been a big problem. Wifi had to be off or it didnt matter how close.

Eventhough it defeats the purpose of my S9's I'm going to give it a try.

i kept wi-fi off because I was in the gym or walking to my car... it would skip an absurd amount and i would nearly throw my phone and headset 8 blocks from pure frustration. The crazy part is BT is easily strong enough to transmit from a pocket to a headset on my head. I like to think i am tall but not that tall and disproportionate that my pocket is over 30 feet from my head! lol.

any skipping from that short of a distance is actually indicative of a problem to me. Thats like putting on a normal earpiece and getting nothing but static from that distance.

1) tests with my Sony Ericcson K850i showed it wasn't the headset....
2) i sat the phone on the floor directly under me when i was benchpressing, and simply because i layed down and partially covered the back of the headset the music started skipping non-stop. covering the antenna can cause some interferance but honestly with the phone that close it really shouldnt matter...

Tried the same test with my K850... no skipping. Tried with hfp disabled.... no skipping. Turn on hfp and a2dp... skips heavily.

thats the short version of how i came up with the split bandwidth part of my theory.
 

paesano

Member
Jul 7, 2006
18
0
Highland, UT
no changes were made yet... the bluez stack is written to have a bridge between a2dp and headphone profile. i think android is sending packets to the headset via hfp for gsm events. I would think android should discard the packets instead of sending them out and relying on the headset to ignore them.

i would think the code can't be changed without making LOTS of other changes... i would be essentially rewriting how android handles the two profiles at the same time. (ALOT of work)

if this ends up fixing it for everyone... then i might look into trying to increase a2dp's priority in transmitting or some other solutions...

The handsfree profile will periodically send out "indicators" for things such as battery status and signal strength. These are small packets, which in a well designed Bluetooth stack, should not cause any disruption in the A2DP stream. The thing to look for would be how data transmission is prioritized. If, for example, BlueZ simply sends data in a "round robin" style, then sending a small data packet may delay the transmission of an A2DP streaming packet just enough to cause the problems you are describing.

I'm using JF1.51 and am not experiencing any of the audio problems you describe, even with WiFi and Handsfree connections enabled. I ran some tests and used a Bluetooth sniffer to capture the data traffic. One time I did hear an audio dropout at about the same time that the phone sent a signal strength indicator, which doesn't exactly validate your theory, but does make me wonder. However, I only saw 5 indicators sent by the phone over a 30 minute session.
 

webgrafix

Senior Member
Sep 30, 2006
168
10
Jacksonville, FL
Does using this method affect you from using the headset for calls?

Am I understanding that you would use this to listen to music... and if a call comes in would would talk over the handset normal?
 

atoy74

Senior Member
Oct 22, 2007
495
57
What I've found is using A2DP indoors works perfectly (with our without HFP.) The explanation I've read is that the 2.4GHz waves bounce off the walls enhancing reception. Once outside is when I see degradation of quality/drops which would support the theory.

You might be on to something. If the bandwidth is being cut to share data over two profiles then, once you step outside, you'll have less distance before data packets drop.
 

crushsuitandtie

Senior Member
Apr 21, 2009
54
6
I'm using JF1.51 and am not experiencing any of the audio problems you describe, even with WiFi and Handsfree connections enabled. I ran some tests and used a Bluetooth sniffer to capture the data traffic. One time I did hear an audio dropout at about the same time that the phone sent a signal strength indicator, which doesn't exactly validate your theory, but does make me wonder. However, I only saw 5 indicators sent by the phone over a 30 minute session.

you might have misread one of my posts... what you descrribed is exactly what i was saying... gsm events are possibly clogging bandwidth for a2dp. the one time you heard it is what i am experiencing constantly in some areas.

it appears to be a combination of several factors that are somehow hitting some people all at once....

1)"gsm or phone events being broadcasted"
2) possible split BT channel for HFP and A2dp
3) weak overall BT signal strength from g1 (dialed down in drivers to save power?)
4) interference from other wifi sources (enterprise access points aka "High gain antennas")

P.S. I guess its obvious i'm a systems analyst... lol
 

dan0zone

Senior Member
Mar 4, 2007
429
20
LYNN
if you guys remember windows mobile , the BT stack by default is set with the bit pool min and max @ 31 ,it works great but the sound quality sucks.. if you use a registry editor and increase the max bit pool sound quality gets better, but if you go to high you would get the cliping that we now get . i used to do this with my wing , using this same S9 headphone ,the trick was not to go to high with max bitpool and to lower min to 12 and this worked great,, max was @ 46 min was @ 12 ,, no skipping at all.. and great sound . WE need to find a way to get these adjusted on android , this should fix
now i do believe the wing and G1 both use Broadcom stacks ,could be wrong>>
remember Schap's tools - Advanced Configuration this did the trick
 
Last edited:

paesano

Member
Jul 7, 2006
18
0
Highland, UT
you might have misread one of my posts... what you descrribed is exactly what i was saying... gsm events are possibly clogging bandwidth for a2dp. the one time you heard it is what i am experiencing constantly in some areas.

it appears to be a combination of several factors that are somehow hitting some people all at once....

1)"gsm or phone events being broadcasted"
2) possible split BT channel for HFP and A2dp
3) weak overall BT signal strength from g1 (dialed down in drivers to save power?)
4) interference from other wifi sources (enterprise access points aka "High gain antennas")

P.S. I guess its obvious i'm a systems analyst... lol

Sorry, I must not have been very clear. I did understand what you were saying, and I confirmed seeing what you saw in the one dropout I heard. However, in my case, there were only 5 "GSM Events" during the duration of my test. Not really enough to cause a lot of trouble. I can see that if a lot of GSM events occur (The spec calls them indicators), then there could be a lot of errors. Perhaps this happens when the GSM signal is weak and constantly changing.

If you want to look at making changes to the Bluetooth software, here's my analysis of the 4 points above:

1) If a lot of indicators are being sent by the G1, then I can see that a Bluetooth stack implementation could have streaming audio problems if not properly implemented. Unfortunately, the only way to fix this problem is in software by only sending indicators (and any other data) "in between" the A2DP streaming packets. Streaming packets should never get delayed. It would be better to toss the streaming packet than to delay it.

2) When both HF and A2DP are connected, the signal is not actually split. They both have access to the full bandwidth of the Bluetooth stack. The only time that there would be a problem is when both are sending at the same time, which could cause an audio packet to get delayed in a transmit queue, causing a dropout (as described above). Perhaps BlueZ doesn't do a very good job of prioritizing data, so that audio data is never delayed by other data packets. In my opinion, #1 and #2 are the same problem.

3) A week BT signal would definitely cause this. I can reliably listen to stereo audio with my Sony headset at around 10-15 ft. Outside that range, I start to hear dropouts. Also, If I put my hands over the headset, I can cause dropouts at even 2 ft. So, your body will definitely cause problems if it gets in the way of the signal. Finally, the sensitivity of the radio on the headset will affect the range as well. It may or may not be possible to increase the TX power by sending the Bluetooth controller a command in the software. The only other solution is to try and not get in the way. :)

4) WiFi certainly can cause interference, as can a microwave oven. However, adaptive frequency hopping (AFH) should mitigate most problems. Perhaps AFH is not turned on for some reason, or there are multiple WiFi networks around, making it very difficult for the Bluetooth controller to find any reliable frequencies. AFH is turned on by sending the Bluetooth controller the command.