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

Audio Status #63

Open
mtullo27 opened this issue Mar 6, 2023 · 5 comments
Open

Audio Status #63

mtullo27 opened this issue Mar 6, 2023 · 5 comments

Comments

@mtullo27
Copy link

mtullo27 commented Mar 6, 2023

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

@trainman419
Copy link
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.

@utdream
Copy link

utdream commented Oct 3, 2023

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.

@r1ckdu
Copy link

r1ckdu commented Jan 16, 2024

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 ;)

@nderr
Copy link

nderr commented May 15, 2024

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

@utdream
Copy link

utdream commented May 17, 2024

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants