Bug 96807 - I can not control the latency in module-loopback
Summary: I can not control the latency in module-loopback
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: modules (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-04 16:34 UTC by Alessandro Ferri
Modified: 2018-07-30 10:02 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Alessandro Ferri 2016-07-04 16:34:18 UTC
I would like to minimize the latency time between the audio input from the Cirrus Logic Audio Card (for raspberry Pi2) and the audio output over bluetooth speaker. I note an important time separation between my input voice on the output on Bluetooth and I would like to minimize this time. I tried to control the latency with the command:

pactl load-module module-loopback latency_msec=1 source="alsa_input.platform-sound.analog-stereo" sink="bluez_sink.B8_27_EB_00_82_2D"

or

pacat -r --latency=102800 -d alsa_input.platform-sound.analog-stereo | pacat -p --latency=102800 -d bluez_sink.B8_27_EB_00_82_2D

but it seems that the options are ignored.
Below my sink and reference source:

Sink #2
	State: SUSPENDED
	Name: bluez_sink.B8_27_EB_00_82_2D
	Description: BlueAni-00822d
	Driver: module-bluez5-device.c
	Sample Specification: s16le 2ch 44100Hz
	Channel Map: front-left,front-right
	Owner Module: 15
	Mute: no
	Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	Base Volume: 65536 / 100% / 0.00 dB
	Monitor Source: bluez_sink.B8_27_EB_00_82_2D.monitor
	Latency: 0 usec, configured 0 usec
	Flags: HARDWARE DECIBEL_VOLUME LATENCY 
	Properties:
		bluetooth.protocol = "a2dp_sink"
		device.description = "BlueAni-00822d"
		device.string = "B8:27:EB:00:82:2D"
		device.api = "bluez"
		device.class = "sound"
		device.bus = "bluetooth"
		bluez.path = "/org/bluez/hci0/dev_B8_27_EB_00_82_2D"
		bluez.class = "0x0c0000"
		bluez.alias = "BlueAni-00822d"
		device.icon_name = "audio-card-bluetooth"
	Ports:
		unknown-output: Bluetooth Output (priority: 0)
	Active Port: unknown-output
	Formats:
		pcm


Source #1
	State: SUSPENDED
	Name: alsa_input.platform-sound.analog-stereo
	Description: snd_rpi_wsp Analog Stereo
	Driver: module-alsa-card.c
	Sample Specification: s16le 2ch 44100Hz
	Channel Map: front-left,front-right
	Owner Module: 1
	Mute: no
	Volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB
	        balance 0.00
	Base Volume: 65536 / 100% / 0.00 dB
	Monitor of Sink: n/a
	Latency: 0 usec, configured 0 usec
	Flags: HARDWARE DECIBEL_VOLUME LATENCY 
	Properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = ""
		alsa.id = "WM5102 AiFi wm5102-aif1-0"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "1"
		alsa.card_name = "snd_rpi_wsp"
		alsa.long_card_name = "snd_rpi_wsp"
		alsa.driver_name = "snd_soc_rpi_wsp"
		device.bus_path = "platform-sound"
		sysfs.path = "/devices/platform/sound/sound/card1"
		device.string = "hw:1"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "58800"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "snd_rpi_wsp Analog Stereo"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card"
	Ports:
		analog-input: Analog Input (priority: 10000)
	Active Port: analog-input
	Formats:
		pcm


I take it for granted that the bluetooth latency output is already at zero, How can I control this latency.
Comment 1 Raymond 2016-07-05 03:05:46 UTC
44100 Hz at 1ms contain 44.1 frames , how can you get 44.1 frames latency
Comment 2 Raymond 2016-07-05 07:58:01 UTC
https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/bluetooth/module-bluez4-device.c

#define FIXED_LATENCY_PLAYBACK_A2DP (25*PA_USEC_PER_MSEC)
#define FIXED_LATENCY_RECORD_A2DP (25*PA_USEC_PER_MSEC)
#define FIXED_LATENCY_PLAYBACK_HSP (125*PA_USEC_PER_MSEC)
#define FIXED_LATENCY_RECORD_HSP (25*PA_USEC_PER_MSEC)

https://cgit.freedesktop.org/pulseaudio/pulseaudio/tree/src/modules/bluetooth/module-bluez5-device.c


you have to post the pu;seaudio verbose log
Comment 3 Alessandro Ferri 2016-07-05 10:33:27 UTC
Hi Raymond,
I run pulseaudio in system-mode. You can tell me how I can send you the verbose log, that is, what command I have to run?
Comment 4 Raymond 2016-07-05 13:21:54 UTC
	device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "58800"

after the sound card capture one fragment  , do pulseaudio have enough data for one bluetooth packet to play ?
Comment 5 GitLab Migration User 2018-07-30 10:02:02 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/178.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.