Skip to content

Audio Status #63

Open
Open

Description

@mtullo27

Has there been any progress on implementing the get audio status functionality?

Activity

  1. trainman419 commented on Mar 7, 2023

    @trainman419
    Owner

    No, I haven't had anyone asking for audio status, so I haven't looked into it. If you can explain briefly what you're trying to do, I might be able to help.

  2. utdream commented on Oct 3, 2023

    @utdream

    Audio status is only loosely implemented in the HDMI-CEC specification itself. It rarely (never?) works on TV's and only works on things like sound bars. We need better implementation in the HDMI spec itself before it can really be implemented in an API like this IMHO.

  3. r1ckdu commented on Jan 16, 2024

    @r1ckdu

    I know this is an old thread but I'd love to get an absolute volume reading. From what I have gathered the code that i need to evaluate is 15:71 (recorder to audio): "Give Audio Status"
    Returns 51:8e e.g. indicating that the volume is 14 and its muted -> hex sum of 80 + an integer of 0..127.

    This would be amazing to have because for my application I need an absolute volume scale.

    @trainman419 I have been able to do this using cec-client but I am not able to drive this from python...so this is where your python package came in ;)

  4. nderr commented on May 15, 2024

    @nderr

    I poked around a little bit on this issue. You can add a wrapper for the libcec "GetAudioStatus" function without too much trouble, but as discussed here, libcec caches the first result and keeps returning it forever.

    The path of least resistance is probably to ask the audio system for the audio status directly, add a handler to grab the response, and cast the resulting parameter from bytes to int. For example, when I run the following...

    # audio_status_test.py
    
    import time
    import cec
    
    audio     = cec.CECDEVICE_AUDIOSYSTEM
    op_give   = cec.CEC_OPCODE_GIVE_AUDIO_STATUS
    op_report = cec.CEC_OPCODE_REPORT_AUDIO_STATUS
    
    recvd = False
    def cb(event, *args):
    
        print('event: ', event, ', data: ', args)
    
        par = args[0]
        init = par['initiator']
        comm = par['opcode']
    
        if init == audio and comm == op_report:
    
            byte_result = par['parameters']
            print(f'\n\nAudio Status: {int.from_bytes(byte_result,"big")}')
    
            global recvd
            recvd = True
    
    cec.add_callback(cb, cec.EVENT_COMMAND)
    cec.init()
    cec.transmit(audio,op_give)
    
    while not recvd:
        time.sleep(0.1)

    ...I get the following output.

    event:  4 , data:  ({'initiator': 0, 'destination': 15, 'ack': False, 'eom': False, 'opcode': 135, 'parameters': b'\x00\x009', 'opcode_set': True, 'transmit_timeout': 1000},)
    event:  4 , data:  ({'initiator': 0, 'destination': 1, 'ack': False, 'eom': False, 'opcode': 144, 'parameters': b'\x00', 'opcode_set': True, 'transmit_timeout': 1000},)
    event:  4 , data:  ({'initiator': 5, 'destination': 1, 'ack': False, 'eom': False, 'opcode': 122, 'parameters': b'$', 'opcode_set': True, 'transmit_timeout': 1000},)
    
    
    Audio Status: 36
    
  5. utdream commented on May 17, 2024

    @utdream

    Yuk. That really sucks that libcec does that. I like your implementation of asking the device directly. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions