Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into seek-latency-metrics
Browse files Browse the repository at this point in the history
Change-Id: If3ef45925049a43ee190e1bd65bdeae638d5d526
  • Loading branch information
at-ninja committed Apr 1, 2024
2 parents d1b56d5 + 02dc352 commit 81d9e33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ AdaptiveAudioDecoder::AdaptiveAudioDecoder(
}

AdaptiveAudioDecoder::~AdaptiveAudioDecoder() {
Reset();
SB_DCHECK(BelongsToCurrentThread());

if (audio_decoder_) {
TeardownAudioDecoder();
}
ResetInternal();
}

void AdaptiveAudioDecoder::Initialize(const OutputCB& output_cb,
Expand Down Expand Up @@ -150,15 +155,7 @@ void AdaptiveAudioDecoder::Reset() {
resampler_.reset();
channel_mixer_.reset();
}
CancelPendingJobs();
while (!decoded_audios_.empty()) {
decoded_audios_.pop();
}
pending_input_buffers_.clear();
pending_consumed_cb_ = nullptr;
flushing_ = false;
stream_ended_ = false;
first_output_received_ = false;
ResetInternal();
}

void AdaptiveAudioDecoder::InitializeAudioDecoder(
Expand Down Expand Up @@ -188,6 +185,18 @@ void AdaptiveAudioDecoder::TeardownAudioDecoder() {
channel_mixer_.reset();
}

void AdaptiveAudioDecoder::ResetInternal() {
CancelPendingJobs();
while (!decoded_audios_.empty()) {
decoded_audios_.pop();
}
pending_input_buffers_.clear();
pending_consumed_cb_ = nullptr;
flushing_ = false;
stream_ended_ = false;
first_output_received_ = false;
}

void AdaptiveAudioDecoder::OnDecoderOutput() {
if (!BelongsToCurrentThread()) {
Schedule(std::bind(&AdaptiveAudioDecoder::OnDecoderOutput, this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class AdaptiveAudioDecoder : public AudioDecoder, private JobQueue::JobOwner {
void InitializeAudioDecoder(const media::AudioStreamInfo& audio_stream_info);
void TeardownAudioDecoder();
void OnDecoderOutput();
void ResetInternal();

const uint32_t initial_samples_per_second_;
const SbDrmSystem drm_system_;
Expand Down

0 comments on commit 81d9e33

Please sign in to comment.