Speed up playlist processing

The recent removal of the cache from MediaScanner (commit 58ef68905d67e356eb)
slowed down processing of playlists, in some cases significantly, due to every
line in a playlist prompting a query that looped over the entire audio table.

With this change, the query is only done once instead of for every line,
and the code starts iterating over the Cursor starting near the point of
the last match, instead of from the start. The latter is especially helpful
when the entire query result is too large to fit in a CursorWindow, since
it reduces the number of times that sqlite has to perform an offset query
under the hood to refil the window.

Change-Id: I9fea990b3b8c86571384de2122708fb7e809c355
1 file changed