GithubHelp home page GithubHelp logo

Huge delay about bluez-alsa HOT 8 CLOSED

arkq avatar arkq commented on May 23, 2024 2
Huge delay

from bluez-alsa.

Comments (8)

arkq avatar arkq commented on May 23, 2024

Delay issue... yeap, definitely sounds like bluealsa :D

The big number you've seen in the PCM plugin (if you're talking about this line) is to counteract delay, not to cause it. There is a lot of "components" which contribute to the final audio delay. However, not all of them are taken into account right now. So, the audio might be out of sync sometimes. However, this delay should not be bigger than 1 second or so. If you are experiencing bigger delay it is caused by a bug in a synchronization logic within bluealsa server and I'm aware of that.... Unfortunately, right now I don't know how to fix it. To be more specific, the problem is with ALSA software PCM API or my understanding how it works (which is more likely). I need a "signal" which will indicate, that the audio will start and then it will be delivered without any delay, until another signal arrives - audio stop. Right now I'm using pcm_io_start callback as a start signal, however, audio is (or it seems it is) delayed afterwards....

device doesn't get exposed in any of the usual ALSA Apis like /proc/asound/cards

Bluealsa ALSA interface is based on a software plugin, which is a part of asound library. The /proc/asound directory is a part of kernel ALSA module.

from bluez-alsa.

dagf2101 avatar dagf2101 commented on May 23, 2024

I also have a Huge delay bug right now, more something like 25 seconds.

If I open bluealsa device via my app in c++ (alsa-lib) and set every normal values I would set for regular playback, I get this huge delay.

aplay -D seem to work fine and has only small delay.

Any idea ?

from bluez-alsa.

arkq avatar arkq commented on May 23, 2024

25 secs is kinda odd... How does your PCM configuration look like (what I mean is HW params and SW params)? The delay should be no more than 0.5s (in most cases).

from bluez-alsa.

dagf2101 avatar dagf2101 commented on May 23, 2024

from bluez-alsa.

dagf2101 avatar dagf2101 commented on May 23, 2024

Ok the missing part was a snd_pcm_hw_params_set_buffer_size_near.
For some reason the sound card was only requiring snd_pcm_hw_params_set_period_size_near to work, no snd_pcm_hw_params_set_buffer_size_near was needed.

from bluez-alsa.

dagf2101 avatar dagf2101 commented on May 23, 2024

Hello, I am experiencing the 500-1000ms delay here, I guess it is normal but we need to lower it to something like 250ms.

In my app I am always sending audio so I may not need to support multiple start/stop it this can help.

You have a suggestion where I should start to look in the code ?

from bluez-alsa.

arkq avatar arkq commented on May 23, 2024

@dagf2101, it should be possible, however it depends on your usage case.

First of all make sure that your app uses small PCM buffer (or start threshold is small). You might also reduce BT socket buffer. E.g. add something like this:

size_t size = 2 * t->mtu_write;
setsockopt(t->bt_fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size))

in here: https://github.com/Arkq/bluez-alsa/blob/b0a8a136ad073549b038635e26f3caa3608330c8/src/transport.c#L694

I've been testing something similar, however the outcome is not "stable", so this change is not in the master yet.

from bluez-alsa.

arkq avatar arkq commented on May 23, 2024

A LOT of has changed in bluez-alsa project since 2017. It seems that the issue is not as severe as it was. I'm closing this issue then. For a reference please see these comments: #454 (comment) #454 (comment)

If somehow this problem still occurs please create a new issue.

from bluez-alsa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.