| Index: media/base/android/media_codec_loop.cc
|
| diff --git a/media/base/android/media_codec_loop.cc b/media/base/android/media_codec_loop.cc
|
| index 7a8132b8db6815514796f5a84a0209fef927828d..f31ba8e58a47fe3a1c8b99f9717f349e0d1fe656 100644
|
| --- a/media/base/android/media_codec_loop.cc
|
| +++ b/media/base/android/media_codec_loop.cc
|
| @@ -4,12 +4,11 @@
|
|
|
| #include "media/base/android/media_codec_loop.h"
|
|
|
| -#include "base/android/build_info.h"
|
| +// TODO(liberato): do something
|
| +//#include "base/android/build_info.h"
|
| #include "base/bind.h"
|
| #include "base/callback_helpers.h"
|
| #include "base/logging.h"
|
| -#include "base/threading/thread_task_runner_handle.h"
|
| -#include "media/base/android/sdk_media_codec_bridge.h"
|
| #include "media/base/audio_buffer.h"
|
| #include "media/base/audio_timestamp_helper.h"
|
| #include "media/base/bind_to_current_loop.h"
|
| @@ -26,7 +25,9 @@ static inline bool codec_flush_requires_destruction() {
|
| // Return true if and only if Flush() isn't supported / doesn't work.
|
| // Prior to JellyBean-MR2, flush() had several bugs (b/8125974, b/8347958) so
|
| // we have to completely destroy and recreate the codec there.
|
| - return base::android::BuildInfo::GetInstance()->sdk_int() < 18;
|
| + // return base::android::BuildInfo::GetInstance()->sdk_int() < 18;
|
| + // TODO(liberato): testing
|
| + return false;
|
| }
|
|
|
| MediaCodecLoop::InputData::InputData() {}
|
| @@ -44,13 +45,17 @@ MediaCodecLoop::InputData::InputData(const InputData& other)
|
|
|
| MediaCodecLoop::InputData::~InputData() {}
|
|
|
| -MediaCodecLoop::MediaCodecLoop(Client* client,
|
| - std::unique_ptr<MediaCodecBridge> media_codec)
|
| +MediaCodecLoop::MediaCodecLoop(
|
| + Client* client,
|
| + std::unique_ptr<MediaCodecBridge> media_codec,
|
| + scoped_refptr<base::SingleThreadTaskRunner> task_runner)
|
| : state_(STATE_READY),
|
| client_(client),
|
| media_codec_(std::move(media_codec)),
|
| pending_input_buf_index_(kInvalidBufferIndex),
|
| weak_factory_(this) {
|
| + if (task_runner)
|
| + io_timer_.SetTaskRunner(task_runner);
|
| // TODO(liberato): should this DCHECK?
|
| if (media_codec_ == nullptr)
|
| SetState(STATE_ERROR);
|
| @@ -58,6 +63,10 @@ MediaCodecLoop::MediaCodecLoop(Client* client,
|
|
|
| MediaCodecLoop::~MediaCodecLoop() {}
|
|
|
| +void MediaCodecLoop::SetTestTickClock(base::TickClock* test_tick_clock) {
|
| + test_tick_clock_ = test_tick_clock;
|
| +}
|
| +
|
| void MediaCodecLoop::OnKeyAdded() {
|
| if (state_ == STATE_WAITING_FOR_KEY)
|
| SetState(STATE_READY);
|
| @@ -278,8 +287,11 @@ bool MediaCodecLoop::ProcessOneOutputBuffer() {
|
| media_codec_->ReleaseOutputBuffer(out.index, false);
|
|
|
| // Run the EOS completion callback now, since we deferred it until
|
| - // the EOS was completely processed.
|
| - pending_eos_completion_cb_.Run(DecodeStatus::OK);
|
| + // the EOS was completely processed. If there is no EOS callback, then
|
| + // this is an unsolicited EOS. Skip the callback since it will crash,
|
| + // but still notify the client.
|
| + if (!pending_eos_completion_cb_.is_null())
|
| + pending_eos_completion_cb_.Run(DecodeStatus::OK);
|
| pending_eos_completion_cb_ = DecodeCB();
|
|
|
| client_->OnDecodedEos(out);
|
| @@ -313,7 +325,9 @@ bool MediaCodecLoop::ProcessOneOutputBuffer() {
|
| void MediaCodecLoop::ManageTimer(bool did_work) {
|
| bool should_be_running = true;
|
|
|
| - base::TimeTicks now = base::TimeTicks::Now();
|
| + // One might also use DefaultTickClock, but then ownership becomes harder.
|
| + base::TimeTicks now = (test_tick_clock_ ? test_tick_clock_->NowTicks()
|
| + : base::TimeTicks::Now());
|
| if (did_work || idle_time_begin_ == base::TimeTicks()) {
|
| idle_time_begin_ = now;
|
| } else {
|
|
|