Re: [cecd-devel] [PATCH 2/2] [libcec] fix logical address allocation
Status: Beta
Brought to you by:
pbatard
|
From: Pete B. <pb...@gm...> - 2012-01-06 00:38:09
|
On 2012.01.05 17:13, Florian Fainelli wrote:
> The current logical address allocation will iterate over all possible
> logical addresses no matter what device type we configured. According
> to the specification this is wrong, for instance, if we are a recording
> device, we should:
>
> - take the unregistered address
> - poll the<N>th logical address corresponding to a recording device
> * if available, take it
> * if not available continue to the next logical address
> - until we either have a valid address or remain unregistered
I think this is what we are already doing.
Internally, we will iterate over all addresses, but it is not because we
iterate them that we poll.
To illustrate this, let's take the case of a playback device
(device_type 4). The beginning of the loop code:
for (logical_address = 1; logical_address < 15; logical_address++) {
if (logical_address_table[logical_address] != device_type) {
continue;
}
along with the fact that logical_address_table is defined as:
logical_address_table[15] = {0, 1, 1, 3, 4, 5, 3, 3, 4, 1, 3, 4, 2, 2, 0};
means that for logical_addresses 1 to 3, we don't do anything - we just
increment logical_address and continue because the device_type won't
match. Then, for logical_address 4, we have a match on the device_type,
so we poll to see if the address is in use. If it is, then we will skip
over logical_address 5, because the device_type won't match either and
it's only for logical_address 8 that we will poll again.
Thus, I believe that the use of a simple table and the insertion of
continue statements achieves exactly what we need, and is a lot simpler
than the solution your proposed.
On the other hand, I have applied the polling message fix (good call)
and also fixed the file permissions that got changed with the version bump.
Regards,
/Pete
|