Fixed CEA-708 issue where cues weren't updated at the appropriate times

As per the CEA-708-B specification, section 8.10.4, cues don't necessarily
need either an ETX command or any of the C1 commands before being updated
with the latest buffered content. While those commands do indicate that the
cues should be updated immediately, the cues can also be updated after a
service block has been processed if it appended text to the buffer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149673162
This commit is contained in:
cdrolle 2017-03-09 11:18:15 -08:00 committed by Oliver Woodman
parent b6773dba05
commit b84c84cc76

View File

@ -285,19 +285,26 @@ public final class Cea708Decoder extends CeaDecoder {
return; return;
} }
// The cues should be updated if we receive a C0 ETX command, any C1 command, or if after
// processing the service block any text has been added to the buffer. See CEA-708-B Section
// 8.10.4 for more details.
boolean cuesNeedUpdate = false;
while (serviceBlockPacket.bitsLeft() > 0) { while (serviceBlockPacket.bitsLeft() > 0) {
int command = serviceBlockPacket.readBits(8); int command = serviceBlockPacket.readBits(8);
if (command != COMMAND_EXT1) { if (command != COMMAND_EXT1) {
if (command <= GROUP_C0_END) { if (command <= GROUP_C0_END) {
handleC0Command(command); handleC0Command(command);
// If the C0 command was an ETX command, the cues are updated in handleC0Command.
} else if (command <= GROUP_G0_END) { } else if (command <= GROUP_G0_END) {
handleG0Character(command); handleG0Character(command);
cuesNeedUpdate = true;
} else if (command <= GROUP_C1_END) { } else if (command <= GROUP_C1_END) {
handleC1Command(command); handleC1Command(command);
// Cues are always updated after a C1 command cuesNeedUpdate = true;
cues = getDisplayCues();
} else if (command <= GROUP_G1_END) { } else if (command <= GROUP_G1_END) {
handleG1Character(command); handleG1Character(command);
cuesNeedUpdate = true;
} else { } else {
Log.w(TAG, "Invalid base command: " + command); Log.w(TAG, "Invalid base command: " + command);
} }
@ -308,15 +315,21 @@ public final class Cea708Decoder extends CeaDecoder {
handleC2Command(command); handleC2Command(command);
} else if (command <= GROUP_G2_END) { } else if (command <= GROUP_G2_END) {
handleG2Character(command); handleG2Character(command);
cuesNeedUpdate = true;
} else if (command <= GROUP_C3_END) { } else if (command <= GROUP_C3_END) {
handleC3Command(command); handleC3Command(command);
} else if (command <= GROUP_G3_END) { } else if (command <= GROUP_G3_END) {
handleG3Character(command); handleG3Character(command);
cuesNeedUpdate = true;
} else { } else {
Log.w(TAG, "Invalid extended command: " + command); Log.w(TAG, "Invalid extended command: " + command);
} }
} }
} }
if (cuesNeedUpdate) {
cues = getDisplayCues();
}
} }
private void handleC0Command(int command) { private void handleC0Command(int command) {