- _log->log (String::compose ("-> ADS has request for %1 %2", frame, length), LogEntry::TYPE_DEBUG_DECODE);
-
- Frame const end = frame + length - 1;
-
- /* If we are less than (about) 5 seconds behind the data that we want we'll
- run through it rather than seeking.
- */
- Frame const slack = 5 * 48000;
+ _log->log (
+ String::compose (
+ "ADS has request for %1 %2; has %3 %4",
+ frame, length, _decoded.frame, _decoded.audio->frames()
+ ), LogEntry::TYPE_DEBUG_DECODE
+ );
+
+ Frame const from = frame;
+ Frame const to = from + length;
+ Frame const have_from = _decoded.frame;
+ Frame const have_to = _decoded.frame + _decoded.audio->frames();
+
+ optional<Frame> missing;
+ if (have_from > from || have_to < to) {
+ /* We need something */
+ if (have_from <= from && from < have_to) {
+ missing = have_to;
+ } else {
+ missing = from;
+ }
+ }