Methods Summary |
---|
void | add(HdmiCecMessage message)Add a new message to the buffer. The buffer keeps selected messages in
the order they are received.
boolean buffered = true;
// Note that all the messages are not handled in the same manner.
// For <Active Source> we keep the latest one only.
// TODO: This might not be the best way to choose the active source.
// Devise a better way to pick up the best one.
switch (message.getOpcode()) {
case Constants.MESSAGE_ACTIVE_SOURCE:
removeActiveSource();
mBuffer.add(message);
break;
case Constants.MESSAGE_INITIATE_ARC:
case Constants.MESSAGE_SET_SYSTEM_AUDIO_MODE:
mBuffer.add(message);
break;
default:
buffered = false;
break;
}
if (buffered) {
HdmiLogger.debug("Buffering message:" + message);
}
|
boolean | isBuffered(int opcode)
for (HdmiCecMessage message : mBuffer) {
if (message.getOpcode() == opcode) {
return true;
}
}
return false;
|
void | processActiveSource(int address)Process <Active Source>.
The message has a dependency on TV input framework. Should be invoked
after we get the callback
{@link android.media.tv.TvInputManager.TvInputCallback#onInputAdded(String)}
to ensure the processing of the message takes effect when transformed
to input change callback.
ArrayList<HdmiCecMessage> copiedBuffer = new ArrayList<HdmiCecMessage>(mBuffer);
mBuffer.clear();
for (HdmiCecMessage message : copiedBuffer) {
if (message.getOpcode() == Constants.MESSAGE_ACTIVE_SOURCE
&& message.getSource() == address) {
mDevice.onMessage(message);
HdmiLogger.debug("Processing message:" + message);
} else {
mBuffer.add(message);
}
}
|
void | processAllMessages()
// Use the copied buffer.
ArrayList<HdmiCecMessage> copiedBuffer = new ArrayList<HdmiCecMessage>(mBuffer);
mBuffer.clear();
for (HdmiCecMessage message : copiedBuffer) {
mDevice.onMessage(message);
HdmiLogger.debug("Processing message:" + message);
}
|
void | processMessagesForDevice(int address)Process messages from a given logical device. Called by
{@link NewDeviceAction} actions when they finish adding the device
information.
<Active Source> is processed only when the TV input is ready.
If not, {@link #processActiveSource()} will be invoked later to handle it.
ArrayList<HdmiCecMessage> copiedBuffer = new ArrayList<HdmiCecMessage>(mBuffer);
mBuffer.clear();
HdmiLogger.debug("Checking message for address:" + address);
for (HdmiCecMessage message : copiedBuffer) {
if (message.getSource() != address) {
mBuffer.add(message);
continue;
}
if (message.getOpcode() == Constants.MESSAGE_ACTIVE_SOURCE
&& !mDevice.isInputReady(HdmiDeviceInfo.idForCecDevice(address))) {
mBuffer.add(message);
continue;
}
mDevice.onMessage(message);
HdmiLogger.debug("Processing message:" + message);
}
|
private void | removeActiveSource()
// Uses iterator to remove elements while looping through the list.
for (Iterator<HdmiCecMessage> iter = mBuffer.iterator(); iter.hasNext(); ) {
HdmiCecMessage message = iter.next();
if (message.getOpcode() == Constants.MESSAGE_ACTIVE_SOURCE) {
iter.remove();
}
}
|