batocera-linux / batocera.linux

batocera.linux
https://batocera.org
Other
2.03k stars 522 forks source link

[V36]: HDMI audio device not being released for Kodi on Batocera bootup #7335

Open Grandma-Betty opened 2 years ago

Grandma-Betty commented 2 years ago

In addition to the ticket I alredy opened here... https://github.com/batocera-linux/batocera.linux/issues/6905 ...for V36 it is currently not even possible to select the according HDMI #3 audio output device anymore.

In summary, here's the difference from V35 to V36:

In V35 it is possible to select the HDMI #3 audio output device if Kodi is booted automatically on Batocera bootup. Then, as soon as switching from Kodi to ES and then back to Kodi, the HDMI #3 audio output device disappears completely as the device seems not to get released by ES.

In V36, the HDMI #3 audio output device is not selectable anymore, not even when booting directly into Kodi on Batocera bootup. This indicates that ES does preserve the audio device and not releasing it for Kodi already on Batocera bootup.

Again: Please have a look on the response from the PipeWire dev to my initial ticket. His explanation may be the main issue for HDMI audio issues (and other audio issues) on Batocera: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2742

Thanks.

dmanlfc commented 2 years ago

@nadenislamarre

crcerror commented 2 years ago

This roots back a whole year - see https://github.com/batocera-linux/batocera.linux/issues/4709

Even the pipeware dev said:

It might also be some race condition where Kodi tries to use the HDMI device before it's been released by the other software upon switching back but it should still be solvable by making sure that the raw devices are not opened in the first place.

Grandma-Betty commented 2 years ago

This roots back a whole year - see #4709

That's the thing. I don't know what more to investigate, I did all I can to solve this now. @dmanlfc really tried to help back then but no reaction from @nadenislamarre ever since.

ismay commented 1 year ago

Same here. I’ve had these issues as well, ever since batocera switched to pipewire. Didn’t have them before, with the exact same hardware. Most likely this is affecting a ton of other people.

I can understand that there’s maybe no bandwidth to work on this, that’s understandable. But the issue itself should be acknowledged at least. @Grandma-Betty has been working tirelessly to promote this for over a year now, time to acknowledge that effort and take this bug seriously.

nadenislamarre commented 1 year ago

yes. too many subjects to work on. i must make choices.

ismay commented 1 year ago

yes. too many subjects to work on. i must make choices.

No worries, I completely understand. We can help of course. Just making sure that the issue doesn't go unnoticed.

dmanlfc commented 1 year ago

@Grandma-Betty please test - https://drive.google.com/drive/folders/1_bqmR7CoZ78i7DolYt5b-RRqB5c-LPyN?usp=share_link

Grandma-Betty commented 1 year ago

Hmm...the issue seems to be gone in my case on the latest beta from today. @dmanlfc Sorry, I somehow missed your message, so I guess your changes are already in today's beta? As I am going along with this issue since over a year now, could you please kindly tell me what potentailly exactly solved the issue? The link to the commit you made would be nice 👍 I never had an issue with Batocera crucifying me that hard for such a long time. @ismay Can you also confirm the issue is solved in your case?

dmanlfc commented 1 year ago

It's multiple commis but we are now using latest kernel drivers with sound open firmware & an updated alsa stack.

Grandma-Betty commented 1 year ago

Unfortunately I have to report the issue is NOT resolved. My fault. Somehow after updateing from V35 to V36 beta to test if this issue has been resolved, the Kodi audio output device's HDMI port of my AV Preceiver changed from HDMI#3 to HDMI#0. I was not aware of this until now, so the tests I did yesterday are obsolete. Strange enough that I did receive sound output on HDMI#3 anyway, even there is no device connected to HDMI#3.

So in summary the issue still remains the same as before. The only difference is that it's now HDMI#0 instead of HDMI#3. Which is clearly because of the sound driver updates. Sorry guys, I was too quick with my previous response.

ismay commented 1 year ago

@ismay Can you also confirm the issue is solved in your case?

No idea tbh, I'm using recalbox and have no intention of going back to batocera, it’s just been too much of a hassle. Good luck though!

Grandma-Betty commented 1 year ago

@dmanlfc Just because I'm curious: Is this issue still work in progress? If not, I'll close the ticket.

To me it does not matter anymore as for media center I switched now to a Raspberry Pi 4 with LibreELEC on it which works flawlessly and makes even more sense now that I have a new system with lots of gaming horsepower. To turn on a high end PC just for watching TV seems a bit overkill to me anyway ;-)

taleteller commented 11 months ago

I stumbled upon this trying to get HDMI passthrough for my AVR working with kodi, noticing PipeWire blocking the required HDMI output. Since there seems no solution anywhere on the horizon, i "solved" it the most bruteforce way possible. I modified /usr/bin/batocera-kodilauncher to stop PipeWire while running.

(
    /etc/init.d/S06audio stop
    LD_LIBRARY_PATH="/usr/lib/mysql" /usr/lib/kodi/kodi.bin --standalone -fs
    /etc/init.d/S06audio start
    /usr/bin/batocera-audio setSystemVolume 100
    echo "Kodi process ended." >&2
    echo "EXIT" >> /var/run/kodi.msg # in case of normal, but mainly anormal end of kodi, send a message to signal the end
)&

Before kodi.bin takes over I stop the audio service and start it right afterwards. That way I can change kodi audio settings independent from Batocera. This got my passtrough working. Additionally I have to reset the volume back to 100, since per default it loves to set it to 40.

Because this is a hard change to the filesystem a batocera-safe-overlay is required and the change has to be reapplied after updates. This is not a solution per se, but it helps for now.

dmanlfc commented 11 months ago

I already provided that workaround on Discord :-)

taleteller commented 11 months ago

@dmanlfc Nice to know you came to the same conclusion before me! However I don't have discord, and would not have found it there.

Probably it would be useful to introduce a Switch to disable PipeWire in the Kodi settings page, and have the launcher implementing this setting.

Grandma-Betty commented 11 months ago

I mean who's gonna search actively for old issue solutions on Discord? Yes, you can ask the community there but generally, GitHub/Wiki is the place to be for documenting things like that.

dmanlfc commented 11 months ago

It's not an elegant solution & potentially can cause other issues as you well know @Grandma-Betty as I gave you the said fix months ago!

taleteller commented 11 months ago

I doubt @Grandma-Betty has problems with the solution as is but its documentation outside the ticket. For myself I had to discover this workaround on my own because this ticket stalled without a hint.

mousemat86 commented 11 months ago

I stumbled upon this trying to get HDMI passthrough for my AVR working with kodi, noticing PipeWire blocking the required HDMI output. Since there seems no solution anywhere on the horizon, i "solved" it the most bruteforce way possible. I modified /usr/bin/batocera-kodilauncher to stop PipeWire while running.

(
    /etc/init.d/S06audio stop
    LD_LIBRARY_PATH="/usr/lib/mysql" /usr/lib/kodi/kodi.bin --standalone -fs
    /etc/init.d/S06audio start
    /usr/bin/batocera-audio setSystemVolume 100
    echo "Kodi process ended." >&2
    echo "EXIT" >> /var/run/kodi.msg # in case of normal, but mainly anormal end of kodi, send a message to signal the end
)&

Before kodi.bin takes over I stop the audio service and start it right afterwards. That way I can change kodi audio settings independent from Batocera. This got my passtrough working. Additionally I have to reset the volume back to 100, since per default it loves to set it to 40.

Because this is a hard change to the filesystem a batocera-safe-overlay is required and the change has to be reapplied after updates. This is not a solution per se, but it helps for now.

Hi @taleteller could

I stumbled upon this trying to get HDMI passthrough for my AVR working with kodi, noticing PipeWire blocking the required HDMI output. Since there seems no solution anywhere on the horizon, i "solved" it the most bruteforce way possible. I modified /usr/bin/batocera-kodilauncher to stop PipeWire while running.

(
    /etc/init.d/S06audio stop
    LD_LIBRARY_PATH="/usr/lib/mysql" /usr/lib/kodi/kodi.bin --standalone -fs
    /etc/init.d/S06audio start
    /usr/bin/batocera-audio setSystemVolume 100
    echo "Kodi process ended." >&2
    echo "EXIT" >> /var/run/kodi.msg # in case of normal, but mainly anormal end of kodi, send a message to signal the end
)&

Before kodi.bin takes over I stop the audio service and start it right afterwards. That way I can change kodi audio settings independent from Batocera. This got my passtrough working. Additionally I have to reset the volume back to 100, since per default it loves to set it to 40.

Because this is a hard change to the filesystem a batocera-safe-overlay is required and the change has to be reapplied after updates. This is not a solution per se, but it helps for now.

just wanted to say thanks for this. I lost a day or so trying to figure out why my soundcard wasn't available. It's now working with this hack!

mamiro-ms commented 11 months ago

I had the same issue of missing audio passthrough port for HDMI in Kodi running at Batocera v38 and could finally fix it by adding a delay of minimum 4 seconds via "sleep" command to the "/usr/bin/batocera-kodi" script before the "emulatorlauncher" is accessed by this script...

`#!/bin/sh

script to be called from es to call configgen + kodi

sleep 5 emulatorlauncher -system kodi -rom '' "$@"`

However, I recognized that changes in "/usr/bin/batocera-kodi" are not persistent and will be revert after reboot of Batocera. Therefore I implement as workaround a copy of "/usr/bin/batocera-kodi" to the "/userdata/roms/ports/", renamed the copied file to "Kodi.sh" an run Kodi for now as a "Ports-Game". ;-)

Might it be possible to update the "/usr/bin/batocera-kodi" script with such an delay command in regular Batocera releases as I assume that will fix many audio issues for many users?

dmanlfc commented 11 months ago

I had the same issue of missing audio passthrough port for HDMI in Kodi running at Batocera v38 and could finally fix it by adding a delay of minimum 4 seconds via "sleep" command to the "/usr/bin/batocera-kodi" script before the "emulatorlauncher" is accessed by this script...

`#!/bin/sh

script to be called from es to call configgen + kodi

sleep 5 emulatorlauncher -system kodi -rom '' "$@"`

However, I recognized that changes in "/usr/bin/batocera-kodi" are not persistent and will be revert after reboot of Batocera. Therefore I implement as workaround a copy of "/usr/bin/batocera-kodi" to the "/userdata/roms/ports/", renamed the copied file to "Kodi.sh" an run Kodi for now as a "Ports-Game". ;-)

Might it be possible to update the "/usr/bin/batocera-kodi" script with such an delay command in regular Batocera releases as I assume that will fix many audio issues for many users?

this could be a possibility... let me investigate

giancarloerra commented 7 months ago

After losing hours, this solved my problem as well while trying to play surround sound from Kodi.

The HDMI was not available in Kodi if used as well in Batocera settings.

Adding simply the 5-second delay (and saving with the overlay), SOLVED!

I think the script should definitely be updated, or at least add about this in the wiki.