2024-12-12, 01:24
Description
Kodi allows for volume changes through CEC commands. The target of these commands is hard-coded to
There is even a setting
Context
I am using ARC to route audio from my HTPC (RPi 5 with LibreELEC 12) through the TV to an AV receiver. In order to save energy I sometimes turn off the receiver, so audio is output by the TV.
When the receiver is on, I can change volume with my HTPC's remote using Kodi's CEC capabilities. However, if the receiver is off, this does not work anymore. I instead have to write custom CEC commands with cec-ctl and map them to buttons of my remote (or use the TV's remote).
Possible Implementation
The setting
Kodi allows for volume changes through CEC commands. The target of these commands is hard-coded to
CECDEVICE_AUDIOSYSTEM
, e.g. here in PeripheralCecAdapter.cpp
In case the HTPC is connected to a TV and there is no audio system available, the volume cannot be changed using this approach.There is even a setting
connected_device
in the peripherals section, where the user can define the device the HTPC is connected to. However, this setting is not used for volume commands.Code:
<setting id="connected_device" value="36037"/>
Context
I am using ARC to route audio from my HTPC (RPi 5 with LibreELEC 12) through the TV to an AV receiver. In order to save energy I sometimes turn off the receiver, so audio is output by the TV.
When the receiver is on, I can change volume with my HTPC's remote using Kodi's CEC capabilities. However, if the receiver is off, this does not work anymore. I instead have to write custom CEC commands with cec-ctl and map them to buttons of my remote (or use the TV's remote).
Possible Implementation
The setting
connected_device
is already available in the variable m_configuration.baseDevice
of PeripheralCecAdapter.cpp
, so it can be used directly.cpp:switch (pendingVolumeChange)
{
case VOLUME_CHANGE_UP:
m_cecAdapter->SendKeypress(m_configuration.baseDevice, CEC_USER_CONTROL_CODE_VOLUME_UP, false);
break;
case VOLUME_CHANGE_DOWN:
m_cecAdapter->SendKeypress(m_configuration.baseDevice, CEC_USER_CONTROL_CODE_VOLUME_DOWN, false);
break;
case VOLUME_CHANGE_MUTE:
m_cecAdapter->SendKeypress(m_configuration.baseDevice, CEC_USER_CONTROL_CODE_MUTE, false);
{
std::unique_lock<CCriticalSection> lock(m_critSection);
m_bIsMuted = !m_bIsMuted;
}
break;
case VOLUME_CHANGE_NONE:
if (bSendRelease)
m_cecAdapter->SendKeyRelease(m_configuration.baseDevice, false);
break;
}