You are not logged in.

#1 2020-01-12 17:11:24

T-bond
Member
Registered: 2020-01-12
Posts: 4
Website

Bluetooth delay with specific HTS

Hello!

I am a happy owner of an Arch installation. (Reinstalled after a year, as I sometimes want to be 'clean')
System is up to date.
I have two Home Theatre System, which supports Bluetooth playback.

One is a Samsung one, and the another one is a Sony system.

I have been using the Samsung one for a few years, with Debian, and for a year with Arch without any issues.
Recently I got the Sony system, and it has a delay of ~1-1.5 seconds.
It makes watching videos a very unpleasant experience. Also very frustrating when you get notification sound after you have read the notification, and you just start to search the new one. big_smile
It happens with YouTube and YouTube Music from Firefox, and from VLC too.
It seems like some kind of buffer, because it starts late, and stops late after start/stop of the media.
As I said it is not happening with the Samsung one.

I also tested it with an Android phone. (Playing Audio from the phone to the Sony) This issue does not occur there. That's why I think it maybe some configuration difference.

I think the pacmd list-sinks command's output can be relevant:
Samsung:

  * index: 4
        name: <bluez_sink.SAMSUNG_MAC.a2dp_sink>
        driver: <module-bluez5-device.c>
        flags: HARDWARE DECIBEL_VOLUME LATENCY 
        state: RUNNING
        suspend cause: (none)
        priority: 9050
        volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 57.79 ms
        max request: 3 KiB
        max rewind: 0 KiB
        monitor source: 5
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 1
        linked by: 2
        fixed latency: 45.32 ms
        card: 4 <bluez_card.SAMSUNG_MAC>
        module: 28
        properties:
                bluetooth.protocol = "a2dp_sink"
                device.description = "[HTS]J4500"
                device.string = "SAMSUNG_MAC"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_SAMSUNG_MAC"
                bluez.class = "0x240404"
                bluez.alias = "[HTS]J4500"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
        ports:
                headset-output: Headset (priority 0, latency offset 0 usec, available: yes)
                        properties:

        active port: <headset-output>

Sony:

* index: 2
        name: <bluez_sink.SONY_MAC.a2dp_sink>
        driver: <module-bluez5-device.c>
        flags: HARDWARE DECIBEL_VOLUME LATENCY 
        state: RUNNING
        suspend cause: (none)
        priority: 9550
        volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
                balance 0.00
        base volume: 65536 / 100% / 0.00 dB
        volume steps: 65537
        muted: no
        current latency: 66.09 ms
        max request: 4 KiB
        max rewind: 0 KiB
        monitor source: 3
        sample spec: s16le 2ch 44100Hz
        channel map: front-left,front-right
                     Stereo
        used by: 1
        linked by: 1
        fixed latency: 48.22 ms
        card: 2 <bluez_card.SONY_MAC>
        module: 27
        properties:
                bluetooth.protocol = "a2dp_sink"
                device.description = "BLU-RAY HOME THEATRE SYSTEM"
                device.string = "SONY_MAC"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "speaker"
                bluez.path = "/org/bluez/hci0/dev_SONY_MAC"
                bluez.class = "0x240414"
                bluez.alias = "BLU-RAY HOME THEATRE SYSTEM"
                device.icon_name = "audio-speakers-bluetooth"
        ports:
                speaker-output: Speaker (priority 0, latency offset 0 usec, available: yes)
                        properties:

        active port: <speaker-output>

Maybe someone with more practice can see that I tried to change the bluez.class of the Sony device, to the Samsung one's hoping it will solve my problem. I thought that maybe the ,,speaker" devices are handled differently than ,,headset" devices.
As you can see I was not able to perfectly change any of the another properties of the device only the major and minor part of the bluez.class.
It seems like both using a2dp sinks so I assume that is correct, as I only found on my research questions and posts trying to switch to it.

  • I read what I can found on the Arch Wiki about Bluetooth, or Bluetooth a2dp

  • I have made my research on the World Wide Web, but found nothing which can move me closer to the solution

  • I used the search on the Arch Forum, without any result

  • I agree that I am a human, and maybe I just missed something, or I did not interpret everything, as I should have done.

I hope everything is clear about what I wrote. If not don't fear to ask (especially I am asking for your help, and will try my best to provide the asked details). And sorry if my English is not perfect. Greetings from Hungary.

Oh, and before I let you go my question:
Do you know an article / a solution on how to eliminate the audio delay with this specific system?

I will listen for comments with a 1~1.5s delay as my notifications arrive. big_smile big_smile

Offline

#2 2020-01-12 18:28:35

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 8,394

Re: Bluetooth delay with specific HTS

Welcome to the boards, nice first post, shows your thoughts and research and useful outputs

What's important here is

        current latency: 66.09 ms

so from pulse's perspective it "sends off" audio in a 66ms interval which is within realms of normality. So just from this I'd say it looks like everything's working properly. Do you get any messages in dmesg/journal that could link to some form of a connection problem or so?

A bit of an ugly workaround could be forcing a specific latency offset so that it should be logically synchronized again

pactl set-port-latency-offset bluez_sink.SONY_MAC.a2dp_sink speaker-output +1000 #in ms, not entirely sure whether it needs to be positive or negative in your case

Offline

#3 2020-01-12 21:08:55

T-bond
Member
Registered: 2020-01-12
Posts: 4
Website

Re: Bluetooth delay with specific HTS

V1del wrote:

Welcome to the boards, nice first post, shows your thoughts and research and useful outputs

Thank you very much. smile

V1del wrote:

so from pulse's perspective it "sends off" audio in a 66ms interval which is within realms of normality.

Yes, I think the same. The Samsung has a very similar offset.


V1del wrote:

Do you get any messages in dmesg/journal that could link to some form of a connection problem or so?

I checked both, now, and before creating the post, and did not find anything. Only messages about the successful connection to the device in dmesg.

Also for the set-port-latency-offset:
I tried it with positive and with negative values.
Even tried higher/lower numbers like: 10000 and -10000
Unfortunately, none of them made any difference. (I assume it is like the subtitle offset when watching movies, or the SPDIF offset for the audio and video synchronization. So it would be perfect, if it would do that. sad )

  • I tried changing the values while playing music.

  • Tried change the value, disconnect, reconnect the device and test.

  • Change the value, and disable the Bluetooth adapter, and reconnect.

I can not see/hear any difference, not even a crack or jump when changed while playing.
I assume it should do it live as I tried other commands like suspending the sink, and it works.

Note: I tested the same offset settings with the Samsung device, it doesn't effect the audio either.

Also found that I can play samples directly with pactl, so I grabbed a test MP3, Audacity, chopped of the silent part from the start, and uploaded to the sample storage. The problem is the same. When playing the sample through my laptop speakers it is starts as soon as the command executes, but when I play through the Bluetooth device, the delay is clearly there.

I have one theory: what if, the Sony creates this buffer, based on some connection parameter from the computer. (Like these Bluetooth classes)
It is just an idea, I have no clue. I am trying to think logically, about what can cause this difference, so I can then change that part, to figure it out.

So, thanks for the tip, but unfortunately, it does not work. sad

Offline

#4 2020-01-12 21:55:22

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 8,394

Re: Bluetooth delay with specific HTS

Yes it could be a specific quirk of the speakers themselves in which any changing on the OS side won't help much. It might also be an issue of the used bluetooth codec, which sadly most vendors don't have much documentation on, so you could try and set up https://aur.archlinux.org/packages/puls … les-bt-git which is a fork adding more bluetooth audio codecs to the existing pulse support.

Offline

#5 2020-01-12 22:36:29

T-bond
Member
Registered: 2020-01-12
Posts: 4
Website

Re: Bluetooth delay with specific HTS

Thank you.

I will try it, as I checked and it says it has AAC support. Maybe that won't have the delay.

For future readers, on how to check your device: https://github.com/EHfive/pulseaudio-mo … /issues/31
Mine output is:

Connecting ... 
Stream End-Point #1: Audio Sink 
        Media Codec: SBC
                Channel Modes: Mono DualChannel Stereo JointStereo
                Frequencies: 16Khz 32Khz 44.1Khz 48Khz 
                Subbands: 4 8
                Blocks: 4 8 12 16 
                Bitpool Range: 2-64
        Content Protection: SCMS-T
Stream End-Point #2: Audio Sink 
        Media Codec: MPEG24
                Object Types: MPEG-2 AAC LC MPEG-4 AAC LC MPEG-4 AAC LTP MPEG-4 AAC scalable 
                Frequencies: 8kHz 11.025kHz 12kHz 22.05kHz 24kHz 32kHz 44.1kHz 
                Channels: 2 
                Bitrate: 238
                VBR: Yes
        Content Protection: SCMS-T

I will definitely report back with my results, when I got time for the tests.
Thanks for showing me this AUR package.

Offline

#6 2020-01-19 21:06:31

T-bond
Member
Registered: 2020-01-12
Posts: 4
Website

Re: Bluetooth delay with specific HTS

So, I got time to try out the AUR package, but it made no differences.

I checked with the following command:

pactl list sinks | grep -e bluez -e a2dp_codec

That it is using the available AAC codec. And it said bluetooth.a2dp_codec = "AAC"
So I assume it is using it.
I tried to play around with the module arguments, but it made no change.
Tried all the aac_bitrate_mode and aac_afterburner  options.

I have no idea where to continue from here. hmm

Offline

Board footer

Powered by FluxBB