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

Side by Side Diff: media/audio/fake_audio_input_stream.cc

Issue 9655018: Make AudioParameters a class instead of a struct (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 8 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 | Annotate | Revision Log
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/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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698