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

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

Issue 10832285: Switch OnMoreData() to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Comments. Created 8 years, 3 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
« no previous file with comments | « media/audio/fake_audio_output_stream.h ('k') | media/audio/linux/alsa_output.h » ('j') | 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/audio/fake_audio_output_stream.h" 5 #include "media/audio/fake_audio_output_stream.h"
6 6
7 #include "base/at_exit.h" 7 #include "base/at_exit.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/audio/audio_manager_base.h" 9 #include "media/audio/audio_manager_base.h"
10 10
11 namespace media { 11 namespace media {
12 12
13 FakeAudioOutputStream* FakeAudioOutputStream::current_fake_stream_ = NULL; 13 FakeAudioOutputStream* FakeAudioOutputStream::current_fake_stream_ = NULL;
14 14
15 // static 15 // static
16 AudioOutputStream* FakeAudioOutputStream::MakeFakeStream( 16 AudioOutputStream* FakeAudioOutputStream::MakeFakeStream(
17 AudioManagerBase* manager, 17 AudioManagerBase* manager,
18 const AudioParameters& params) { 18 const AudioParameters& params) {
19 FakeAudioOutputStream* new_stream = new FakeAudioOutputStream(manager, 19 FakeAudioOutputStream* new_stream = new FakeAudioOutputStream(manager,
20 params); 20 params);
21 DCHECK(current_fake_stream_ == NULL); 21 DCHECK(current_fake_stream_ == NULL);
22 current_fake_stream_ = new_stream; 22 current_fake_stream_ = new_stream;
23 return new_stream; 23 return new_stream;
24 } 24 }
25 25
26 bool FakeAudioOutputStream::Open() { 26 bool FakeAudioOutputStream::Open() {
27 if (bytes_per_buffer_ < sizeof(int16))
28 return false;
29 buffer_.reset(new uint8[bytes_per_buffer_]);
30 return true; 27 return true;
31 } 28 }
32 29
33 // static 30 // static
34 FakeAudioOutputStream* FakeAudioOutputStream::GetCurrentFakeStream() { 31 FakeAudioOutputStream* FakeAudioOutputStream::GetCurrentFakeStream() {
35 return current_fake_stream_; 32 return current_fake_stream_;
36 } 33 }
37 34
38 void FakeAudioOutputStream::Start(AudioSourceCallback* callback) { 35 void FakeAudioOutputStream::Start(AudioSourceCallback* callback) {
39 callback_ = callback; 36 callback_ = callback;
40 memset(buffer_.get(), 0, bytes_per_buffer_); 37 audio_bus_->Zero();
41 callback_->OnMoreData(buffer_.get(), bytes_per_buffer_, 38 callback_->OnMoreData(audio_bus_.get(), AudioBuffersState(0, 0));
42 AudioBuffersState(0, 0));
43 } 39 }
44 40
45 void FakeAudioOutputStream::Stop() { 41 void FakeAudioOutputStream::Stop() {
46 callback_ = NULL; 42 callback_ = NULL;
47 } 43 }
48 44
49 void FakeAudioOutputStream::SetVolume(double volume) { 45 void FakeAudioOutputStream::SetVolume(double volume) {
50 volume_ = volume; 46 volume_ = volume;
51 } 47 }
52 48
53 void FakeAudioOutputStream::GetVolume(double* volume) { 49 void FakeAudioOutputStream::GetVolume(double* volume) {
54 *volume = volume_; 50 *volume = volume_;
55 } 51 }
56 52
57 void FakeAudioOutputStream::Close() { 53 void FakeAudioOutputStream::Close() {
58 closed_ = true; 54 closed_ = true;
59 audio_manager_->ReleaseOutputStream(this); 55 audio_manager_->ReleaseOutputStream(this);
60 } 56 }
61 57
62 FakeAudioOutputStream::FakeAudioOutputStream(AudioManagerBase* manager, 58 FakeAudioOutputStream::FakeAudioOutputStream(AudioManagerBase* manager,
63 const AudioParameters& params) 59 const AudioParameters& params)
64 : audio_manager_(manager), 60 : audio_manager_(manager),
65 volume_(0), 61 volume_(0),
66 callback_(NULL), 62 callback_(NULL),
67 bytes_per_buffer_(params.GetBytesPerBuffer()),
68 closed_(false) { 63 closed_(false) {
64 audio_bus_ = AudioBus::Create(params);
69 } 65 }
70 66
71 FakeAudioOutputStream::~FakeAudioOutputStream() { 67 FakeAudioOutputStream::~FakeAudioOutputStream() {
72 if (current_fake_stream_ == this) 68 if (current_fake_stream_ == this)
73 current_fake_stream_ = NULL; 69 current_fake_stream_ = NULL;
74 } 70 }
75 71
76 } // namespace media 72 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/fake_audio_output_stream.h ('k') | media/audio/linux/alsa_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698