Get rid of 0.5s latency when playing audio over Bluetooth with A2DP












45















As described in the title I experience a half a second delay when playing audio over Bluetooth with A2DP.

This makes watching movies not possible as the sound is not synchronised with the video.



I'm not sure if the delay is caused by the Bluetooth standard, the A2PD protocol, the A2DP implementation on Ubuntu 12.04, or the Belkin Z73 Bluetooth Receiver.



Anyways, is this a normal lag? Is there a way to play audio over Bluetooth without any noticeable latency?










share|improve this question




















  • 8





    Not a real solution to your problem but a workaround: If it's only about playing movies, you can adjust the audio/video offset, which will delay the video too. Using mplayer, you do so by pressing the + and - keys. In VLC, I don't know how to set the delay, but I'd be surprised if VLC doesn't have such an option.

    – leemes
    Jun 3 '12 at 14:29











  • I thought about that but I'm missing a solution for YouTube. When the video is played with HTML5 a solution could be to install a browser extension that sets a video offset. But for the case the video is played with flash I'm not sure how to achieve that.

    – brillout
    Jun 3 '12 at 14:33











  • Incidentally, the VLC option is at Tools->Track Synchronisation, or play with the --audio-desync option. I'm afraid I'm not sure what the units are, and which direction is positive, and the help is not forthcoming on the matter, but that's where you want to look.

    – Darael
    Jul 31 '12 at 19:32











  • Relevant Q I asked: How to debug lag using Bluetooth connected mouse and A2DP headset?

    – gertvdijk
    Jan 5 '13 at 15:48











  • Have you found a permanent solution to this problem? I am currently using the solution to switch between the A2DP / HSP / A2DP, but it's not practical to stay doing that every time the sync problem.

    – Fred Wuerges
    Jul 18 '16 at 22:54
















45















As described in the title I experience a half a second delay when playing audio over Bluetooth with A2DP.

This makes watching movies not possible as the sound is not synchronised with the video.



I'm not sure if the delay is caused by the Bluetooth standard, the A2PD protocol, the A2DP implementation on Ubuntu 12.04, or the Belkin Z73 Bluetooth Receiver.



Anyways, is this a normal lag? Is there a way to play audio over Bluetooth without any noticeable latency?










share|improve this question




















  • 8





    Not a real solution to your problem but a workaround: If it's only about playing movies, you can adjust the audio/video offset, which will delay the video too. Using mplayer, you do so by pressing the + and - keys. In VLC, I don't know how to set the delay, but I'd be surprised if VLC doesn't have such an option.

    – leemes
    Jun 3 '12 at 14:29











  • I thought about that but I'm missing a solution for YouTube. When the video is played with HTML5 a solution could be to install a browser extension that sets a video offset. But for the case the video is played with flash I'm not sure how to achieve that.

    – brillout
    Jun 3 '12 at 14:33











  • Incidentally, the VLC option is at Tools->Track Synchronisation, or play with the --audio-desync option. I'm afraid I'm not sure what the units are, and which direction is positive, and the help is not forthcoming on the matter, but that's where you want to look.

    – Darael
    Jul 31 '12 at 19:32











  • Relevant Q I asked: How to debug lag using Bluetooth connected mouse and A2DP headset?

    – gertvdijk
    Jan 5 '13 at 15:48











  • Have you found a permanent solution to this problem? I am currently using the solution to switch between the A2DP / HSP / A2DP, but it's not practical to stay doing that every time the sync problem.

    – Fred Wuerges
    Jul 18 '16 at 22:54














45












45








45


27






As described in the title I experience a half a second delay when playing audio over Bluetooth with A2DP.

This makes watching movies not possible as the sound is not synchronised with the video.



I'm not sure if the delay is caused by the Bluetooth standard, the A2PD protocol, the A2DP implementation on Ubuntu 12.04, or the Belkin Z73 Bluetooth Receiver.



Anyways, is this a normal lag? Is there a way to play audio over Bluetooth without any noticeable latency?










share|improve this question
















As described in the title I experience a half a second delay when playing audio over Bluetooth with A2DP.

This makes watching movies not possible as the sound is not synchronised with the video.



I'm not sure if the delay is caused by the Bluetooth standard, the A2PD protocol, the A2DP implementation on Ubuntu 12.04, or the Belkin Z73 Bluetooth Receiver.



Anyways, is this a normal lag? Is there a way to play audio over Bluetooth without any noticeable latency?







pulseaudio bluetooth






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 24 '14 at 22:41









Braiam

51.8k20136221




51.8k20136221










asked Jun 3 '12 at 14:26









brilloutbrillout

53031020




53031020








  • 8





    Not a real solution to your problem but a workaround: If it's only about playing movies, you can adjust the audio/video offset, which will delay the video too. Using mplayer, you do so by pressing the + and - keys. In VLC, I don't know how to set the delay, but I'd be surprised if VLC doesn't have such an option.

    – leemes
    Jun 3 '12 at 14:29











  • I thought about that but I'm missing a solution for YouTube. When the video is played with HTML5 a solution could be to install a browser extension that sets a video offset. But for the case the video is played with flash I'm not sure how to achieve that.

    – brillout
    Jun 3 '12 at 14:33











  • Incidentally, the VLC option is at Tools->Track Synchronisation, or play with the --audio-desync option. I'm afraid I'm not sure what the units are, and which direction is positive, and the help is not forthcoming on the matter, but that's where you want to look.

    – Darael
    Jul 31 '12 at 19:32











  • Relevant Q I asked: How to debug lag using Bluetooth connected mouse and A2DP headset?

    – gertvdijk
    Jan 5 '13 at 15:48











  • Have you found a permanent solution to this problem? I am currently using the solution to switch between the A2DP / HSP / A2DP, but it's not practical to stay doing that every time the sync problem.

    – Fred Wuerges
    Jul 18 '16 at 22:54














  • 8





    Not a real solution to your problem but a workaround: If it's only about playing movies, you can adjust the audio/video offset, which will delay the video too. Using mplayer, you do so by pressing the + and - keys. In VLC, I don't know how to set the delay, but I'd be surprised if VLC doesn't have such an option.

    – leemes
    Jun 3 '12 at 14:29











  • I thought about that but I'm missing a solution for YouTube. When the video is played with HTML5 a solution could be to install a browser extension that sets a video offset. But for the case the video is played with flash I'm not sure how to achieve that.

    – brillout
    Jun 3 '12 at 14:33











  • Incidentally, the VLC option is at Tools->Track Synchronisation, or play with the --audio-desync option. I'm afraid I'm not sure what the units are, and which direction is positive, and the help is not forthcoming on the matter, but that's where you want to look.

    – Darael
    Jul 31 '12 at 19:32











  • Relevant Q I asked: How to debug lag using Bluetooth connected mouse and A2DP headset?

    – gertvdijk
    Jan 5 '13 at 15:48











  • Have you found a permanent solution to this problem? I am currently using the solution to switch between the A2DP / HSP / A2DP, but it's not practical to stay doing that every time the sync problem.

    – Fred Wuerges
    Jul 18 '16 at 22:54








8




8





Not a real solution to your problem but a workaround: If it's only about playing movies, you can adjust the audio/video offset, which will delay the video too. Using mplayer, you do so by pressing the + and - keys. In VLC, I don't know how to set the delay, but I'd be surprised if VLC doesn't have such an option.

– leemes
Jun 3 '12 at 14:29





Not a real solution to your problem but a workaround: If it's only about playing movies, you can adjust the audio/video offset, which will delay the video too. Using mplayer, you do so by pressing the + and - keys. In VLC, I don't know how to set the delay, but I'd be surprised if VLC doesn't have such an option.

– leemes
Jun 3 '12 at 14:29













I thought about that but I'm missing a solution for YouTube. When the video is played with HTML5 a solution could be to install a browser extension that sets a video offset. But for the case the video is played with flash I'm not sure how to achieve that.

– brillout
Jun 3 '12 at 14:33





I thought about that but I'm missing a solution for YouTube. When the video is played with HTML5 a solution could be to install a browser extension that sets a video offset. But for the case the video is played with flash I'm not sure how to achieve that.

– brillout
Jun 3 '12 at 14:33













Incidentally, the VLC option is at Tools->Track Synchronisation, or play with the --audio-desync option. I'm afraid I'm not sure what the units are, and which direction is positive, and the help is not forthcoming on the matter, but that's where you want to look.

– Darael
Jul 31 '12 at 19:32





Incidentally, the VLC option is at Tools->Track Synchronisation, or play with the --audio-desync option. I'm afraid I'm not sure what the units are, and which direction is positive, and the help is not forthcoming on the matter, but that's where you want to look.

– Darael
Jul 31 '12 at 19:32













Relevant Q I asked: How to debug lag using Bluetooth connected mouse and A2DP headset?

– gertvdijk
Jan 5 '13 at 15:48





Relevant Q I asked: How to debug lag using Bluetooth connected mouse and A2DP headset?

– gertvdijk
Jan 5 '13 at 15:48













Have you found a permanent solution to this problem? I am currently using the solution to switch between the A2DP / HSP / A2DP, but it's not practical to stay doing that every time the sync problem.

– Fred Wuerges
Jul 18 '16 at 22:54





Have you found a permanent solution to this problem? I am currently using the solution to switch between the A2DP / HSP / A2DP, but it's not practical to stay doing that every time the sync problem.

– Fred Wuerges
Jul 18 '16 at 22:54










10 Answers
10






active

oldest

votes


















34





+100









No, this is not normal but I've had a similar problem occasionally with my Altec Lansing iMT525 Bluetooth Speakers. Something similar in concept to Sri's answer almost always works for me, and I need to do it only once per connect.



Auto-switching Bluetooth profiles to re-initialize PulseAudio



If you're looking for a culprit, I'd look at Ubuntu's sound system, PulseAudio first, and then your bluetooth receiver. Try this:




  • First, delete and re-pair your Bluetooth device.



  • Then, copy and paste the below into a .sh file in your home directory, say /home/brillout/pabluezswitch.sh:




    #!/bin/bash

    BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
    pactl set-card-profile $BLUEZCARD a2dp
    pactl set-card-profile $BLUEZCARD hsp
    pactl set-card-profile $BLUEZCARD a2dp


  • Make the file executable by opening a terminal and typing chmod +x ~/pabluezswitch.sh


  • Go to Settings...Keyboard...Shortcuts, and create a custom shortcut; name it whatever you want, with the command as /home/brillout/pabluezswitch.sh (substitute appropriate username in path!). Click Apply, and then click on the right where it says Disabled to set up a keyboard shortcut to execute the script.



What this does is force the PulseAudio system to resynchronize the audio being sent to your headset/speakers by switching profiles from ad2p -> hsp -> a2dp, thus hopefully getting rid of any latency.





Whenever you connect and notice the lag, you should press the keyboard shortcut chosen above to attempt to fix the latency -- hopefully it works for you!






share|improve this answer
























  • I've been using this for a couple days now, and it works great. -- 14.04

    – dpb
    Oct 29 '14 at 14:37











  • Great answer and perfectly convenient too! Great job!

    – Zzzach...
    Dec 14 '14 at 21:30






  • 7





    Note that pactl has terrible error messages, and that many audio equipment don't have these ad2p and hsp. My Bose only has ad2p_sink, not these other two.

    – odinho - Velmont
    Jun 12 '16 at 10:10






  • 1





    I think you need quotes around that egrep pattern

    – naught101
    Aug 4 '16 at 5:33






  • 2





    @odinho-Velmont toggling between ad2p_sink and off works for me. I've recently aded this to my Pulse audio/volume control script that might be helpful to somebody

    – Sam Mason
    Mar 31 '17 at 16:37



















16














In pavucontrol I go to the output device tab, then choose the advanced option below the bluetooth device. There you can set the latency offset to 600ms. Problem solved.






share|improve this answer





















  • 2





    Removed unnecessary sass from answer - no need to be rude. Also, this sounds like it should work, but it doesn't seem to actually do anything for me...

    – naught101
    Aug 16 '16 at 1:31













  • For me this worked for youtube playback with bluetooth speakers. Thanks. When I first opened pavucontrol the advanced option was hidden. Had to vertically expand the window.

    – user75505
    Jan 15 '18 at 23:20



















9














I get similar problem occasionally, irrespective of the player used. Mine is a Nokia BH-503 Bluetooth Stereo Headphone with MSI CR400 laptop and Ubuntu 11.10. I happened to come across a workaround which you can try.




  • Start the video playback.

  • Go to Sound Settings > Hardware.

  • Select the Bluetooth device.

  • Then in Settings for the Selected Device drop-down, switch to Telephony Duplex (HSP/HFP) profile, then switch back to High Fidelity Playback (A2DP).






share|improve this answer































    7














    The top reply here works, but not for every bluetooth audio device. Some devices have different profile names than what that poster has with his bluetooth speakers. For instance, in the following code, which was originally posted by that person, it apparently has profiles named a2dp and hsp. Neither of these are available with my LG Tones, for example, but they are with other devices like my Sony headset.



    #!/bin/bash

    BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
    pactl set-card-profile $BLUEZCARD a2dp
    pactl set-card-profile $BLUEZCARD hsp
    pactl set-card-profile $BLUEZCARD a2dp


    That code will work for most bluetooth devices it appears, but to get this working correctly for those devices that don't have the a2dp profile or the hsp profile, type in:



    pactl list | grep -Pzo '.*bluez_card(.*n)*'


    This will return everything after where it finds a bluetooth device. For instance, with the LG Tone Ultra headset, I get this:



    Name: bluez_card.B8_AD_3E_**_**_**
    Driver: module-bluez5-device.c
    Owner Module: 36
    Properties:
    device.description = "LG HBS810"
    device.string = "B8:AD:3E:**:**:**"
    device.api = "bluez"
    device.class = "sound"
    device.bus = "bluetooth"
    device.form_factor = "headset"
    bluez.path = "/org/bluez/hci0/dev_B8_AD_3E_**_**_**"
    bluez.class = "0x240404"
    bluez.alias = "LG HBS810"
    device.icon_name = "audio-headset-bluetooth"
    device.intended_roles = "phone"
    Profiles:
    a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
    headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
    off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
    Active Profile: a2dp_sink
    Ports:
    headset-output: Headset (priority: 0, latency offset: 0 usec)
    Part of profile(s): a2dp_sink, headset_head_unit
    headset-input: Headset (priority: 0, latency offset: 0 usec)
    Part of profile(s): headset_head_unit


    We are interested in the profiles section. In this section, we see three profiles, which are a2dp_sink, headset_head_unit, and off. The two profiles we need should have in them (A2DP Sink) and (HSP/HFP). In this case, they are a2dp_sink for the a2dp profile, and headsethead_unit for the hsp profile. Notice this is different than the original poster's a2dp and hsp.



    Now, with the above code, we will modify it and put it into a file. I called the file bluezswitch.sh.



    Change to the directory you want to put the file. It can be anywhere.



    touch bluezswitch.sh


    Then



    nano bluezswitch.sh


    Copy and paste the code at the very top of this comment and replace the a2dp and hsp with the values you got when you ran the above command, and paste it in that file. For instance, this is what my file looked like for my LG Tones.



    #!/bin/bash

    BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
    pactl set-card-profile $BLUEZCARD a2dp_sink
    pactl set-card-profile $BLUEZCARD headset_head_unit
    pactl set-card-profile $BLUEZCARD a2dp_sink


    Now, ctrl-x then y to save the file and exit nano, and then make the file executable:



    chmod +x bluezswitch.sh


    Then follow up by setting a keyboard shortcut as has been explained.




    Go to Settings...Keyboard...Shortcuts, and create a
    custom shortcut; name it whatever you want, with the command as
    /home/brillout/bluezswitch.sh (substitute appropriate username in
    path!). Click Apply, and then click on the right where it says
    Disabled to set up a keyboard shortcut to execute the script.




    That should be all there is to it. This should work for all those that it didn't work for before.






    share|improve this answer





















    • 1





      For me, turning off a2dp_sink, off, a2dp_sink in sequence works very well for me. Setting to headset_head_unit I/O error.

      – Mohd Shahril
      Apr 8 '18 at 9:46



















    5














    Adaptive differential pulse code modulation involves a look-ahead type compressing algorithm where information cannot be transmitted before the encoder has had a chance to examine several bytes of forthcoming info. Hence, data has to stack up in the encoder, and there is an inherent time shift between the streams entering and leaving the encoder. Long ago, I did a study of data network delays to determine the feasibility of voice-over-data telephony (what is now VoIP). I think I concluded that ADPCM-style compression/encoding would introduce too much delay. I think to overcome this Bluetooth-delay problem, one might need a non-compressing type of audio encoding which should have lower latency.






    share|improve this answer



















    • 6





      The compression problem would account for a few tens of milliseconds, not half a second, surely?

      – naught101
      Aug 4 '16 at 5:36



















    4














    I tried a lot of approaches to this problem, but nothing could fix it. Then I stumbled upon set-port-latency-offset



    If you are using pulseaudio do :



    pactl list cards short | egrep -o bluez.*[[:space:]]


    This will give you the bluetooth interface.
    Now set the latency accordingly :



    pactl set-port-latency-offset <INTERFACE> speaker-output 100000


    I am using 100000 microseconds which works fine for me.






    share|improve this answer



















    • 1





      For anyone else stumbling across this old post searching for an answer, Arindam Mani Das's answer works perfectly. If you receive the "no such entity" error, run 'pactl list cards' and check which ports are available for your device. I had to change "speaker-output" to "headset-output" in the second command since my device does not have a speaker-output port.

      – Billy Farrington
      May 22 '18 at 0:46



















    1














    Here's what solved it for me: $ sudo apt-get install phonon-backend-vlc and make sure it's the preferred backend, in KDE go to [System Settings][Multimedia][Audio and video settings][Backend] and use the [Prefer button]






    share|improve this answer





















    • 1





      @dargaud I recommend expanding this to explain how to make it the preferred backend.

      – Eliah Kagan
      Jul 24 '14 at 22:33



















    0














    individuals who are having this problem Please view this website: http://projectzeorymer.wordpress.com/2011/09/01/ubuntu-how-to-connect-nokia-bh-503-bluetooth-headset-to-your-pc/ to see a pic of what you need to download.



    Download the bluetooth manager and use it to manipulate the settings of the headset. Set the sound settings to High Fidelity Playback (A2DP) and then go in sound settings.






    share|improve this answer





















    • 1





      Go on bluetooth manage and go to Audio Profile and then select High Fedelity Playback.. thats it

      – Alex Force
      Aug 18 '12 at 22:25



















    0














    On VLC media player, Go to
    Tools
    Track synchronization
    Synchronize tab
    Under audio/ video audio track synchronize, use a negative value like about -0.67 and the lag will be compensated for fully. You have to manually do this every time you open a new file. Chris






    share|improve this answer































      0














      Similarly to Timm's answer, I did not have the profiles of the accepted answer either. Setting the HSP gave an error code.



      I ended up using the following, almost identical, script.



      #!/bin/bash
      BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
      pactl set-card-profile $BLUEZCARD a2dp_sink
      pactl set-card-profile $BLUEZCARD off
      pactl set-card-profile $BLUEZCARD a2dp_sink





      share|improve this answer























        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "89"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f145935%2fget-rid-of-0-5s-latency-when-playing-audio-over-bluetooth-with-a2dp%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        10 Answers
        10






        active

        oldest

        votes








        10 Answers
        10






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        34





        +100









        No, this is not normal but I've had a similar problem occasionally with my Altec Lansing iMT525 Bluetooth Speakers. Something similar in concept to Sri's answer almost always works for me, and I need to do it only once per connect.



        Auto-switching Bluetooth profiles to re-initialize PulseAudio



        If you're looking for a culprit, I'd look at Ubuntu's sound system, PulseAudio first, and then your bluetooth receiver. Try this:




        • First, delete and re-pair your Bluetooth device.



        • Then, copy and paste the below into a .sh file in your home directory, say /home/brillout/pabluezswitch.sh:




          #!/bin/bash

          BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
          pactl set-card-profile $BLUEZCARD a2dp
          pactl set-card-profile $BLUEZCARD hsp
          pactl set-card-profile $BLUEZCARD a2dp


        • Make the file executable by opening a terminal and typing chmod +x ~/pabluezswitch.sh


        • Go to Settings...Keyboard...Shortcuts, and create a custom shortcut; name it whatever you want, with the command as /home/brillout/pabluezswitch.sh (substitute appropriate username in path!). Click Apply, and then click on the right where it says Disabled to set up a keyboard shortcut to execute the script.



        What this does is force the PulseAudio system to resynchronize the audio being sent to your headset/speakers by switching profiles from ad2p -> hsp -> a2dp, thus hopefully getting rid of any latency.





        Whenever you connect and notice the lag, you should press the keyboard shortcut chosen above to attempt to fix the latency -- hopefully it works for you!






        share|improve this answer
























        • I've been using this for a couple days now, and it works great. -- 14.04

          – dpb
          Oct 29 '14 at 14:37











        • Great answer and perfectly convenient too! Great job!

          – Zzzach...
          Dec 14 '14 at 21:30






        • 7





          Note that pactl has terrible error messages, and that many audio equipment don't have these ad2p and hsp. My Bose only has ad2p_sink, not these other two.

          – odinho - Velmont
          Jun 12 '16 at 10:10






        • 1





          I think you need quotes around that egrep pattern

          – naught101
          Aug 4 '16 at 5:33






        • 2





          @odinho-Velmont toggling between ad2p_sink and off works for me. I've recently aded this to my Pulse audio/volume control script that might be helpful to somebody

          – Sam Mason
          Mar 31 '17 at 16:37
















        34





        +100









        No, this is not normal but I've had a similar problem occasionally with my Altec Lansing iMT525 Bluetooth Speakers. Something similar in concept to Sri's answer almost always works for me, and I need to do it only once per connect.



        Auto-switching Bluetooth profiles to re-initialize PulseAudio



        If you're looking for a culprit, I'd look at Ubuntu's sound system, PulseAudio first, and then your bluetooth receiver. Try this:




        • First, delete and re-pair your Bluetooth device.



        • Then, copy and paste the below into a .sh file in your home directory, say /home/brillout/pabluezswitch.sh:




          #!/bin/bash

          BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
          pactl set-card-profile $BLUEZCARD a2dp
          pactl set-card-profile $BLUEZCARD hsp
          pactl set-card-profile $BLUEZCARD a2dp


        • Make the file executable by opening a terminal and typing chmod +x ~/pabluezswitch.sh


        • Go to Settings...Keyboard...Shortcuts, and create a custom shortcut; name it whatever you want, with the command as /home/brillout/pabluezswitch.sh (substitute appropriate username in path!). Click Apply, and then click on the right where it says Disabled to set up a keyboard shortcut to execute the script.



        What this does is force the PulseAudio system to resynchronize the audio being sent to your headset/speakers by switching profiles from ad2p -> hsp -> a2dp, thus hopefully getting rid of any latency.





        Whenever you connect and notice the lag, you should press the keyboard shortcut chosen above to attempt to fix the latency -- hopefully it works for you!






        share|improve this answer
























        • I've been using this for a couple days now, and it works great. -- 14.04

          – dpb
          Oct 29 '14 at 14:37











        • Great answer and perfectly convenient too! Great job!

          – Zzzach...
          Dec 14 '14 at 21:30






        • 7





          Note that pactl has terrible error messages, and that many audio equipment don't have these ad2p and hsp. My Bose only has ad2p_sink, not these other two.

          – odinho - Velmont
          Jun 12 '16 at 10:10






        • 1





          I think you need quotes around that egrep pattern

          – naught101
          Aug 4 '16 at 5:33






        • 2





          @odinho-Velmont toggling between ad2p_sink and off works for me. I've recently aded this to my Pulse audio/volume control script that might be helpful to somebody

          – Sam Mason
          Mar 31 '17 at 16:37














        34





        +100







        34





        +100



        34




        +100





        No, this is not normal but I've had a similar problem occasionally with my Altec Lansing iMT525 Bluetooth Speakers. Something similar in concept to Sri's answer almost always works for me, and I need to do it only once per connect.



        Auto-switching Bluetooth profiles to re-initialize PulseAudio



        If you're looking for a culprit, I'd look at Ubuntu's sound system, PulseAudio first, and then your bluetooth receiver. Try this:




        • First, delete and re-pair your Bluetooth device.



        • Then, copy and paste the below into a .sh file in your home directory, say /home/brillout/pabluezswitch.sh:




          #!/bin/bash

          BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
          pactl set-card-profile $BLUEZCARD a2dp
          pactl set-card-profile $BLUEZCARD hsp
          pactl set-card-profile $BLUEZCARD a2dp


        • Make the file executable by opening a terminal and typing chmod +x ~/pabluezswitch.sh


        • Go to Settings...Keyboard...Shortcuts, and create a custom shortcut; name it whatever you want, with the command as /home/brillout/pabluezswitch.sh (substitute appropriate username in path!). Click Apply, and then click on the right where it says Disabled to set up a keyboard shortcut to execute the script.



        What this does is force the PulseAudio system to resynchronize the audio being sent to your headset/speakers by switching profiles from ad2p -> hsp -> a2dp, thus hopefully getting rid of any latency.





        Whenever you connect and notice the lag, you should press the keyboard shortcut chosen above to attempt to fix the latency -- hopefully it works for you!






        share|improve this answer













        No, this is not normal but I've had a similar problem occasionally with my Altec Lansing iMT525 Bluetooth Speakers. Something similar in concept to Sri's answer almost always works for me, and I need to do it only once per connect.



        Auto-switching Bluetooth profiles to re-initialize PulseAudio



        If you're looking for a culprit, I'd look at Ubuntu's sound system, PulseAudio first, and then your bluetooth receiver. Try this:




        • First, delete and re-pair your Bluetooth device.



        • Then, copy and paste the below into a .sh file in your home directory, say /home/brillout/pabluezswitch.sh:




          #!/bin/bash

          BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
          pactl set-card-profile $BLUEZCARD a2dp
          pactl set-card-profile $BLUEZCARD hsp
          pactl set-card-profile $BLUEZCARD a2dp


        • Make the file executable by opening a terminal and typing chmod +x ~/pabluezswitch.sh


        • Go to Settings...Keyboard...Shortcuts, and create a custom shortcut; name it whatever you want, with the command as /home/brillout/pabluezswitch.sh (substitute appropriate username in path!). Click Apply, and then click on the right where it says Disabled to set up a keyboard shortcut to execute the script.



        What this does is force the PulseAudio system to resynchronize the audio being sent to your headset/speakers by switching profiles from ad2p -> hsp -> a2dp, thus hopefully getting rid of any latency.





        Whenever you connect and notice the lag, you should press the keyboard shortcut chosen above to attempt to fix the latency -- hopefully it works for you!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 2 '12 at 13:24









        ishish

        115k29265293




        115k29265293













        • I've been using this for a couple days now, and it works great. -- 14.04

          – dpb
          Oct 29 '14 at 14:37











        • Great answer and perfectly convenient too! Great job!

          – Zzzach...
          Dec 14 '14 at 21:30






        • 7





          Note that pactl has terrible error messages, and that many audio equipment don't have these ad2p and hsp. My Bose only has ad2p_sink, not these other two.

          – odinho - Velmont
          Jun 12 '16 at 10:10






        • 1





          I think you need quotes around that egrep pattern

          – naught101
          Aug 4 '16 at 5:33






        • 2





          @odinho-Velmont toggling between ad2p_sink and off works for me. I've recently aded this to my Pulse audio/volume control script that might be helpful to somebody

          – Sam Mason
          Mar 31 '17 at 16:37



















        • I've been using this for a couple days now, and it works great. -- 14.04

          – dpb
          Oct 29 '14 at 14:37











        • Great answer and perfectly convenient too! Great job!

          – Zzzach...
          Dec 14 '14 at 21:30






        • 7





          Note that pactl has terrible error messages, and that many audio equipment don't have these ad2p and hsp. My Bose only has ad2p_sink, not these other two.

          – odinho - Velmont
          Jun 12 '16 at 10:10






        • 1





          I think you need quotes around that egrep pattern

          – naught101
          Aug 4 '16 at 5:33






        • 2





          @odinho-Velmont toggling between ad2p_sink and off works for me. I've recently aded this to my Pulse audio/volume control script that might be helpful to somebody

          – Sam Mason
          Mar 31 '17 at 16:37

















        I've been using this for a couple days now, and it works great. -- 14.04

        – dpb
        Oct 29 '14 at 14:37





        I've been using this for a couple days now, and it works great. -- 14.04

        – dpb
        Oct 29 '14 at 14:37













        Great answer and perfectly convenient too! Great job!

        – Zzzach...
        Dec 14 '14 at 21:30





        Great answer and perfectly convenient too! Great job!

        – Zzzach...
        Dec 14 '14 at 21:30




        7




        7





        Note that pactl has terrible error messages, and that many audio equipment don't have these ad2p and hsp. My Bose only has ad2p_sink, not these other two.

        – odinho - Velmont
        Jun 12 '16 at 10:10





        Note that pactl has terrible error messages, and that many audio equipment don't have these ad2p and hsp. My Bose only has ad2p_sink, not these other two.

        – odinho - Velmont
        Jun 12 '16 at 10:10




        1




        1





        I think you need quotes around that egrep pattern

        – naught101
        Aug 4 '16 at 5:33





        I think you need quotes around that egrep pattern

        – naught101
        Aug 4 '16 at 5:33




        2




        2





        @odinho-Velmont toggling between ad2p_sink and off works for me. I've recently aded this to my Pulse audio/volume control script that might be helpful to somebody

        – Sam Mason
        Mar 31 '17 at 16:37





        @odinho-Velmont toggling between ad2p_sink and off works for me. I've recently aded this to my Pulse audio/volume control script that might be helpful to somebody

        – Sam Mason
        Mar 31 '17 at 16:37













        16














        In pavucontrol I go to the output device tab, then choose the advanced option below the bluetooth device. There you can set the latency offset to 600ms. Problem solved.






        share|improve this answer





















        • 2





          Removed unnecessary sass from answer - no need to be rude. Also, this sounds like it should work, but it doesn't seem to actually do anything for me...

          – naught101
          Aug 16 '16 at 1:31













        • For me this worked for youtube playback with bluetooth speakers. Thanks. When I first opened pavucontrol the advanced option was hidden. Had to vertically expand the window.

          – user75505
          Jan 15 '18 at 23:20
















        16














        In pavucontrol I go to the output device tab, then choose the advanced option below the bluetooth device. There you can set the latency offset to 600ms. Problem solved.






        share|improve this answer





















        • 2





          Removed unnecessary sass from answer - no need to be rude. Also, this sounds like it should work, but it doesn't seem to actually do anything for me...

          – naught101
          Aug 16 '16 at 1:31













        • For me this worked for youtube playback with bluetooth speakers. Thanks. When I first opened pavucontrol the advanced option was hidden. Had to vertically expand the window.

          – user75505
          Jan 15 '18 at 23:20














        16












        16








        16







        In pavucontrol I go to the output device tab, then choose the advanced option below the bluetooth device. There you can set the latency offset to 600ms. Problem solved.






        share|improve this answer















        In pavucontrol I go to the output device tab, then choose the advanced option below the bluetooth device. There you can set the latency offset to 600ms. Problem solved.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 16 '16 at 2:18









        naught101

        8441017




        8441017










        answered Apr 22 '15 at 15:17









        Roelf RenkemaRoelf Renkema

        16912




        16912








        • 2





          Removed unnecessary sass from answer - no need to be rude. Also, this sounds like it should work, but it doesn't seem to actually do anything for me...

          – naught101
          Aug 16 '16 at 1:31













        • For me this worked for youtube playback with bluetooth speakers. Thanks. When I first opened pavucontrol the advanced option was hidden. Had to vertically expand the window.

          – user75505
          Jan 15 '18 at 23:20














        • 2





          Removed unnecessary sass from answer - no need to be rude. Also, this sounds like it should work, but it doesn't seem to actually do anything for me...

          – naught101
          Aug 16 '16 at 1:31













        • For me this worked for youtube playback with bluetooth speakers. Thanks. When I first opened pavucontrol the advanced option was hidden. Had to vertically expand the window.

          – user75505
          Jan 15 '18 at 23:20








        2




        2





        Removed unnecessary sass from answer - no need to be rude. Also, this sounds like it should work, but it doesn't seem to actually do anything for me...

        – naught101
        Aug 16 '16 at 1:31







        Removed unnecessary sass from answer - no need to be rude. Also, this sounds like it should work, but it doesn't seem to actually do anything for me...

        – naught101
        Aug 16 '16 at 1:31















        For me this worked for youtube playback with bluetooth speakers. Thanks. When I first opened pavucontrol the advanced option was hidden. Had to vertically expand the window.

        – user75505
        Jan 15 '18 at 23:20





        For me this worked for youtube playback with bluetooth speakers. Thanks. When I first opened pavucontrol the advanced option was hidden. Had to vertically expand the window.

        – user75505
        Jan 15 '18 at 23:20











        9














        I get similar problem occasionally, irrespective of the player used. Mine is a Nokia BH-503 Bluetooth Stereo Headphone with MSI CR400 laptop and Ubuntu 11.10. I happened to come across a workaround which you can try.




        • Start the video playback.

        • Go to Sound Settings > Hardware.

        • Select the Bluetooth device.

        • Then in Settings for the Selected Device drop-down, switch to Telephony Duplex (HSP/HFP) profile, then switch back to High Fidelity Playback (A2DP).






        share|improve this answer




























          9














          I get similar problem occasionally, irrespective of the player used. Mine is a Nokia BH-503 Bluetooth Stereo Headphone with MSI CR400 laptop and Ubuntu 11.10. I happened to come across a workaround which you can try.




          • Start the video playback.

          • Go to Sound Settings > Hardware.

          • Select the Bluetooth device.

          • Then in Settings for the Selected Device drop-down, switch to Telephony Duplex (HSP/HFP) profile, then switch back to High Fidelity Playback (A2DP).






          share|improve this answer


























            9












            9








            9







            I get similar problem occasionally, irrespective of the player used. Mine is a Nokia BH-503 Bluetooth Stereo Headphone with MSI CR400 laptop and Ubuntu 11.10. I happened to come across a workaround which you can try.




            • Start the video playback.

            • Go to Sound Settings > Hardware.

            • Select the Bluetooth device.

            • Then in Settings for the Selected Device drop-down, switch to Telephony Duplex (HSP/HFP) profile, then switch back to High Fidelity Playback (A2DP).






            share|improve this answer













            I get similar problem occasionally, irrespective of the player used. Mine is a Nokia BH-503 Bluetooth Stereo Headphone with MSI CR400 laptop and Ubuntu 11.10. I happened to come across a workaround which you can try.




            • Start the video playback.

            • Go to Sound Settings > Hardware.

            • Select the Bluetooth device.

            • Then in Settings for the Selected Device drop-down, switch to Telephony Duplex (HSP/HFP) profile, then switch back to High Fidelity Playback (A2DP).







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 6 '12 at 5:42









            SriSri

            1,15511031




            1,15511031























                7














                The top reply here works, but not for every bluetooth audio device. Some devices have different profile names than what that poster has with his bluetooth speakers. For instance, in the following code, which was originally posted by that person, it apparently has profiles named a2dp and hsp. Neither of these are available with my LG Tones, for example, but they are with other devices like my Sony headset.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp
                pactl set-card-profile $BLUEZCARD hsp
                pactl set-card-profile $BLUEZCARD a2dp


                That code will work for most bluetooth devices it appears, but to get this working correctly for those devices that don't have the a2dp profile or the hsp profile, type in:



                pactl list | grep -Pzo '.*bluez_card(.*n)*'


                This will return everything after where it finds a bluetooth device. For instance, with the LG Tone Ultra headset, I get this:



                Name: bluez_card.B8_AD_3E_**_**_**
                Driver: module-bluez5-device.c
                Owner Module: 36
                Properties:
                device.description = "LG HBS810"
                device.string = "B8:AD:3E:**:**:**"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_B8_AD_3E_**_**_**"
                bluez.class = "0x240404"
                bluez.alias = "LG HBS810"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
                Profiles:
                a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
                Active Profile: a2dp_sink
                Ports:
                headset-output: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): a2dp_sink, headset_head_unit
                headset-input: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): headset_head_unit


                We are interested in the profiles section. In this section, we see three profiles, which are a2dp_sink, headset_head_unit, and off. The two profiles we need should have in them (A2DP Sink) and (HSP/HFP). In this case, they are a2dp_sink for the a2dp profile, and headsethead_unit for the hsp profile. Notice this is different than the original poster's a2dp and hsp.



                Now, with the above code, we will modify it and put it into a file. I called the file bluezswitch.sh.



                Change to the directory you want to put the file. It can be anywhere.



                touch bluezswitch.sh


                Then



                nano bluezswitch.sh


                Copy and paste the code at the very top of this comment and replace the a2dp and hsp with the values you got when you ran the above command, and paste it in that file. For instance, this is what my file looked like for my LG Tones.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp_sink
                pactl set-card-profile $BLUEZCARD headset_head_unit
                pactl set-card-profile $BLUEZCARD a2dp_sink


                Now, ctrl-x then y to save the file and exit nano, and then make the file executable:



                chmod +x bluezswitch.sh


                Then follow up by setting a keyboard shortcut as has been explained.




                Go to Settings...Keyboard...Shortcuts, and create a
                custom shortcut; name it whatever you want, with the command as
                /home/brillout/bluezswitch.sh (substitute appropriate username in
                path!). Click Apply, and then click on the right where it says
                Disabled to set up a keyboard shortcut to execute the script.




                That should be all there is to it. This should work for all those that it didn't work for before.






                share|improve this answer





















                • 1





                  For me, turning off a2dp_sink, off, a2dp_sink in sequence works very well for me. Setting to headset_head_unit I/O error.

                  – Mohd Shahril
                  Apr 8 '18 at 9:46
















                7














                The top reply here works, but not for every bluetooth audio device. Some devices have different profile names than what that poster has with his bluetooth speakers. For instance, in the following code, which was originally posted by that person, it apparently has profiles named a2dp and hsp. Neither of these are available with my LG Tones, for example, but they are with other devices like my Sony headset.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp
                pactl set-card-profile $BLUEZCARD hsp
                pactl set-card-profile $BLUEZCARD a2dp


                That code will work for most bluetooth devices it appears, but to get this working correctly for those devices that don't have the a2dp profile or the hsp profile, type in:



                pactl list | grep -Pzo '.*bluez_card(.*n)*'


                This will return everything after where it finds a bluetooth device. For instance, with the LG Tone Ultra headset, I get this:



                Name: bluez_card.B8_AD_3E_**_**_**
                Driver: module-bluez5-device.c
                Owner Module: 36
                Properties:
                device.description = "LG HBS810"
                device.string = "B8:AD:3E:**:**:**"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_B8_AD_3E_**_**_**"
                bluez.class = "0x240404"
                bluez.alias = "LG HBS810"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
                Profiles:
                a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
                Active Profile: a2dp_sink
                Ports:
                headset-output: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): a2dp_sink, headset_head_unit
                headset-input: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): headset_head_unit


                We are interested in the profiles section. In this section, we see three profiles, which are a2dp_sink, headset_head_unit, and off. The two profiles we need should have in them (A2DP Sink) and (HSP/HFP). In this case, they are a2dp_sink for the a2dp profile, and headsethead_unit for the hsp profile. Notice this is different than the original poster's a2dp and hsp.



                Now, with the above code, we will modify it and put it into a file. I called the file bluezswitch.sh.



                Change to the directory you want to put the file. It can be anywhere.



                touch bluezswitch.sh


                Then



                nano bluezswitch.sh


                Copy and paste the code at the very top of this comment and replace the a2dp and hsp with the values you got when you ran the above command, and paste it in that file. For instance, this is what my file looked like for my LG Tones.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp_sink
                pactl set-card-profile $BLUEZCARD headset_head_unit
                pactl set-card-profile $BLUEZCARD a2dp_sink


                Now, ctrl-x then y to save the file and exit nano, and then make the file executable:



                chmod +x bluezswitch.sh


                Then follow up by setting a keyboard shortcut as has been explained.




                Go to Settings...Keyboard...Shortcuts, and create a
                custom shortcut; name it whatever you want, with the command as
                /home/brillout/bluezswitch.sh (substitute appropriate username in
                path!). Click Apply, and then click on the right where it says
                Disabled to set up a keyboard shortcut to execute the script.




                That should be all there is to it. This should work for all those that it didn't work for before.






                share|improve this answer





















                • 1





                  For me, turning off a2dp_sink, off, a2dp_sink in sequence works very well for me. Setting to headset_head_unit I/O error.

                  – Mohd Shahril
                  Apr 8 '18 at 9:46














                7












                7








                7







                The top reply here works, but not for every bluetooth audio device. Some devices have different profile names than what that poster has with his bluetooth speakers. For instance, in the following code, which was originally posted by that person, it apparently has profiles named a2dp and hsp. Neither of these are available with my LG Tones, for example, but they are with other devices like my Sony headset.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp
                pactl set-card-profile $BLUEZCARD hsp
                pactl set-card-profile $BLUEZCARD a2dp


                That code will work for most bluetooth devices it appears, but to get this working correctly for those devices that don't have the a2dp profile or the hsp profile, type in:



                pactl list | grep -Pzo '.*bluez_card(.*n)*'


                This will return everything after where it finds a bluetooth device. For instance, with the LG Tone Ultra headset, I get this:



                Name: bluez_card.B8_AD_3E_**_**_**
                Driver: module-bluez5-device.c
                Owner Module: 36
                Properties:
                device.description = "LG HBS810"
                device.string = "B8:AD:3E:**:**:**"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_B8_AD_3E_**_**_**"
                bluez.class = "0x240404"
                bluez.alias = "LG HBS810"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
                Profiles:
                a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
                Active Profile: a2dp_sink
                Ports:
                headset-output: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): a2dp_sink, headset_head_unit
                headset-input: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): headset_head_unit


                We are interested in the profiles section. In this section, we see three profiles, which are a2dp_sink, headset_head_unit, and off. The two profiles we need should have in them (A2DP Sink) and (HSP/HFP). In this case, they are a2dp_sink for the a2dp profile, and headsethead_unit for the hsp profile. Notice this is different than the original poster's a2dp and hsp.



                Now, with the above code, we will modify it and put it into a file. I called the file bluezswitch.sh.



                Change to the directory you want to put the file. It can be anywhere.



                touch bluezswitch.sh


                Then



                nano bluezswitch.sh


                Copy and paste the code at the very top of this comment and replace the a2dp and hsp with the values you got when you ran the above command, and paste it in that file. For instance, this is what my file looked like for my LG Tones.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp_sink
                pactl set-card-profile $BLUEZCARD headset_head_unit
                pactl set-card-profile $BLUEZCARD a2dp_sink


                Now, ctrl-x then y to save the file and exit nano, and then make the file executable:



                chmod +x bluezswitch.sh


                Then follow up by setting a keyboard shortcut as has been explained.




                Go to Settings...Keyboard...Shortcuts, and create a
                custom shortcut; name it whatever you want, with the command as
                /home/brillout/bluezswitch.sh (substitute appropriate username in
                path!). Click Apply, and then click on the right where it says
                Disabled to set up a keyboard shortcut to execute the script.




                That should be all there is to it. This should work for all those that it didn't work for before.






                share|improve this answer















                The top reply here works, but not for every bluetooth audio device. Some devices have different profile names than what that poster has with his bluetooth speakers. For instance, in the following code, which was originally posted by that person, it apparently has profiles named a2dp and hsp. Neither of these are available with my LG Tones, for example, but they are with other devices like my Sony headset.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp
                pactl set-card-profile $BLUEZCARD hsp
                pactl set-card-profile $BLUEZCARD a2dp


                That code will work for most bluetooth devices it appears, but to get this working correctly for those devices that don't have the a2dp profile or the hsp profile, type in:



                pactl list | grep -Pzo '.*bluez_card(.*n)*'


                This will return everything after where it finds a bluetooth device. For instance, with the LG Tone Ultra headset, I get this:



                Name: bluez_card.B8_AD_3E_**_**_**
                Driver: module-bluez5-device.c
                Owner Module: 36
                Properties:
                device.description = "LG HBS810"
                device.string = "B8:AD:3E:**:**:**"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_B8_AD_3E_**_**_**"
                bluez.class = "0x240404"
                bluez.alias = "LG HBS810"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
                Profiles:
                a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
                Active Profile: a2dp_sink
                Ports:
                headset-output: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): a2dp_sink, headset_head_unit
                headset-input: Headset (priority: 0, latency offset: 0 usec)
                Part of profile(s): headset_head_unit


                We are interested in the profiles section. In this section, we see three profiles, which are a2dp_sink, headset_head_unit, and off. The two profiles we need should have in them (A2DP Sink) and (HSP/HFP). In this case, they are a2dp_sink for the a2dp profile, and headsethead_unit for the hsp profile. Notice this is different than the original poster's a2dp and hsp.



                Now, with the above code, we will modify it and put it into a file. I called the file bluezswitch.sh.



                Change to the directory you want to put the file. It can be anywhere.



                touch bluezswitch.sh


                Then



                nano bluezswitch.sh


                Copy and paste the code at the very top of this comment and replace the a2dp and hsp with the values you got when you ran the above command, and paste it in that file. For instance, this is what my file looked like for my LG Tones.



                #!/bin/bash

                BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                pactl set-card-profile $BLUEZCARD a2dp_sink
                pactl set-card-profile $BLUEZCARD headset_head_unit
                pactl set-card-profile $BLUEZCARD a2dp_sink


                Now, ctrl-x then y to save the file and exit nano, and then make the file executable:



                chmod +x bluezswitch.sh


                Then follow up by setting a keyboard shortcut as has been explained.




                Go to Settings...Keyboard...Shortcuts, and create a
                custom shortcut; name it whatever you want, with the command as
                /home/brillout/bluezswitch.sh (substitute appropriate username in
                path!). Click Apply, and then click on the right where it says
                Disabled to set up a keyboard shortcut to execute the script.




                That should be all there is to it. This should work for all those that it didn't work for before.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 30 '17 at 15:02

























                answered Sep 2 '17 at 6:38









                Timm SimpkinsTimm Simpkins

                18615




                18615








                • 1





                  For me, turning off a2dp_sink, off, a2dp_sink in sequence works very well for me. Setting to headset_head_unit I/O error.

                  – Mohd Shahril
                  Apr 8 '18 at 9:46














                • 1





                  For me, turning off a2dp_sink, off, a2dp_sink in sequence works very well for me. Setting to headset_head_unit I/O error.

                  – Mohd Shahril
                  Apr 8 '18 at 9:46








                1




                1





                For me, turning off a2dp_sink, off, a2dp_sink in sequence works very well for me. Setting to headset_head_unit I/O error.

                – Mohd Shahril
                Apr 8 '18 at 9:46





                For me, turning off a2dp_sink, off, a2dp_sink in sequence works very well for me. Setting to headset_head_unit I/O error.

                – Mohd Shahril
                Apr 8 '18 at 9:46











                5














                Adaptive differential pulse code modulation involves a look-ahead type compressing algorithm where information cannot be transmitted before the encoder has had a chance to examine several bytes of forthcoming info. Hence, data has to stack up in the encoder, and there is an inherent time shift between the streams entering and leaving the encoder. Long ago, I did a study of data network delays to determine the feasibility of voice-over-data telephony (what is now VoIP). I think I concluded that ADPCM-style compression/encoding would introduce too much delay. I think to overcome this Bluetooth-delay problem, one might need a non-compressing type of audio encoding which should have lower latency.






                share|improve this answer



















                • 6





                  The compression problem would account for a few tens of milliseconds, not half a second, surely?

                  – naught101
                  Aug 4 '16 at 5:36
















                5














                Adaptive differential pulse code modulation involves a look-ahead type compressing algorithm where information cannot be transmitted before the encoder has had a chance to examine several bytes of forthcoming info. Hence, data has to stack up in the encoder, and there is an inherent time shift between the streams entering and leaving the encoder. Long ago, I did a study of data network delays to determine the feasibility of voice-over-data telephony (what is now VoIP). I think I concluded that ADPCM-style compression/encoding would introduce too much delay. I think to overcome this Bluetooth-delay problem, one might need a non-compressing type of audio encoding which should have lower latency.






                share|improve this answer



















                • 6





                  The compression problem would account for a few tens of milliseconds, not half a second, surely?

                  – naught101
                  Aug 4 '16 at 5:36














                5












                5








                5







                Adaptive differential pulse code modulation involves a look-ahead type compressing algorithm where information cannot be transmitted before the encoder has had a chance to examine several bytes of forthcoming info. Hence, data has to stack up in the encoder, and there is an inherent time shift between the streams entering and leaving the encoder. Long ago, I did a study of data network delays to determine the feasibility of voice-over-data telephony (what is now VoIP). I think I concluded that ADPCM-style compression/encoding would introduce too much delay. I think to overcome this Bluetooth-delay problem, one might need a non-compressing type of audio encoding which should have lower latency.






                share|improve this answer













                Adaptive differential pulse code modulation involves a look-ahead type compressing algorithm where information cannot be transmitted before the encoder has had a chance to examine several bytes of forthcoming info. Hence, data has to stack up in the encoder, and there is an inherent time shift between the streams entering and leaving the encoder. Long ago, I did a study of data network delays to determine the feasibility of voice-over-data telephony (what is now VoIP). I think I concluded that ADPCM-style compression/encoding would introduce too much delay. I think to overcome this Bluetooth-delay problem, one might need a non-compressing type of audio encoding which should have lower latency.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 7 '13 at 15:02









                Kirk ShrewsburyKirk Shrewsbury

                5111




                5111








                • 6





                  The compression problem would account for a few tens of milliseconds, not half a second, surely?

                  – naught101
                  Aug 4 '16 at 5:36














                • 6





                  The compression problem would account for a few tens of milliseconds, not half a second, surely?

                  – naught101
                  Aug 4 '16 at 5:36








                6




                6





                The compression problem would account for a few tens of milliseconds, not half a second, surely?

                – naught101
                Aug 4 '16 at 5:36





                The compression problem would account for a few tens of milliseconds, not half a second, surely?

                – naught101
                Aug 4 '16 at 5:36











                4














                I tried a lot of approaches to this problem, but nothing could fix it. Then I stumbled upon set-port-latency-offset



                If you are using pulseaudio do :



                pactl list cards short | egrep -o bluez.*[[:space:]]


                This will give you the bluetooth interface.
                Now set the latency accordingly :



                pactl set-port-latency-offset <INTERFACE> speaker-output 100000


                I am using 100000 microseconds which works fine for me.






                share|improve this answer



















                • 1





                  For anyone else stumbling across this old post searching for an answer, Arindam Mani Das's answer works perfectly. If you receive the "no such entity" error, run 'pactl list cards' and check which ports are available for your device. I had to change "speaker-output" to "headset-output" in the second command since my device does not have a speaker-output port.

                  – Billy Farrington
                  May 22 '18 at 0:46
















                4














                I tried a lot of approaches to this problem, but nothing could fix it. Then I stumbled upon set-port-latency-offset



                If you are using pulseaudio do :



                pactl list cards short | egrep -o bluez.*[[:space:]]


                This will give you the bluetooth interface.
                Now set the latency accordingly :



                pactl set-port-latency-offset <INTERFACE> speaker-output 100000


                I am using 100000 microseconds which works fine for me.






                share|improve this answer



















                • 1





                  For anyone else stumbling across this old post searching for an answer, Arindam Mani Das's answer works perfectly. If you receive the "no such entity" error, run 'pactl list cards' and check which ports are available for your device. I had to change "speaker-output" to "headset-output" in the second command since my device does not have a speaker-output port.

                  – Billy Farrington
                  May 22 '18 at 0:46














                4












                4








                4







                I tried a lot of approaches to this problem, but nothing could fix it. Then I stumbled upon set-port-latency-offset



                If you are using pulseaudio do :



                pactl list cards short | egrep -o bluez.*[[:space:]]


                This will give you the bluetooth interface.
                Now set the latency accordingly :



                pactl set-port-latency-offset <INTERFACE> speaker-output 100000


                I am using 100000 microseconds which works fine for me.






                share|improve this answer













                I tried a lot of approaches to this problem, but nothing could fix it. Then I stumbled upon set-port-latency-offset



                If you are using pulseaudio do :



                pactl list cards short | egrep -o bluez.*[[:space:]]


                This will give you the bluetooth interface.
                Now set the latency accordingly :



                pactl set-port-latency-offset <INTERFACE> speaker-output 100000


                I am using 100000 microseconds which works fine for me.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 21 '15 at 9:14









                Arindam Mani DasArindam Mani Das

                1412




                1412








                • 1





                  For anyone else stumbling across this old post searching for an answer, Arindam Mani Das's answer works perfectly. If you receive the "no such entity" error, run 'pactl list cards' and check which ports are available for your device. I had to change "speaker-output" to "headset-output" in the second command since my device does not have a speaker-output port.

                  – Billy Farrington
                  May 22 '18 at 0:46














                • 1





                  For anyone else stumbling across this old post searching for an answer, Arindam Mani Das's answer works perfectly. If you receive the "no such entity" error, run 'pactl list cards' and check which ports are available for your device. I had to change "speaker-output" to "headset-output" in the second command since my device does not have a speaker-output port.

                  – Billy Farrington
                  May 22 '18 at 0:46








                1




                1





                For anyone else stumbling across this old post searching for an answer, Arindam Mani Das's answer works perfectly. If you receive the "no such entity" error, run 'pactl list cards' and check which ports are available for your device. I had to change "speaker-output" to "headset-output" in the second command since my device does not have a speaker-output port.

                – Billy Farrington
                May 22 '18 at 0:46





                For anyone else stumbling across this old post searching for an answer, Arindam Mani Das's answer works perfectly. If you receive the "no such entity" error, run 'pactl list cards' and check which ports are available for your device. I had to change "speaker-output" to "headset-output" in the second command since my device does not have a speaker-output port.

                – Billy Farrington
                May 22 '18 at 0:46











                1














                Here's what solved it for me: $ sudo apt-get install phonon-backend-vlc and make sure it's the preferred backend, in KDE go to [System Settings][Multimedia][Audio and video settings][Backend] and use the [Prefer button]






                share|improve this answer





















                • 1





                  @dargaud I recommend expanding this to explain how to make it the preferred backend.

                  – Eliah Kagan
                  Jul 24 '14 at 22:33
















                1














                Here's what solved it for me: $ sudo apt-get install phonon-backend-vlc and make sure it's the preferred backend, in KDE go to [System Settings][Multimedia][Audio and video settings][Backend] and use the [Prefer button]






                share|improve this answer





















                • 1





                  @dargaud I recommend expanding this to explain how to make it the preferred backend.

                  – Eliah Kagan
                  Jul 24 '14 at 22:33














                1












                1








                1







                Here's what solved it for me: $ sudo apt-get install phonon-backend-vlc and make sure it's the preferred backend, in KDE go to [System Settings][Multimedia][Audio and video settings][Backend] and use the [Prefer button]






                share|improve this answer















                Here's what solved it for me: $ sudo apt-get install phonon-backend-vlc and make sure it's the preferred backend, in KDE go to [System Settings][Multimedia][Audio and video settings][Backend] and use the [Prefer button]







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 25 '14 at 14:56

























                answered Jul 24 '14 at 16:29









                dargauddargaud

                3151616




                3151616








                • 1





                  @dargaud I recommend expanding this to explain how to make it the preferred backend.

                  – Eliah Kagan
                  Jul 24 '14 at 22:33














                • 1





                  @dargaud I recommend expanding this to explain how to make it the preferred backend.

                  – Eliah Kagan
                  Jul 24 '14 at 22:33








                1




                1





                @dargaud I recommend expanding this to explain how to make it the preferred backend.

                – Eliah Kagan
                Jul 24 '14 at 22:33





                @dargaud I recommend expanding this to explain how to make it the preferred backend.

                – Eliah Kagan
                Jul 24 '14 at 22:33











                0














                individuals who are having this problem Please view this website: http://projectzeorymer.wordpress.com/2011/09/01/ubuntu-how-to-connect-nokia-bh-503-bluetooth-headset-to-your-pc/ to see a pic of what you need to download.



                Download the bluetooth manager and use it to manipulate the settings of the headset. Set the sound settings to High Fidelity Playback (A2DP) and then go in sound settings.






                share|improve this answer





















                • 1





                  Go on bluetooth manage and go to Audio Profile and then select High Fedelity Playback.. thats it

                  – Alex Force
                  Aug 18 '12 at 22:25
















                0














                individuals who are having this problem Please view this website: http://projectzeorymer.wordpress.com/2011/09/01/ubuntu-how-to-connect-nokia-bh-503-bluetooth-headset-to-your-pc/ to see a pic of what you need to download.



                Download the bluetooth manager and use it to manipulate the settings of the headset. Set the sound settings to High Fidelity Playback (A2DP) and then go in sound settings.






                share|improve this answer





















                • 1





                  Go on bluetooth manage and go to Audio Profile and then select High Fedelity Playback.. thats it

                  – Alex Force
                  Aug 18 '12 at 22:25














                0












                0








                0







                individuals who are having this problem Please view this website: http://projectzeorymer.wordpress.com/2011/09/01/ubuntu-how-to-connect-nokia-bh-503-bluetooth-headset-to-your-pc/ to see a pic of what you need to download.



                Download the bluetooth manager and use it to manipulate the settings of the headset. Set the sound settings to High Fidelity Playback (A2DP) and then go in sound settings.






                share|improve this answer















                individuals who are having this problem Please view this website: http://projectzeorymer.wordpress.com/2011/09/01/ubuntu-how-to-connect-nokia-bh-503-bluetooth-headset-to-your-pc/ to see a pic of what you need to download.



                Download the bluetooth manager and use it to manipulate the settings of the headset. Set the sound settings to High Fidelity Playback (A2DP) and then go in sound settings.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 14 '12 at 0:56









                Jorge Castro

                36.4k105422617




                36.4k105422617










                answered Aug 18 '12 at 22:22









                Alex ForceAlex Force

                171




                171








                • 1





                  Go on bluetooth manage and go to Audio Profile and then select High Fedelity Playback.. thats it

                  – Alex Force
                  Aug 18 '12 at 22:25














                • 1





                  Go on bluetooth manage and go to Audio Profile and then select High Fedelity Playback.. thats it

                  – Alex Force
                  Aug 18 '12 at 22:25








                1




                1





                Go on bluetooth manage and go to Audio Profile and then select High Fedelity Playback.. thats it

                – Alex Force
                Aug 18 '12 at 22:25





                Go on bluetooth manage and go to Audio Profile and then select High Fedelity Playback.. thats it

                – Alex Force
                Aug 18 '12 at 22:25











                0














                On VLC media player, Go to
                Tools
                Track synchronization
                Synchronize tab
                Under audio/ video audio track synchronize, use a negative value like about -0.67 and the lag will be compensated for fully. You have to manually do this every time you open a new file. Chris






                share|improve this answer




























                  0














                  On VLC media player, Go to
                  Tools
                  Track synchronization
                  Synchronize tab
                  Under audio/ video audio track synchronize, use a negative value like about -0.67 and the lag will be compensated for fully. You have to manually do this every time you open a new file. Chris






                  share|improve this answer


























                    0












                    0








                    0







                    On VLC media player, Go to
                    Tools
                    Track synchronization
                    Synchronize tab
                    Under audio/ video audio track synchronize, use a negative value like about -0.67 and the lag will be compensated for fully. You have to manually do this every time you open a new file. Chris






                    share|improve this answer













                    On VLC media player, Go to
                    Tools
                    Track synchronization
                    Synchronize tab
                    Under audio/ video audio track synchronize, use a negative value like about -0.67 and the lag will be compensated for fully. You have to manually do this every time you open a new file. Chris







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 2 '17 at 14:18









                    LexLex

                    1




                    1























                        0














                        Similarly to Timm's answer, I did not have the profiles of the accepted answer either. Setting the HSP gave an error code.



                        I ended up using the following, almost identical, script.



                        #!/bin/bash
                        BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                        pactl set-card-profile $BLUEZCARD a2dp_sink
                        pactl set-card-profile $BLUEZCARD off
                        pactl set-card-profile $BLUEZCARD a2dp_sink





                        share|improve this answer




























                          0














                          Similarly to Timm's answer, I did not have the profiles of the accepted answer either. Setting the HSP gave an error code.



                          I ended up using the following, almost identical, script.



                          #!/bin/bash
                          BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                          pactl set-card-profile $BLUEZCARD a2dp_sink
                          pactl set-card-profile $BLUEZCARD off
                          pactl set-card-profile $BLUEZCARD a2dp_sink





                          share|improve this answer


























                            0












                            0








                            0







                            Similarly to Timm's answer, I did not have the profiles of the accepted answer either. Setting the HSP gave an error code.



                            I ended up using the following, almost identical, script.



                            #!/bin/bash
                            BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                            pactl set-card-profile $BLUEZCARD a2dp_sink
                            pactl set-card-profile $BLUEZCARD off
                            pactl set-card-profile $BLUEZCARD a2dp_sink





                            share|improve this answer













                            Similarly to Timm's answer, I did not have the profiles of the accepted answer either. Setting the HSP gave an error code.



                            I ended up using the following, almost identical, script.



                            #!/bin/bash
                            BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
                            pactl set-card-profile $BLUEZCARD a2dp_sink
                            pactl set-card-profile $BLUEZCARD off
                            pactl set-card-profile $BLUEZCARD a2dp_sink






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jan 18 at 12:16









                            raahlbraahlb

                            1




                            1






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Ask Ubuntu!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f145935%2fget-rid-of-0-5s-latency-when-playing-audio-over-bluetooth-with-a2dp%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How to make a Squid Proxy server?

                                第一次世界大戦

                                Touch on Surface Book