Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of mute audio differs between C & C++ library #663

Open
kira-bruneau opened this issue Oct 5, 2024 · 0 comments
Open

Implementation of mute audio differs between C & C++ library #663

kira-bruneau opened this issue Oct 5, 2024 · 0 comments

Comments

@kira-bruneau
Copy link

kira-bruneau commented Oct 5, 2024

Hi! I noticed that when trying to run libcec_mute_audio through the C library, it wouldn't work on my TV (I don't have an audio system).

It looks like SendMuteAudio is designed to send key presses if there isn't an audio system, but the C library doesn't use it:

C: src/libcec/LibCECC.cpp:

#if CEC_LIB_VERSION_MAJOR >= 5
int libcec_mute_audio(libcec_connection_t connection, int UNUSED(bSendRelease))
{
  ICECAdapter* adapter = static_cast<ICECAdapter*>(connection);
  return adapter ?
      adapter->AudioToggleMute() :
      -1;
}
#endif

C++: src/libcec/LibCEC.cpp:

#if CEC_LIB_VERSION_MAJOR >= 5
uint8_t CLibCEC::MuteAudio(void)
{
  return !!m_client ?
    m_client->SendMuteAudio() :
    (uint8_t)CEC_AUDIO_VOLUME_STATUS_UNKNOWN;
}
#endif

I'm working around this, by just sending key presses manually (I'm using https://github.com/ssalonen/cec-rs in Rust, which internally uses the C library):

fn mute(cec: &CecConnection) -> CecConnectionResult<()> {
    cec.send_keypress(CecLogicalAddress::Tv, CecUserControlCode::Mute, true)?;
    cec.send_key_release(CecLogicalAddress::Tv, true)?;
    Ok(())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant