Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: media/renderers/audio_renderer_impl.cc

Issue 2837303003: Fix the crash due to AudioRendererImpl::audio_clock_ being null (Closed)
Patch Set: Safer fix + rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/renderers/audio_renderer_impl.h" 5 #include "media/renderers/audio_renderer_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 void AudioRendererImpl::Initialize(DemuxerStream* stream, 330 void AudioRendererImpl::Initialize(DemuxerStream* stream,
331 CdmContext* cdm_context, 331 CdmContext* cdm_context,
332 RendererClient* client, 332 RendererClient* client,
333 const PipelineStatusCB& init_cb) { 333 const PipelineStatusCB& init_cb) {
334 DVLOG(1) << __func__; 334 DVLOG(1) << __func__;
335 DCHECK(task_runner_->BelongsToCurrentThread()); 335 DCHECK(task_runner_->BelongsToCurrentThread());
336 DCHECK(client); 336 DCHECK(client);
337 DCHECK(stream); 337 DCHECK(stream);
338 DCHECK_EQ(stream->type(), DemuxerStream::AUDIO); 338 DCHECK_EQ(stream->type(), DemuxerStream::AUDIO);
339 DCHECK(!init_cb.is_null()); 339 DCHECK(!init_cb.is_null());
340
341 base::AutoLock auto_lock(lock_);
340 DCHECK(state_ == kUninitialized || state_ == kFlushed); 342 DCHECK(state_ == kUninitialized || state_ == kFlushed);
341 DCHECK(sink_.get()); 343 DCHECK(sink_.get());
342 344
343 // If we are re-initializing playback (e.g. switching media tracks), stop the 345 // If we are re-initializing playback (e.g. switching media tracks), stop the
344 // sink first. 346 // sink first.
345 if (state_ == kFlushed) { 347 if (state_ == kFlushed) {
346 sink_->Stop(); 348 // Release the lock while we are stopping the sink to avoid deadlock if the
349 // sink needs to wait for the current Render to finish.
350 auto* sink = sink_.get();
351 {
352 base::AutoUnlock auto_unlock(lock_);
353 sink->Stop();
354 }
347 audio_clock_.reset(); 355 audio_clock_.reset();
DaleCurtis 2017/05/17 00:15:52 Instead just delete the CHECK below seems like tha
servolk 2017/05/17 00:23:31 Sure, we can probably do this. But I believe that
servolk 2017/05/17 00:27:12 Done (removed the explicit audio_clock_.reset() he
348 } 356 }
349 357
350 // Trying to track down AudioClock crash, http://crbug.com/674856. 358 // Trying to track down AudioClock crash, http://crbug.com/674856.
351 // AudioRenderImpl should only be initialized once to avoid destroying 359 // AudioRenderImpl should only be initialized once to avoid destroying
352 // AudioClock while the audio thread is still using it. 360 // AudioClock while the audio thread is still using it.
353 CHECK_EQ(audio_clock_.get(), nullptr); 361 CHECK_EQ(audio_clock_.get(), nullptr);
354 362
355 state_ = kInitializing; 363 state_ = kInitializing;
356 client_ = client; 364 client_ = client;
357 365
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 // All channels with a zero mix are muted and can be ignored. 1017 // All channels with a zero mix are muted and can be ignored.
1010 std::vector<bool> channel_mask(audio_parameters_.channels(), false); 1018 std::vector<bool> channel_mask(audio_parameters_.channels(), false);
1011 for (size_t ch = 0; ch < matrix.size(); ++ch) { 1019 for (size_t ch = 0; ch < matrix.size(); ++ch) {
1012 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(), 1020 channel_mask[ch] = std::any_of(matrix[ch].begin(), matrix[ch].end(),
1013 [](float mix) { return !!mix; }); 1021 [](float mix) { return !!mix; });
1014 } 1022 }
1015 algorithm_->SetChannelMask(std::move(channel_mask)); 1023 algorithm_->SetChannelMask(std::move(channel_mask));
1016 } 1024 }
1017 1025
1018 } // namespace media 1026 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698