fix(text): Skip append if switching to a new stream
fix(text): Skip append if switching to a new stream

StreamingEngine takes the following steps to fetch and append a
segment:
1. Fetch and append the init segment, and initializes the source
buffer;
2. Fetch the segment;
3. Append the segment.

When StreamingEngine switches to a new text stream, it:
1. initializes a new text parser
2. If there's a fetchAndAppend_() call in the process, waits until
   that is finished
3. Otherwise, clears the buffer, and schedules an update to call
   fetchAndAppend_().

If switching the text stream gets called in the middle of a
fetchAndAppend_() process, the stream of the mediaState
can be changed between fetch_() and append_().
The new text parser is intialized, but the new init segment is not
fetched yet, however StreamingEngine tries to append the old segment.
That would cause an error in TextParser.parseMedia().

After a segment is fetched, we can check if the current stream is
switched. If so, the mediaState is waiting to clear buffer. We can
skip append, and schedule a new update for the new stream.

b/168253400

Change-Id: If8eebeb9a8e459baf0ff34748d77020098a9468e

tvoli/shaka-player,shaka-project/shaka-player,shaka-project/shaka-player,tvoli/shaka-player,tvoli/shaka-player,tvoli/shaka-player,shaka-project/shaka-player,shaka-project/shaka-player