Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / audio / fake_audio_output_stream.cc
blobfb460ab680554bb789a6ea2b7d64e402d2ca9856
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
3 // found in the LICENSE file.
5 #include "media/audio/fake_audio_output_stream.h"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h"
11 #include "media/audio/audio_manager_base.h"
13 namespace media {
15 // static
16 AudioOutputStream* FakeAudioOutputStream::MakeFakeStream(
17 AudioManagerBase* manager, const AudioParameters& params) {
18 return new FakeAudioOutputStream(manager, params);
21 FakeAudioOutputStream::FakeAudioOutputStream(AudioManagerBase* manager,
22 const AudioParameters& params)
23 : audio_manager_(manager),
24 callback_(NULL),
25 fake_consumer_(manager->GetWorkerLoop(), params) {
28 FakeAudioOutputStream::~FakeAudioOutputStream() {
29 DCHECK(!callback_);
32 bool FakeAudioOutputStream::Open() {
33 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
34 return true;
37 void FakeAudioOutputStream::Start(AudioSourceCallback* callback) {
38 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
39 callback_ = callback;
40 fake_consumer_.Start(base::Bind(
41 &FakeAudioOutputStream::CallOnMoreData, base::Unretained(this)));
44 void FakeAudioOutputStream::Stop() {
45 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
46 fake_consumer_.Stop();
47 callback_ = NULL;
50 void FakeAudioOutputStream::Close() {
51 DCHECK(!callback_);
52 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
53 audio_manager_->ReleaseOutputStream(this);
56 void FakeAudioOutputStream::SetVolume(double volume) {};
58 void FakeAudioOutputStream::GetVolume(double* volume) {
59 *volume = 0;
62 void FakeAudioOutputStream::CallOnMoreData(AudioBus* audio_bus) {
63 DCHECK(audio_manager_->GetWorkerLoop()->BelongsToCurrentThread());
64 callback_->OnMoreData(audio_bus, AudioBuffersState());
67 } // namespace media