You are not logged in.

#1 2017-04-11 03:41:56

rogervn
Member
Registered: 2017-04-09
Posts: 21

[SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Hello guys, I'm having some trouble with pulseaudio and my HDMI TV right now. Every time I start a sound effect it cuts the first second and then it starts playing perfectly.

It happens in youtube, chrome, and also while testing the sound channels. If I start the test, I can hear only the "... left" on the first time and then the following tries are complete until I close the window and try again.

This does not happens if I have pavucontrol open monitoring the output sound. What could be the problem? I tried some specific configuraitons on the wiki, but no success.

Last edited by rogervn (2017-04-13 03:07:09)

Offline

#2 2017-04-11 04:36:27

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

https://www.freedesktop.org/wiki/Softwa … #index63h3

HDMI sound seems have a high latency on getting started, so to work around it you need to disable module-suspend-on-idle (comment out the line in default.pa)

Offline

#3 2017-04-11 23:28:40

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

tom.ty89 wrote:

https://www.freedesktop.org/wiki/Softwa … #index63h3

HDMI sound seems have a high latency on getting started, so to work around it you need to disable module-suspend-on-idle (comment out the line in default.pa)

Just did that. It didn't work, still getting the delays on new streams after some time.

Offline

#4 2017-04-11 23:32:55

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Have you restared pulseaudio and made sure the module is not loaded anymore?

pacmd list-modules

Offline

#5 2017-04-11 23:50:03

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

tom.ty89 wrote:

Have you restared pulseaudio and made sure the module is not loaded anymore?

pacmd list-modules

Yup, even rebooted the whole system just in case.

Output for command:

22 module(s) loaded.
    index: 0
	name: <module-device-restore>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Automatically restore the volume/mute state of devices"
		module.version = "10.0"
    index: 1
	name: <module-stream-restore>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Automatically restore the volume/mute/device state of streams"
		module.version = "10.0"
    index: 2
	name: <module-card-restore>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Automatically restore profile of cards"
		module.version = "10.0"
    index: 3
	name: <module-augment-properties>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Augment the property sets of streams with additional static information"
		module.version = "10.0"
    index: 4
	name: <module-switch-on-port-available>
	argument: <>
	used: -1
	load once: no
	properties:
		
    index: 5
	name: <module-udev-detect>
	argument: <tsched=0>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Detect available audio hardware and load matching drivers"
		module.version = "10.0"
    index: 6
	name: <module-alsa-card>
	argument: <device_id="0" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=no fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1">
	used: 0
	load once: no
	properties:
		module.author = "Lennart Poettering"
		module.description = "ALSA Card"
		module.version = "10.0"
    index: 7
	name: <module-esound-protocol-unix>
	argument: <>
	used: -1
	load once: no
	properties:
		module.author = "Lennart Poettering"
		module.description = "ESOUND protocol (UNIX sockets)"
		module.version = "10.0"
    index: 8
	name: <module-native-protocol-unix>
	argument: <>
	used: -1
	load once: no
	properties:
		module.author = "Lennart Poettering"
		module.description = "Native protocol (UNIX sockets)"
		module.version = "10.0"
    index: 9
	name: <module-default-device-restore>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Automatically restore the default sink and source"
		module.version = "10.0"
    index: 10
	name: <module-rescue-streams>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "When a sink/source is removed, try to move its streams to the default sink/source"
		module.version = "10.0"
    index: 11
	name: <module-always-sink>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Colin Guthrie"
		module.description = "Sempre manter pelo menos um destino carregado mesmo se for nulo"
		module.version = "10.0"
    index: 12
	name: <module-intended-roles>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Automatically set device of streams based on intended roles of devices"
		module.version = "10.0"
    index: 13
	name: <module-console-kit>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Create a client for each ConsoleKit session of this user"
		module.version = "10.0"
    index: 14
	name: <module-systemd-login>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Create a client for each login session of this user"
		module.version = "10.0"
    index: 15
	name: <module-position-event-sounds>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Position event sounds between L and R depending on the position on screen of the widget triggering them."
		module.version = "10.0"
    index: 16
	name: <module-role-cork>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Lennart Poettering"
		module.description = "Mute & cork streams with certain roles while others exist"
		module.version = "10.0"
    index: 17
	name: <module-filter-heuristics>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Colin Guthrie"
		module.description = "Detect when various filters are desirable"
		module.version = "10.0"
    index: 18
	name: <module-filter-apply>
	argument: <>
	used: -1
	load once: yes
	properties:
		module.author = "Colin Guthrie"
		module.description = "Load filter sinks automatically when needed"
		module.version = "10.0"
    index: 19
	name: <module-x11-publish>
	argument: <display=:0>
	used: -1
	load once: no
	properties:
		module.author = "Lennart Poettering"
		module.description = "X11 credential publisher"
		module.version = "10.0"
    index: 20
	name: <module-x11-xsmp>
	argument: <display=:0 session_manager=local/ibanez:@/tmp/.ICE-unix/595,unix/ibanez:/tmp/.ICE-unix/595>
	used: -1
	load once: no
	properties:
		module.author = "Lennart Poettering"
		module.description = "X11 session management"
		module.version = "10.0"
    index: 21
	name: <module-cli-protocol-unix>
	argument: <>
	used: -1
	load once: no
	properties:
		module.author = "Lennart Poettering"
		module.description = "Command line interface protocol (UNIX sockets)"
		module.version = "10.0"

Offline

#6 2017-04-12 00:08:47

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Not sure about your case then. You can see if HDMI sound still get closed after certain time:

watch grep . /proc/asound/card*/pcm*p/sub*/hw_params

Offline

#7 2017-04-12 01:25:34

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

tom.ty89 wrote:

Not sure about your case then. You can see if HDMI sound still get closed after certain time:

watch grep . /proc/asound/card*/pcm*p/sub*/hw_params

Actually, it didn't, but I think we've progressed a little.

Before trying, the output looked like that:

/proc/asound/card0/pcm0p/sub0/hw_params:access: MMAP_INTERLEAVED
/proc/asound/card0/pcm0p/sub0/hw_params:format: S16_LE
/proc/asound/card0/pcm0p/sub0/hw_params:subformat: STD
/proc/asound/card0/pcm0p/sub0/hw_params:channels: 2
/proc/asound/card0/pcm0p/sub0/hw_params:rate: 44100 (44100/1)
/proc/asound/card0/pcm0p/sub0/hw_params:period_size: 1102
/proc/asound/card0/pcm0p/sub0/hw_params:buffer_size: 4408
/proc/asound/card0/pcm1p/sub0/hw_params:closed
/proc/asound/card0/pcm3p/sub0/hw_params:closed
/proc/asound/card0/pcm7p/sub0/hw_params:closed

After the test and reproducing the error, the rate changed:

/proc/asound/card0/pcm0p/sub0/hw_params:closed
/proc/asound/card0/pcm1p/sub0/hw_params:closed
/proc/asound/card0/pcm3p/sub0/hw_params:access: MMAP_INTERLEAVED
/proc/asound/card0/pcm3p/sub0/hw_params:format: S16_LE
/proc/asound/card0/pcm3p/sub0/hw_params:subformat: STD
/proc/asound/card0/pcm3p/sub0/hw_params:channels: 2
/proc/asound/card0/pcm3p/sub0/hw_params:rate: 48000 (48000/1)
/proc/asound/card0/pcm3p/sub0/hw_params:period_size: 1102
/proc/asound/card0/pcm3p/sub0/hw_params:buffer_size: 4408
/proc/asound/card0/pcm7p/sub0/hw_params:closed

And stayed that way, without reproducing the error again. But if I get a beep from the gnome-terminal, it goes bach to 44100 and then if I try again, it doens't reproduce while changing to 48000.

It seems to happen with everytime it changes the sampling rate and then if I repeat sounds of the same sampling rate while it doesn't change, then the problem is gone. But is back everytime I reproduce a sample from another rate.

Last edited by rogervn (2017-04-12 01:26:36)

Offline

#8 2017-04-12 01:38:55

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Make sense I guess, because when it changes sampling rate the device has to be "restarted". You may want to pick either 44100 or 48000 (or some other that is supported by your TV) that most sources you played are at, then set both default-sample-rate and alternate-sample-rate in daemon.conf to it. Remember to remove the semi-colon to uncomment the lines.

Last edited by tom.ty89 (2017-04-12 01:39:48)

Offline

#9 2017-04-12 03:04:01

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Wait a minute. Something's not right here. The first quote you have the opened device is pcm0p, which is probably analog sound. The second quote you have the opened device is pcm3p, which is probably the HDMI sound.

If this isn't some sort if mispaste/miscapture, it may have something to do with module-switch-on-port-available...

Paste `aplay -l` output (aplay is provided in alsa-utils). Also check with `pacmd list-sinks` to see if the active port changes before/after the issue occurs.

Last edited by tom.ty89 (2017-04-12 03:11:55)

Offline

#10 2017-04-12 03:53:13

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Maybe the output was outdated and was before I changed the audio from the headphones to the HDMI....

aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

pacmd list-sinks

1 sink(s) available.
  * index: 2
	name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: IDLE
	suspend cause: 
	priority: 9959
	volume: front-left: 52858 /  81% / -5,60 dB,   front-right: 52858 /  81% / -5,60 dB
	        balance 0,00
	base volume: 65536 / 100% / 0,00 dB
	volume steps: 65537
	muted: no
	current latency: 2000,11 ms
	max request: 344 KiB
	max rewind: 344 KiB
	monitor source: 3
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Estéreo
	used by: 0
	linked by: 0
	configured latency: 2000,00 ms; range is 0,50 .. 2000,00 ms
	card: 0 <alsa_card.pci-0000_00_1b.0>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC892 Analog"
		alsa.id = "ALC892 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xf6b10000 irq 31"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1b.0"
		sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "1e20"
		device.product.name = "7 Series/C216 Chipset Family High Definition Audio Controller"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "352800"
		device.buffering.fragment_size = "176400"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Estéreo analógico"
		device.description = "Áudio interno Estéreo analógico"
		alsa.mixer_name = "Realtek ALC892"
		alsa.components = "HDA:10ec0892,15585105,00100302 HDA:80862806,80860101,00100000"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-lineout: Saída de linha (priority 9900, latency offset 0 usec, available: no)
			properties:
				
		analog-output-speaker: Alto-falantes (priority 10000, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Fones de ouvidos (priority 9000, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-headphones>

I just tried again and the device stays on pcm3p, but if I change the output via the Sound Input & Output Device Chooser from Gnome, it stays with the old ones until I play a sound. It doesn't do that if I change via the configuration app, but both ways the delay with the different sampling rates continue.

Last edited by rogervn (2017-04-12 03:56:58)

Offline

#11 2017-04-12 04:19:51

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

And now things got a little weird. I've installed pavucontrol to try to move things around, and while pavucontrol is opened, every sound I try maxes up at 44100. If I close it, again I find the issue and sounds get to 48000.

This delay doesn't happens in the headphones nor the laptop speakers, but they too change sampling rates, but not issuing any problem whatsoever.

Offline

#12 2017-04-12 04:35:39

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Hmm, it seems something keeps changing the card profile back and forth from analog and hdmi sound profile. You can monitor it with:

watch 'pacmd list-sinks | grep active\ port'

or

watch 'pacmd list-cards | grep active\ profile'

They pretty much monitors the same thing in your case, so either one would do.

Not sure what exactly does it though. Could be module-switch-on-available-port, or pavucontrol or gnome-control-center doing something silly.

As for whether the rate change actually matters here, I think we need to make sure that the active card profile / sink port remains steady as expected first. Whether alternate rate would actually cause the same issue is in doubt, as it may not even be actually in effect due to the fact that your TV may only support only 48kHz audio.

EDIT:

watch pactl list short sinks

Should be able to determine the active card profile / sink port from the sink name, and it prints the sample spec as well.

Last edited by tom.ty89 (2017-04-12 04:52:43)

Offline

#13 2017-04-13 01:39:06

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

tom.ty89 wrote:

Hmm, it seems something keeps changing the card profile back and forth from analog and hdmi sound profile. You can monitor it with:

watch 'pacmd list-sinks | grep active\ port'

or

watch 'pacmd list-cards | grep active\ profile'

They pretty much monitors the same thing in your case, so either one would do.

Not sure what exactly does it though. Could be module-switch-on-available-port, or pavucontrol or gnome-control-center doing something silly.

As for whether the rate change actually matters here, I think we need to make sure that the active card profile / sink port remains steady as expected first. Whether alternate rate would actually cause the same issue is in doubt, as it may not even be actually in effect due to the fact that your TV may only support only 48kHz audio.

EDIT:

watch pactl list short sinks

Should be able to determine the active card profile / sink port from the sink name, and it prints the sample spec as well.


Yeah, it seems to keep it steady. Doing the last command you suggested:

Before playing 48khz:

0       alsa_output.pci-0000_00_1b.0.hdmi-stereo        module-alsa-card.c
s16le 2ch 44100Hz       IDLE

And after

0       alsa_output.pci-0000_00_1b.0.hdmi-stereo        module-alsa-card.c
s16le 2ch 48000Hz       IDLE 

The behaviour I watched while loading pavucontrol may be due to the mixer monitoring it does. I think..

Offline

#14 2017-04-13 01:42:39

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

In that case see if disabling alternate sample rate help as I mentioned (setting both default and alternate to a same value)

Offline

#15 2017-04-13 02:11:18

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

tom.ty89 wrote:

In that case see if disabling alternate sample rate help as I mentioned (setting both default and alternate to a same value)

OK, just set both to 48000 and the problem is gone. Also tried backtracking all the other changes and indeed suspend-on-idle also reproduces the problem, so, for it to be fixed I have to set both the alternate and default sampling rates to the same rate and also disable the suspend-on-idle module.

Thanks a lot! Never imagined to go through so much, I even learned a lot.

Before I rename the topic to SOLVED, do you think that there are any side-effects to this configuration other than spending a little more power due to pulseaudio not suspending the module and incompatibility to any device which doesn't support 48khz that I might plug in?

Offline

#16 2017-04-13 02:54:52

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

I don't suppose disabling module-suspend-on-idle would cause any problem. The only thing I can think of is, when it is enabled, you can still grab the default device with things like jack or mpv --ao alsa:device=[hw:N,M], as long as nothing is playing through pulse, but with it disable, the default device is persistently grabbed by pulse, you will need to either stop pulse or at least make pulse uses another device as default first.

And you don't need to worry too much about the support on the sample rate either. AFAIK, the default-sample-rate and alternate-sample-rate are both used to indicate preference only. If a hardware does not support any of them, pulse will set the sample rate to one that it supports (not exactly sure which will be picked when there are multiple though). That said, assuming the hardware/driver exposes its capability properly.

The purpose of alternate sample rate is to guarantee you can enjoy optimal audio quality more often. For example, assuming the default is used, and your hardware support both 44100 and 48000, then when the first new/only stream pulse got is 44100/88200/176400, streams will be (re)sampled to 44100; and when the stream is 48000/96000/192000, streams will be (re)sampled to 48000. So if you don't have streams of different "branches" of sample rates playing simultaneously, it is guaranteed that all of them will _at most_ be up/downsampled "symmetrically".

Obviously it's merely an optimizing strategy, and may not always make a point / give you best result anyway. So long as you set the sample rate that most your sources (or sources where you value audio quality most) are in (e.g. 44100 if you mostly plays CDDA), with the consideration of what your hardware supports, you will be avoiding unnecssary resampling, symmetrical or not, and hence get best audio quality and save CPU power for most of the time.

P.S. Not to mention that the audible effect of resampling are often trivial/unnoticeable to most people (or even subjective/psychological).

Last edited by tom.ty89 (2017-04-13 03:02:32)

Offline

#17 2017-04-13 03:04:33

rogervn
Member
Registered: 2017-04-09
Posts: 21

Re: [SOLVED] HDMI and pulseaudio, sound effects cuts 1s when starting

Thanks a lot!

Offline

Board footer

Powered by FluxBB