Commit d30aa688 authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Always execute FakeAudioWorker::|worker_cb_| even if late.

Most output clients are expecting that |worker_cb_| will consume N
frames and that subsequently the clock advances by N frames. Not
calling the |worker_cb_| stalls these internal clocks.

There's still the issue that tasks are incredibly delayed in the
ScopedTaskEnvironment on macOS. I.e., playback will still be slower than
realtime, but it at least won't be 0.25x as we spend forever trying to
catch up before executing the callback.

BUG=1003761,1014646
R=miu

Change-Id: Iaa98d683ba77fa664f13da2436cb69bf834251ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898641
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarYuri Wiitala <miu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715430}
parent c98dded5
...@@ -69,8 +69,9 @@ void FakeAudioOutputStream::CallOnMoreData(base::TimeTicks ideal_time, ...@@ -69,8 +69,9 @@ void FakeAudioOutputStream::CallOnMoreData(base::TimeTicks ideal_time,
DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread()); DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread());
// Real streams provide small tweaks to their delay values, alongside the // Real streams provide small tweaks to their delay values, alongside the
// current system time; and so the same is done here. // current system time; and so the same is done here.
callback_->OnMoreData(fixed_data_delay_ + (ideal_time - now), now, 0, const auto delay =
audio_bus_.get()); fixed_data_delay_ + std::max(base::TimeDelta(), ideal_time - now);
callback_->OnMoreData(delay, now, 0, audio_bus_.get());
} }
void FakeAudioOutputStream::SetMute(bool muted) {} void FakeAudioOutputStream::SetMute(bool muted) {}
......
...@@ -166,9 +166,12 @@ void FakeAudioWorker::Worker::DoRead() { ...@@ -166,9 +166,12 @@ void FakeAudioWorker::Worker::DoRead() {
base::AutoLock scoped_lock(worker_cb_lock_); base::AutoLock scoped_lock(worker_cb_lock_);
// Important to sample the clock after waiting to acquire the lock. // Important to sample the clock after waiting to acquire the lock.
now = base::TimeTicks::Now(); now = base::TimeTicks::Now();
if (worker_cb_ && next_read_time > now) {
// Note: Even if we're late, this callback must be called. In many cases we
// are driving an underlying "samples consumed" based clock with these
// calls.
if (worker_cb_)
worker_cb_.Run(read_time, now); worker_cb_.Run(read_time, now);
}
} }
// If we're behind, find the next nearest ontime interval. Note, we could be // If we're behind, find the next nearest ontime interval. Note, we could be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment