ssalonen / cec-rs

GNU General Public License v2.0
10 stars 8 forks source link

Incorrect interpretation of cec_logical_addresses #4

Closed igorbernstein closed 3 years ago

igorbernstein commented 3 years ago

It seems like the there is a mismatch of how libcec defines cec_logical_addresses and how CecLogicalAddresses interprets them.

libcec defines cec_logical_addresses as: struct { cec_logical_address primary; /*< the primary logical address to use / int addresses[16]; /*< the list of addresses / }

Unfortunately the comment /**< the list of addresses */ is extremely misleading. It should actually be called a bit map rather than a list where the keys are logical addresses and the values are booleans that indicate if the address is present. This behavior is visible in the implementation for Set():

https://github.com/Pulse-Eight/libcec/blob/76551ea1dd9a55f0ce1533e440dc12dbc594f7ba/include/cectypes.h#L1312-L1318

  void Set(cec_logical_address address)
  {
    if (primary == CECDEVICE_UNREGISTERED)
      primary = address;

    addresses[(int) address] = 1;
  }

On the other hand cec-rs interprets the struct as list of logical addresses (where the primary address lives on its own).

igorbernstein commented 3 years ago

As a sidenote, thanks for fixing all of the issues that I've opened thus far :)