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

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

Issue 1942803002: Caching AudioOutputDevice instances in mixer manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase cache smoke test added minor unit test cleanup Created 4 years, 6 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
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 18 matching lines...) Expand all
29 #include "media/base/timestamp_constants.h" 29 #include "media/base/timestamp_constants.h"
30 #include "media/filters/audio_clock.h" 30 #include "media/filters/audio_clock.h"
31 #include "media/filters/decrypting_demuxer_stream.h" 31 #include "media/filters/decrypting_demuxer_stream.h"
32 32
33 namespace media { 33 namespace media {
34 34
35 AudioRendererImpl::AudioRendererImpl( 35 AudioRendererImpl::AudioRendererImpl(
36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 36 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
37 media::AudioRendererSink* sink, 37 media::AudioRendererSink* sink,
38 ScopedVector<AudioDecoder> decoders, 38 ScopedVector<AudioDecoder> decoders,
39 const AudioHardwareConfig& hardware_config,
40 const scoped_refptr<MediaLog>& media_log) 39 const scoped_refptr<MediaLog>& media_log)
41 : task_runner_(task_runner), 40 : task_runner_(task_runner),
42 expecting_config_changes_(false), 41 expecting_config_changes_(false),
43 sink_(sink), 42 sink_(sink),
44 audio_buffer_stream_( 43 audio_buffer_stream_(
45 new AudioBufferStream(task_runner, std::move(decoders), media_log)), 44 new AudioBufferStream(task_runner, std::move(decoders), media_log)),
46 hardware_config_(hardware_config),
47 media_log_(media_log), 45 media_log_(media_log),
48 client_(nullptr), 46 client_(nullptr),
49 tick_clock_(new base::DefaultTickClock()), 47 tick_clock_(new base::DefaultTickClock()),
50 last_audio_memory_usage_(0), 48 last_audio_memory_usage_(0),
51 last_decoded_sample_rate_(0), 49 last_decoded_sample_rate_(0),
52 playback_rate_(0.0), 50 playback_rate_(0.0),
53 state_(kUninitialized), 51 state_(kUninitialized),
54 buffering_state_(BUFFERING_HAVE_NOTHING), 52 buffering_state_(BUFFERING_HAVE_NOTHING),
55 rendering_(false), 53 rendering_(false),
56 sink_playing_(false), 54 sink_playing_(false),
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 DCHECK_EQ(kUninitialized, state_); 324 DCHECK_EQ(kUninitialized, state_);
327 DCHECK(sink_.get()); 325 DCHECK(sink_.get());
328 326
329 state_ = kInitializing; 327 state_ = kInitializing;
330 client_ = client; 328 client_ = client;
331 329
332 // Always post |init_cb_| because |this| could be destroyed if initialization 330 // Always post |init_cb_| because |this| could be destroyed if initialization
333 // failed. 331 // failed.
334 init_cb_ = BindToCurrentLoop(init_cb); 332 init_cb_ = BindToCurrentLoop(init_cb);
335 333
336 const AudioParameters& hw_params = hardware_config_.GetOutputConfig(); 334 const AudioParameters& hw_params =
DaleCurtis 2016/05/26 19:18:09 Do you know what this returns when the element is
o1ka 2016/05/27 13:48:52 This is a good question. Here https://code.google
335 sink_->GetOutputDeviceInfo().output_params();
337 expecting_config_changes_ = stream->SupportsConfigChanges(); 336 expecting_config_changes_ = stream->SupportsConfigChanges();
338 if (!expecting_config_changes_ || !hw_params.IsValid() || 337 if (!expecting_config_changes_ || !hw_params.IsValid() ||
339 hw_params.format() == AudioParameters::AUDIO_FAKE) { 338 hw_params.format() == AudioParameters::AUDIO_FAKE) {
340 // The actual buffer size is controlled via the size of the AudioBus 339 // The actual buffer size is controlled via the size of the AudioBus
341 // provided to Render(), so just choose something reasonable here for looks. 340 // provided to Render(), so just choose something reasonable here for looks.
342 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100; 341 int buffer_size = stream->audio_decoder_config().samples_per_second() / 100;
343 audio_parameters_.Reset( 342 audio_parameters_.Reset(
344 AudioParameters::AUDIO_PCM_LOW_LATENCY, 343 AudioParameters::AUDIO_PCM_LOW_LATENCY,
345 stream->audio_decoder_config().channel_layout(), 344 stream->audio_decoder_config().channel_layout(),
346 stream->audio_decoder_config().samples_per_second(), 345 stream->audio_decoder_config().samples_per_second(),
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 DCHECK_NE(buffering_state_, buffering_state); 925 DCHECK_NE(buffering_state_, buffering_state);
927 lock_.AssertAcquired(); 926 lock_.AssertAcquired();
928 buffering_state_ = buffering_state; 927 buffering_state_ = buffering_state;
929 928
930 task_runner_->PostTask( 929 task_runner_->PostTask(
931 FROM_HERE, base::Bind(&AudioRendererImpl::OnBufferingStateChange, 930 FROM_HERE, base::Bind(&AudioRendererImpl::OnBufferingStateChange,
932 weak_factory_.GetWeakPtr(), buffering_state_)); 931 weak_factory_.GetWeakPtr(), buffering_state_));
933 } 932 }
934 933
935 } // namespace media 934 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698