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/single_thread_task_runner.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_worker_(manager
->GetWorkerTaskRunner(), params
),
26 audio_bus_(AudioBus::Create(params
)) {
29 FakeAudioOutputStream::~FakeAudioOutputStream() {
33 bool FakeAudioOutputStream::Open() {
34 DCHECK(audio_manager_
->GetTaskRunner()->BelongsToCurrentThread());
39 void FakeAudioOutputStream::Start(AudioSourceCallback
* callback
) {
40 DCHECK(audio_manager_
->GetTaskRunner()->BelongsToCurrentThread());
42 fake_worker_
.Start(base::Bind(
43 &FakeAudioOutputStream::CallOnMoreData
, base::Unretained(this)));
46 void FakeAudioOutputStream::Stop() {
47 DCHECK(audio_manager_
->GetTaskRunner()->BelongsToCurrentThread());
52 void FakeAudioOutputStream::Close() {
54 DCHECK(audio_manager_
->GetTaskRunner()->BelongsToCurrentThread());
55 audio_manager_
->ReleaseOutputStream(this);
58 void FakeAudioOutputStream::SetVolume(double volume
) {};
60 void FakeAudioOutputStream::GetVolume(double* volume
) {
64 void FakeAudioOutputStream::CallOnMoreData() {
65 DCHECK(audio_manager_
->GetWorkerTaskRunner()->BelongsToCurrentThread());
66 callback_
->OnMoreData(audio_bus_
.get(), 0);