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

Side by Side Diff: media/base/fake_audio_renderer_sink.cc

Issue 1809093003: Moving SwitchOutputDevice out of OutputDevice interface, eliminating OutputDevice (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing guidou's comments Created 4 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/fake_audio_renderer_sink.h" 5 #include "media/base/fake_audio_renderer_sink.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h"
11 #include "media/base/fake_output_device.h"
12 10
13 namespace media { 11 namespace media {
14 12
15 FakeAudioRendererSink::FakeAudioRendererSink() 13 FakeAudioRendererSink::FakeAudioRendererSink()
16 : state_(kUninitialized), 14 : state_(kUninitialized),
17 callback_(NULL), 15 callback_(NULL),
18 output_device_(new FakeOutputDevice) {} 16 output_device_info_(
17 std::string(),
18 OUTPUT_DEVICE_STATUS_OK,
19 media::AudioParameters(media::AudioParameters::AUDIO_FAKE,
20 media::CHANNEL_LAYOUT_STEREO,
21 media::AudioParameters::kTelephoneSampleRate,
22 16,
miu 2016/03/24 21:32:02 Side Note: At some point, we should evaluate wheth
o1ka 2016/03/29 13:39:54 Yes, we should consider this.
23 1)) {}
19 24
20 FakeAudioRendererSink::~FakeAudioRendererSink() { 25 FakeAudioRendererSink::~FakeAudioRendererSink() {
21 DCHECK(!callback_); 26 DCHECK(!callback_);
22 } 27 }
23 28
24 void FakeAudioRendererSink::Initialize(const AudioParameters& params, 29 void FakeAudioRendererSink::Initialize(const AudioParameters& params,
25 RenderCallback* callback) { 30 RenderCallback* callback) {
26 DCHECK_EQ(state_, kUninitialized); 31 DCHECK_EQ(state_, kUninitialized);
27 DCHECK(!callback_); 32 DCHECK(!callback_);
28 DCHECK(callback); 33 DCHECK(callback);
(...skipping 20 matching lines...) Expand all
49 void FakeAudioRendererSink::Play() { 54 void FakeAudioRendererSink::Play() {
50 DCHECK(state_ == kStarted || state_ == kPaused) << "state_ " << state_; 55 DCHECK(state_ == kStarted || state_ == kPaused) << "state_ " << state_;
51 DCHECK_EQ(state_, kPaused); 56 DCHECK_EQ(state_, kPaused);
52 ChangeState(kPlaying); 57 ChangeState(kPlaying);
53 } 58 }
54 59
55 bool FakeAudioRendererSink::SetVolume(double volume) { 60 bool FakeAudioRendererSink::SetVolume(double volume) {
56 return true; 61 return true;
57 } 62 }
58 63
59 OutputDevice* FakeAudioRendererSink::GetOutputDevice() { 64 OutputDeviceInfo FakeAudioRendererSink::GetOutputDeviceInfo() {
60 return output_device_.get(); 65 return output_device_info_;
61 } 66 }
62 67
63 bool FakeAudioRendererSink::Render(AudioBus* dest, 68 bool FakeAudioRendererSink::Render(AudioBus* dest,
64 uint32_t audio_delay_milliseconds, 69 uint32_t audio_delay_milliseconds,
65 int* frames_written) { 70 int* frames_written) {
66 if (state_ != kPlaying) 71 if (state_ != kPlaying)
67 return false; 72 return false;
68 73
69 *frames_written = callback_->Render(dest, audio_delay_milliseconds, 0); 74 *frames_written = callback_->Render(dest, audio_delay_milliseconds, 0);
70 return true; 75 return true;
(...skipping 15 matching lines...) Expand all
86 "kPlaying", 91 "kPlaying",
87 "kStopped" 92 "kStopped"
88 }; 93 };
89 94
90 DVLOG(1) << __FUNCTION__ << " : " 95 DVLOG(1) << __FUNCTION__ << " : "
91 << kStateNames[state_] << " -> " << kStateNames[new_state]; 96 << kStateNames[state_] << " -> " << kStateNames[new_state];
92 state_ = new_state; 97 state_ = new_state;
93 } 98 }
94 99
95 } // namespace media 100 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698