Switch to using the new app install flow
[chromium-blink-merge.git] / media / audio / fake_audio_output_stream.cc
blobb919b84ccf986ecb9dd4b5a7ea7b2bc8256b935e
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/single_thread_task_runner.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_worker_(manager->GetWorkerTaskRunner(), params),
26 audio_bus_(AudioBus::Create(params)) {
29 FakeAudioOutputStream::~FakeAudioOutputStream() {
30 DCHECK(!callback_);
33 bool FakeAudioOutputStream::Open() {
34 DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
35 audio_bus_->Zero();
36 return true;
39 void FakeAudioOutputStream::Start(AudioSourceCallback* callback) {
40 DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
41 callback_ = callback;
42 fake_worker_.Start(base::Bind(
43 &FakeAudioOutputStream::CallOnMoreData, base::Unretained(this)));
46 void FakeAudioOutputStream::Stop() {
47 DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
48 fake_worker_.Stop();
49 callback_ = NULL;
52 void FakeAudioOutputStream::Close() {
53 DCHECK(!callback_);
54 DCHECK(audio_manager_->GetTaskRunner()->BelongsToCurrentThread());
55 audio_manager_->ReleaseOutputStream(this);
58 void FakeAudioOutputStream::SetVolume(double volume) {};
60 void FakeAudioOutputStream::GetVolume(double* volume) {
61 *volume = 0;
64 void FakeAudioOutputStream::CallOnMoreData() {
65 DCHECK(audio_manager_->GetWorkerTaskRunner()->BelongsToCurrentThread());
66 callback_->OnMoreData(audio_bus_.get(), 0);
69 } // namespace media