| 119 | val o = files!!.apply(frame) |
| 120 | if (o == null) { |
| 121 | println(" NO FILE :" + frame) |
| 122 | return false |
| 123 | } |
| 124 | |
| 125 | // synchronous = true; |
| 126 | |
| 127 | val oo = if (synchronous) p.getOrWait(o) else p.get(o) |
| 128 | |
| 129 | try { |
| 130 | if (oo == null) { |
| 131 | println(" did not load in time:$frame / $o") |
| 132 | // p.printStatus(); |
| 133 | |
| 134 | if (synchronous) |
| 135 | System.err.println(" THIS CAN NEVER HAPPEN ") |
| 136 | |
| 137 | for (i in 0 until lookahead * 2) { |
| 138 | val fn = files!!.apply(frame - i - 1) |
| 139 | if (fn != null) |
| 140 | p.unschedule(fn) |
| 141 | } |
| 142 | |
| 143 | for (i in 0 until lookahead) { |
| 144 | val fn = files!!.apply(frame + i) |
| 145 | if (fn != null) |
| 146 | p.schedule(fn) |
| 147 | } |
| 148 | |
| 149 | |
| 150 | return false |
| 151 | } |
| 152 | |
| 153 | println(" loaded in time :$frame / $o") |
| 154 | |
| 155 | oo.rewind() |
| 156 | out.put(oo) |
| 157 | oo.rewind() |
| 158 | |
| 159 | val upcoming = LinkedHashSet<String>() |
| 160 | for (i in 0 until lookahead) { |
| 161 | val fn = files!!.apply(frame + i + 1) |
| 162 | upcoming.add(fn) |
| 163 | } |
| 164 | for (i in 0 until lookahead * 2) { |
| 165 | val fn = files!!.apply(frame - i - 2) |
| 166 | if (fn != null && !upcoming.contains(fn)) |
| 167 | p.unschedule(fn) |
| 168 | } |
| 169 | |
| 170 | for (i in 0 until lookahead) { |
| 171 | val fn = files!!.apply(frame + i + 1) |
| 172 | if (fn != null) |
| 173 | p.schedule(fn) |
| 174 | } |
| 175 | |
| 176 | return true |
| 177 | } finally { |
| 178 | p.free(o) |