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"
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"
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
),
25 fake_consumer_(manager
->GetWorkerLoop(), params
) {
28 FakeAudioOutputStream::~FakeAudioOutputStream() {
32 bool FakeAudioOutputStream::Open() {
33 DCHECK(audio_manager_
->GetMessageLoop()->BelongsToCurrentThread());
37 void FakeAudioOutputStream::Start(AudioSourceCallback
* callback
) {
38 DCHECK(audio_manager_
->GetMessageLoop()->BelongsToCurrentThread());
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();
50 void FakeAudioOutputStream::Close() {
52 DCHECK(audio_manager_
->GetMessageLoop()->BelongsToCurrentThread());
53 audio_manager_
->ReleaseOutputStream(this);
56 void FakeAudioOutputStream::SetVolume(double volume
) {};
58 void FakeAudioOutputStream::GetVolume(double* volume
) {
62 void FakeAudioOutputStream::CallOnMoreData(AudioBus
* audio_bus
) {
63 DCHECK(audio_manager_
->GetWorkerLoop()->BelongsToCurrentThread());
64 callback_
->OnMoreData(audio_bus
, AudioBuffersState());