Fixed an off by one error and fixed iterating through the cues

This commit is contained in:
Rik Heijdens 2016-09-14 09:32:53 -04:00
parent 26fe1dc238
commit b87463a857
2 changed files with 16 additions and 13 deletions

View file

@ -1,8 +1,5 @@
package com.google.android.exoplayer2.text.eia608;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.util.Assertions;
import android.text.Layout;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@ -10,6 +7,9 @@ import android.text.style.CharacterStyle;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.util.Assertions;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
@ -73,7 +73,7 @@ import java.util.List;
* @return true if rolling was possible.
*/
public boolean rollUp() {
if (row < 1) {
if (row <= 1) {
return false;
}
setRow(row - 1);

View file

@ -15,6 +15,13 @@
*/
package com.google.android.exoplayer2.text.eia608;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.SubtitleDecoder;
@ -24,14 +31,8 @@ import com.google.android.exoplayer2.text.SubtitleOutputBuffer;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.ParsableByteArray;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.style.BackgroundColorSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.text.style.UnderlineSpan;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.TreeSet;
@ -472,10 +473,12 @@ public final class Eia608Decoder implements SubtitleDecoder {
// from memory and from the display. The remaining rows of text are each rolled up into the
// next highest row in the window, leaving the base row blank and ready to accept new text.
if (captionMode == CC_MODE_ROLL_UP) {
for (Eia608CueBuilder cue : cues) {
Iterator<Eia608CueBuilder> iterator = cues.iterator();
while (iterator.hasNext()) {
Eia608CueBuilder cue = iterator.next();
// Roll up all the other rows.
if (!cue.rollUp()) {
cues.remove(cue);
iterator.remove();
}
}
currentCue = new Eia608CueBuilder();