Sound only with TV on First

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Sound only with TV on First

Post by OhioYJ »

So I've had an issue now across multiple versions of Mint, across multiple machines. Right now I have two media PCs, one running Mint 19.3, one running 20.1. I have sound usually if I turn the TV on first, then the PC. If I don't have sound a reboot fixes it. If I turn the PC on first I basically never have sound. Both PC's are hooked to the TVs using an HDMI cord, and use this for sound as well.

Both use the Nvidia driver, one is a GTX 1050TI, the other is a GTX 1650 Super.

Is there a command or something I can run to make it reload the audio stuff, or is a full reboot my only option? Is there a way to actually fix this (maybe "hard route" audio to the HDMI out)?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
AndyMH
Level 21
Level 21
Posts: 13585
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Sound only with TV on First

Post by AndyMH »

Have you tried looking in sound settings?
Screenshot from 2021-03-27 13-03-44.png
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Re: Sound only with TV on First

Post by OhioYJ »

AndyMH wrote: Sat Mar 27, 2021 9:04 amHave you tried looking in sound settings?
I did, here are screenshots I just took today, as it's obviously easy to replicate:

No sound:

Image

Options I have with sound:

Image

If it detects the TV properly I have sound. I just don't know how to make it pickup the TV properly without restarting. The problem being is sometimes it doesn't detect the TV even if it was on before the PC. So I have to restart again. Sometimes restarting until I have sound.
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

Instead of the Cinnamon Sound Settings, use PulseAudio Volume Control (pavucontrol) and I'll bet you'll find the Profile for the HDMI card set to Off on the Configuration tab.

We can try to automate this but I'm not positive it'll work. The output of pacmd list-sinks with working sound will help me help you set it up.
User avatar
AndyMH
Level 21
Level 21
Posts: 13585
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Sound only with TV on First

Post by AndyMH »

MrEen wrote: Sat Mar 27, 2021 11:47 am We can try to automate this but I'm not positive it'll work.
Something I've been meaning to get around to (writing a script to set sound to HDMI monitor if connected). Not tried yet:
https://unix.stackexchange.com/question ... -the-shell
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

AndyMH wrote: Sat Mar 27, 2021 1:22 pm
MrEen wrote: Sat Mar 27, 2021 11:47 am We can try to automate this but I'm not positive it'll work.
Something I've been meaning to get around to (writing a script to set sound to HDMI monitor if connected). Not tried yet:
https://unix.stackexchange.com/question ... -the-shell
In the linked case, the HDMI profile is one of the options of the built-in audio card. Changing the profile automatically changes the active sink, as the previous active sink would disappear. But if your outputs are just like that, you should be able to use what was posted there.

In the OP's case, we're looking at 2 separate sound cards, so we need to change the active sink, instead of the active profile. Sometimes PulseAudio fights us trying to set this up in /etc/pulse/default.pa so my guess is what I was planning on trying has about an 85% chance of working. But it all goes out the window if the TV gets turned off after being on for some time. That'll trigger a change that will most likely set the card back to off that will probably require a udev/systemd rule to prevent.
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Re: Sound only with TV on First

Post by OhioYJ »

MrEen wrote: Sat Mar 27, 2021 11:47 am Instead of the Cinnamon Sound Settings, use PulseAudio Volume Control (pavucontrol) and I'll bet you'll find the Profile for the HDMI card set to Off on the Configuration tab.
Ok, somehow I've never noticed in the configuration tab HDA Nvidia Profile is set to Off when I don't have sound. Changing this back to HDMI output makes sound work again without the reboot (obviously as I've turned it back on).
MrEen wrote: Sat Mar 27, 2021 11:47 am We can try to automate this but I'm not positive it'll work. The output of pacmd list-sinks with working sound will help me help you set it up.
Below is the output. However I noticed in your other post you mentioned about the TV turning off. Anytime the TV turns off such as it powering off the "monitor" for power save also triggers this.

Code: Select all

2 sink(s) available.
    index: 0
	name: <alsa_output.pci-0000_00_1f.3.iec958-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE 
	priority: 9038
	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
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 0
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 371.52 ms
	card: 1 <alsa_card.pci-0000_00_1f.3>
	module: 8
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC892 Digital"
		alsa.id = "ALC892 Digital"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "1"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xa4230000 irq 127"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1f.3"
		sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "a348"
		device.form_factor = "internal"
		device.string = "iec958:0"
		device.buffering.buffer_size = "65536"
		device.buffering.fragment_size = "32768"
		device.access_mode = "mmap+timer"
		device.profile.name = "iec958-stereo"
		device.profile.description = "Digital Stereo (IEC958)"
		device.description = "Built-in Audio Digital Stereo (IEC958)"
		alsa.mixer_name = "Realtek ALC892"
		alsa.components = "HDA:10ec0892,1462eb23,00100302"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <iec958-stereo-output>
  * index: 1
	name: <alsa_output.pci-0000_01_00.1.hdmi-surround>
	driver: <module-alsa-card.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE 
	priority: 9030
	volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dB,   rear-left: 65536 / 100% / 0.00 dB,   rear-right: 65536 / 100% / 0.00 dB,   front-center: 65536 / 100% / 0.00 dB,   lfe: 65536 / 100% / 0.00 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 2
	sample spec: s16le 6ch 44100Hz
	channel map: front-left,front-right,rear-left,rear-right,front-center,lfe
	             Surround 5.1
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 123.36 ms
	card: 0 <alsa_card.pci-0000_01_00.1>
	module: 7
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "HDMI 0"
		alsa.id = "HDMI 0"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "3"
		alsa.card = "1"
		alsa.card_name = "HDA NVidia"
		alsa.long_card_name = "HDA NVidia at 0xa4080000 irq 17"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:01:00.1"
		sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1"
		device.bus = "pci"
		device.vendor.id = "10de"
		device.vendor.name = "NVIDIA Corporation"
		device.product.id = "1aeb"
		device.string = "hdmi:1"
		device.buffering.buffer_size = "65280"
		device.buffering.fragment_size = "32640"
		device.access_mode = "mmap+timer"
		device.profile.name = "hdmi-surround"
		device.profile.description = "Digital Surround 5.1 (HDMI)"
		device.description = "HDA NVidia Digital Surround 5.1 (HDMI)"
		alsa.mixer_name = "Nvidia GPU 99 HDMI/DP"
		alsa.components = "HDA:10de0099,38421357,00100100"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		hdmi-output-0: HDMI / DisplayPort (priority 5900, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "video-display"
				device.product.name = "M657-G0
     "
	active port: <hdmi-output-0>
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

Okay, let's try this:

In the terminal run xed admin:///etc/pulse/default.pa and when the file opens add this to the bottom:

Code: Select all

set-card-profile alsa_card.pci-0000_01_00.1 output:hdmi-surround
Now when the TV gets turned back on you should only need to run pulseaudio -k in the terminal to fix the sound. You may not need to do anything, but if there's no sound, that should fix it. If you do need to run that, you might also need to restart any sound playing applications. You can know if sound is working with command:

Code: Select all

aplay /usr/share/sounds/alsa/Front_Center.wav
EDIT: I forgot to mention a pulseaudio -k or reboot is necessary after making the change before it becomes active.
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Re: Sound only with TV on First

Post by OhioYJ »

MrEen wrote: Sun Mar 28, 2021 10:27 amNow when the TV gets turned back on you should only need to run pulseaudio -k in the terminal to fix the sound.
So far I've been testing on the Mint 19.3 machine in the living room, I'm assuming the 20.1 machine in the bedroom will respond the same way. This seems to work fine. I do have to use the pulseaudio -k command. I added this to the startup commands just in case someone forgets to turn on the TV first. I guess I can also add a fix sound shortcut on the desktop. However would there be a way to automate this so when the PC turns the screen saver back off (wakes the TV back up) it runs this automatically?

Or can we just eliminate all other outputs possibly? I can see why in most case you might want a PC to auto detect outputs, but these are media machines that won't have headphones or other outputs used. I just want audio to work reliably.

Either way this is much better than the restarting until it works that I've been doing, thank you so much for your help! It is much appreciated.
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

It gets rather tricky here. When the TV is off, PulseAudio is automatically switching the graphics card's audio Profile to Off for obvious reasons. I would think it'll still do that even if we disable the built-in audio card.

Most likely a systemd script is going to be necessary, but I'd like you try a simple edit first to see if it works.

In the terminal run xed admin:///etc/pulse/default.pa and when the file opens find this section:

Code: Select all

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available
Change it to this:

Code: Select all

### Should be after module-*-restore but before module-*-detect
# load-module module-switch-on-port-available
Save the change then reboot and test the behavior.

I'm hoping that combined with the previous edit we made, this might actually work for you.
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

I'd also like you to test something the next time the sound isn't working. Instead of using pulseaudio -k, try /usr/bin/pasuspender /bin/true first and see if that also works. If it does, sound playing applications won't ever need restarting using that instead. And if the idea in my previous post didn't help, I already have a systemd service ready for you to use that should automate this. Just need to know if we can use the pasuspender or if pulseaudio -k is going to be necessary.
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Re: Sound only with TV on First

Post by OhioYJ »

MrEen wrote: Sun Mar 28, 2021 2:35 pm

Code: Select all

### Should be after module-*-restore but before module-*-detect
# load-module module-switch-on-port-available
I think my problem is more random than I thought. I can reproduce pretty reliably, but I guess I'm not sure what is fixing it exactly. I commented out the line above. Rebooted, Seemed to work fine. Working in my office, my son says there is no sound. Moved to the step below.
MrEen wrote: Sun Mar 28, 2021 3:25 pm I'd also like you to test something the next time the sound isn't working. Instead of using pulseaudio -k, try /usr/bin/pasuspender /bin/true first and see if that also works.
user/bin/.... command did not give me sound. Neither did the pulseaudio -k command this time? This time I did have the correct options in the sound settings at least though, so I was able to just select HDMI, then an output profile

(Just an example image, this is from another PC, my main desktop)

Image
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

Okay, I have one other idea, then I'm probably stuck. Let's see the output of pacmd list-sinks with sound running through the TV please. We'll try one more edit to default.pa and maybe that'll get us over the finish line.
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Re: Sound only with TV on First

Post by OhioYJ »

MrEen wrote: Thu Apr 01, 2021 7:08 pm Okay, I have one other idea, then I'm probably stuck. Let's see the output of pacmd list-sinks with sound running through the TV please. We'll try one more edit to default.pa and maybe that'll get us over the finish line.
This is what I get with sound playing:

Code: Select all

ohioyj@livingroompc:~$ pacmd list-sinks
2 sink(s) available.
    index: 1
	name: <alsa_output.pci-0000_00_1f.3.iec958-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: SUSPENDED
	suspend cause: IDLE 
	priority: 9038
	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
	volume steps: 65537
	muted: no
	current latency: 0.00 ms
	max request: 0 KiB
	max rewind: 0 KiB
	monitor source: 1
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 0
	linked by: 0
	configured latency: 0.00 ms; range is 0.50 .. 341.33 ms
	card: 1 <alsa_card.pci-0000_00_1f.3>
	module: 7
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "ALC892 Digital"
		alsa.id = "ALC892 Digital"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "1"
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xa4230000 irq 127"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1f.3"
		sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "a348"
		device.form_factor = "internal"
		device.string = "iec958:0"
		device.buffering.buffer_size = "65536"
		device.buffering.fragment_size = "32768"
		device.access_mode = "mmap+timer"
		device.profile.name = "iec958-stereo"
		device.profile.description = "Digital Stereo (IEC958)"
		device.description = "Built-in Audio Digital Stereo (IEC958)"
		alsa.mixer_name = "Realtek ALC892"
		alsa.components = "HDA:10ec0892,1462eb23,00100302"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		iec958-stereo-output: Digital Output (S/PDIF) (priority 0, latency offset 0 usec, available: unknown)
			properties:
				
	active port: <iec958-stereo-output>
  * index: 2
	name: <alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1>
	driver: <module-alsa-card.c>
	flags: HARDWARE DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: RUNNING
	suspend cause: 
	priority: 9030
	volume: front-left: 29500 /  45% / -20.80 dB,   front-right: 29500 /  45% / -20.80 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 58.39 ms
	max request: 14 KiB
	max rewind: 64 KiB
	monitor source: 3
	sample spec: s16le 2ch 48000Hz
	channel map: front-left,front-right
	             Stereo
	used by: 1
	linked by: 1
	configured latency: 75.00 ms; range is 0.50 .. 341.33 ms
	card: 0 <alsa_card.pci-0000_01_00.1>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "HDMI 1"
		alsa.id = "HDMI 1"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "7"
		alsa.card = "1"
		alsa.card_name = "HDA NVidia"
		alsa.long_card_name = "HDA NVidia at 0xa4080000 irq 17"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:01:00.1"
		sysfs.path = "/devices/pci0000:00/0000:00:01.0/0000:01:00.1/sound/card1"
		device.bus = "pci"
		device.vendor.id = "10de"
		device.vendor.name = "NVIDIA Corporation"
		device.product.id = "1aeb"
		device.string = "hdmi:1,1"
		device.buffering.buffer_size = "65536"
		device.buffering.fragment_size = "32768"
		device.access_mode = "mmap+timer"
		device.profile.name = "hdmi-stereo-extra1"
		device.profile.description = "Digital Stereo (HDMI 2)"
		device.description = "HDA NVidia Digital Stereo (HDMI 2)"
		alsa.mixer_name = "Nvidia GPU 99 HDMI/DP"
		alsa.components = "HDA:10de0099,38421357,00100100"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		hdmi-output-1: HDMI / DisplayPort 2 (priority 5800, latency offset 0 usec, available: yes)
			properties:
				device.icon_name = "video-display"
				device.product.name = "M657-G0
     "
	active port: <hdmi-output-1>
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

I'm not even sure why I didn't already add this earlier, but add this to the bottom of /etc/pulse/default.pa under the other line you added:

Code: Select all

set-default-sink alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1
Reboot after that and test again.
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Re: Sound only with TV on First

Post by OhioYJ »

MrEen wrote: Sat Apr 10, 2021 11:53 am I'm not even sure why I didn't already add this earlier, but add this to the bottom of /etc/pulse/default.pa under the other line you added:

Code: Select all

set-default-sink alsa_output.pci-0000_01_00.1.hdmi-stereo-extra1
Reboot after that and test again.
Unfortunately that did not work either.

I tried disabling the onboard sound altogether in the BIOS hoping with only one output Mint would default to that and leave that on. Unfortunately it doesn't do that either... With onboard sound disabled it sees the HDMI output on the video card as the only output but then doesn't use it automatically. There is no output profile on by default (not sure if that is the issue or not).

I had one other idea as well. I know my gaming desktop had an issue originally where the hardware wasn't supported very well in Linux and I ended up having to unplug the front audio header to have the audio routed correctly. Perhaps I try disabling the onboard sound and unplugging the front audio header as well. This would leave no option other than the GPU?
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

Well, PulseAudio still has a way around what you're thinking. If it believes there are no outputs at all available, it will create a Dummy Output (or null sink) by default.

I believe what's happening here is simply a timing issue. PulseAudio is ready before the graphics card has announced it has an audio output available, and that's why I had you try to set the card profile a while back. The most recent thing was setting the same card to be the default sink. But again, if PulseAudio hasn't heard from the graphics card yet, it's going to stymie our efforts.

You can certainly try what you're thinking about attempting, and it could very well work. I've seen much stranger things get solved with weirder fixes that I felt shouldn't have helped at all.

At this point, I have no more ideas on the subject. Be aware that a PulseAudio or kernel update could magically fix this whole mess in one shot. Booting to an older kernel that is still installed might also remedy this. Just throwing that out there, but not counting on it helping.
OhioYJ
Level 1
Level 1
Posts: 36
Joined: Sun Jul 01, 2012 3:14 pm

Re: Sound only with TV on First

Post by OhioYJ »

MrEen wrote: Mon Apr 12, 2021 9:03 pmI believe what's happening here is simply a timing issue. PulseAudio is ready before the graphics card has announced it has an audio output available, and that's why I had you try to set the card profile a while back. The most recent thing was setting the same card to be the default sink.
This would make sense, as there are times when I open it up and all the sudden it populates by itself. Or I'll choose 5.1 or 7.1 to just put anything in there, and it'll "correct" it.

Again I appreciate all your help. I'm at least a little further than before. I'm not restarting until it works any more. I'm going to keep messing with it and see what I can find.
User avatar
MrEen
Level 23
Level 23
Posts: 18345
Joined: Mon Jun 12, 2017 8:39 pm

Re: Sound only with TV on First

Post by MrEen »

Sounds good OhioYJ.

Good luck with it. And just FYI, I somewhat expect issues like this to be a thing of the past when Mint 21 comes out later next year. Almost everything sound related will be significantly updated from where it is now when that arrives.
Locked

Return to “Sound”