Skip to content

Commit

Permalink
Merged: MediaCodecPlayer: prevent requesting data in wrong states
Browse files Browse the repository at this point in the history
MediaCodecPlayer expects the demuxer response for each demuxer
data request. Currently it might happen that no response would
come after a data request, which might result in the player
lockup.

This situation might happen if the data request callback arrives
late at the Media thread, e.g. after the player started the Seek
sequence. In this case the data request could come after the
demuxer seek request which violates the demuxer contract.

This CL checks the decoder state before calling the data request
from demuxer.

BUG=557334

[email protected]

> Review URL: https://codereview.chromium.org/1455853002

> Cr-Commit-Position: refs/heads/master@{#360392}

Review URL: https://codereview.chromium.org/1457713003 .

Cr-Commit-Position: refs/branch-heads/2564@{crosswalk-project#49}
Cr-Branched-From: 1283eca-refs/heads/master@{#359700}
  • Loading branch information
Tima Vaisburd committed Nov 18, 2015
1 parent b892a72 commit 1e22259
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions media/base/android/media_codec_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,19 @@ void MediaCodecDecoder::OnCodecError() {
void MediaCodecDecoder::RequestData() {
DCHECK(media_task_runner_->BelongsToCurrentThread());

// We request data only in kPrefetching, kPrerolling and kRunning states.
// For kPrerolling and kRunning this method is posted from Decoder thread,
// and by the time it arrives the player might be doing something else, e.g.
// seeking, in which case we should not request more data
switch (GetState()) {
case kPrefetching:
case kPrerolling:
case kRunning:
break; // continue
default:
return; // skip
}

// Ensure one data request at a time.
if (!is_data_request_in_progress_) {
is_data_request_in_progress_ = true;
Expand Down

0 comments on commit 1e22259

Please sign in to comment.