[Chromecast] Correctly handle very short audio streams
If we receive EOS before hitting the start threshold, begin playback. Bug: internal b/112599779 Test: cast_media_unittests Change-Id: I9575fbe5cb253fef8d626083f310eae7c3d71082 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1544092 Reviewed-by: Yuchen Liu <yucliu@chromium.org> Commit-Queue: Kenneth MacKay <kmackay@chromium.org> Cr-Commit-Position: refs/heads/master@{#645420}
This commit is contained in:
@ -308,6 +308,9 @@ BufferingMixerSource::RenderingDelay BufferingMixerSource::QueueData(
|
|||||||
if (data->end_of_stream()) {
|
if (data->end_of_stream()) {
|
||||||
LOG(INFO) << "End of stream for " << device_id_ << " (" << this << ")";
|
LOG(INFO) << "End of stream for " << device_id_ << " (" << this << ")";
|
||||||
locked->state_ = State::kGotEos;
|
locked->state_ = State::kGotEos;
|
||||||
|
if (!locked->started_ && locked->playback_start_timestamp_ != INT64_MIN) {
|
||||||
|
POST_TASK_TO_CALLER_THREAD(PostAudioReadyForPlayback);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// TODO(almasrymina): this drops 1 more buffer than necessary. What we
|
// TODO(almasrymina): this drops 1 more buffer than necessary. What we
|
||||||
// should do here is only drop if the playback_start_pts_ is not found in
|
// should do here is only drop if the playback_start_pts_ is not found in
|
||||||
@ -399,11 +402,16 @@ void BufferingMixerSource::CheckAndStartPlaybackIfNecessary(
|
|||||||
int64_t playback_absolute_timestamp) {
|
int64_t playback_absolute_timestamp) {
|
||||||
auto locked = locked_members_.AssertAcquired();
|
auto locked = locked_members_.AssertAcquired();
|
||||||
|
|
||||||
DCHECK(locked->state_ == State::kNormalPlayback && !locked->started_);
|
DCHECK(locked->state_ == State::kNormalPlayback ||
|
||||||
|
locked->state_ == State::kGotEos);
|
||||||
|
DCHECK(!locked->started_);
|
||||||
|
|
||||||
if (locked->queued_frames_ >= start_threshold_frames_ &&
|
const bool have_enough_queued_frames =
|
||||||
locked->queued_frames_ >=
|
(locked->state_ == State::kGotEos ||
|
||||||
locked->fader_.FramesNeededFromSource(num_frames) &&
|
(locked->queued_frames_ >= start_threshold_frames_ &&
|
||||||
|
locked->queued_frames_ >=
|
||||||
|
locked->fader_.FramesNeededFromSource(num_frames)));
|
||||||
|
if (have_enough_queued_frames &&
|
||||||
(locked->playback_start_timestamp_ == INT64_MIN ||
|
(locked->playback_start_timestamp_ == INT64_MIN ||
|
||||||
playback_absolute_timestamp +
|
playback_absolute_timestamp +
|
||||||
SamplesToMicroseconds(num_frames, input_samples_per_second_) >=
|
SamplesToMicroseconds(num_frames, input_samples_per_second_) >=
|
||||||
@ -477,7 +485,8 @@ int BufferingMixerSource::FillAudioPlaybackFrames(
|
|||||||
auto locked = locked_members_.Lock();
|
auto locked = locked_members_.Lock();
|
||||||
|
|
||||||
// Playback start check.
|
// Playback start check.
|
||||||
if (locked->state_ == State::kNormalPlayback && !locked->started_) {
|
if (!locked->started_ && (locked->state_ == State::kNormalPlayback ||
|
||||||
|
locked->state_ == State::kGotEos)) {
|
||||||
CheckAndStartPlaybackIfNecessary(num_frames, playback_absolute_timestamp);
|
CheckAndStartPlaybackIfNecessary(num_frames, playback_absolute_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user