Code Monkey home page Code Monkey logo

Comments (5)

arkq avatar arkq commented on June 11, 2024

Hi,

Finally, I've got some time to dig around this issue and it seems that the problem is beyond my understanding....

The problem is (it seems it is) with the VLC audio synchronization code. For some strange reasons there is a build-in constraint, which determines audio-video maximal physical desynchronization. If the audio needs to be sent to the device in an advance (due to device internal delay, which is the case here), there is a maximal value for this advance time - and bluealsa exceeds this time approximately 30x. I've try to adjust these constrains, but the result was not satisfactory - there is no glitching (due to device start and stop), but the audio is not synced properly.

For the record, this is the change I've made (current master snapshot of VLC) to increase sync tolerance:

--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -50,7 +50,7 @@
 
 /** Maximum delay of actual audio playback time from coded PTS,
  * above which upsampling will be performed */
-#define AOUT_MAX_PTS_DELAY              (3 * CLOCK_FREQ / 50)
+#define AOUT_MAX_PTS_DELAY              (100 * CLOCK_FREQ / 50)
 
 /* Max acceptable resampling (in %) */
 #define AOUT_MAX_RESAMPLING             10

Also, other related files:

I will not investigate this further. All reference implementations (imho) work correctly, e.g. aplay, mplayer (even firefox seems to work). If anyone with VLC code experience would like to contribute, I'd be very happy. Btw. I'm not saying, that it is not a bluealsa bug, I just don't know where to look for clues.

from bluez-alsa.

Ruhrmolch avatar Ruhrmolch commented on June 11, 2024

Do you have the same problem with vlc?

from bluez-alsa.

arkq avatar arkq commented on June 11, 2024

Yes, I was able to reproduce this bug. Bluealsa and VLC do not come along, unfortunately. There is a small chance, that when I figure out how to fix #15, this issue will be less severe. But I wouldn't bet on it.

In the meantime, you can use mpv/mplayer as a replacement for VLC. I'm using it as a reference video player.

from bluez-alsa.

arkq avatar arkq commented on June 11, 2024

Since commit e7a4c40 it is possible to customize (overwrite) PCM delay. Using this functionality, I've managed to force VLC to work without patching the source code. One can use something like this:

pcm.headset {
	type plug
	slave.pcm {
		type bluealsa
		device "88:C6:26:C2:76:35"
		profile "a2dp"
		delay -20000
	}
	hint {
		show on
		description "BT Headset"
	}
}

The key part is delay -20000. This value might vary between setups. If VLC is still stopping and starting PCM, increase or decrease this value, e.g.: -25000, -30000, -40000, -10000.

The result is, that audio is audible, but out of sync... by a second or two. So, use the keyboard shortcut J in order to "fix" this out of sync audio (in my case it was -1000 ms). Done.

from bluez-alsa.

arkq avatar arkq commented on June 11, 2024

I think that this issue was resolved in #231

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.