OLD | NEW |
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/audio/fake_audio_input_stream.h" | 5 #include "media/audio/fake_audio_input_stream.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 | 8 |
9 using base::Time; | 9 using base::Time; |
10 using base::TimeDelta; | 10 using base::TimeDelta; |
11 | 11 |
12 AudioInputStream* FakeAudioInputStream::MakeFakeStream( | 12 AudioInputStream* FakeAudioInputStream::MakeFakeStream( |
13 const AudioParameters& params) { | 13 const AudioParameters& params) { |
14 return new FakeAudioInputStream(params); | 14 return new FakeAudioInputStream(params); |
15 } | 15 } |
16 | 16 |
17 FakeAudioInputStream::FakeAudioInputStream(const AudioParameters& params) | 17 FakeAudioInputStream::FakeAudioInputStream(const AudioParameters& params) |
18 : callback_(NULL), | 18 : callback_(NULL), |
19 buffer_size_((params.channels * params.bits_per_sample * | 19 buffer_size_((params.channels() * params.bits_per_sample() * |
20 params.samples_per_packet) / 8), | 20 params.samples_per_packet()) / 8), |
21 thread_("FakeAudioRecordingThread"), | 21 thread_("FakeAudioRecordingThread"), |
22 callback_interval_(base::TimeDelta::FromMilliseconds( | 22 callback_interval_(base::TimeDelta::FromMilliseconds( |
23 (params.samples_per_packet * 1000) / params.sample_rate)) { | 23 (params.samples_per_packet() * 1000) / params.samples_per_second())) { |
24 // This object is ref counted (so that it can be used with Thread, PostTask) | 24 // This object is ref counted (so that it can be used with Thread, PostTask) |
25 // but the caller expects a plain pointer. So we take a reference here and | 25 // but the caller expects a plain pointer. So we take a reference here and |
26 // will Release() ourselves in Close(). | 26 // will Release() ourselves in Close(). |
27 AddRef(); | 27 AddRef(); |
28 } | 28 } |
29 | 29 |
30 FakeAudioInputStream::~FakeAudioInputStream() {} | 30 FakeAudioInputStream::~FakeAudioInputStream() {} |
31 | 31 |
32 bool FakeAudioInputStream::Open() { | 32 bool FakeAudioInputStream::Open() { |
33 buffer_.reset(new uint8[buffer_size_]); | 33 buffer_.reset(new uint8[buffer_size_]); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 double FakeAudioInputStream::GetMaxVolume() { | 81 double FakeAudioInputStream::GetMaxVolume() { |
82 return 0.0; | 82 return 0.0; |
83 } | 83 } |
84 | 84 |
85 void FakeAudioInputStream::SetVolume(double volume) {} | 85 void FakeAudioInputStream::SetVolume(double volume) {} |
86 | 86 |
87 double FakeAudioInputStream::GetVolume() { | 87 double FakeAudioInputStream::GetVolume() { |
88 return 0.0; | 88 return 0.0; |
89 } | 89 } |
OLD | NEW |