Skip to content

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

@kira-bruneau

Description

@kira-bruneau

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(())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions