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

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

Issue 11298006: Browser-wide audio mirroring for TabCapture API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix TabCapture API test Created 8 years, 1 month 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
OLDNEW
(Empty)
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.
4
5 #include "media/audio/virtual_audio_output_stream.h"
6
7 #include "base/message_loop.h"
8 #include "media/audio/audio_manager_base.h"
9
10 namespace media {
11
12 // static
13 VirtualAudioOutputStream* VirtualAudioOutputStream::MakeStream(
14 AudioManagerBase* manager, const AudioParameters& params) {
15 return new VirtualAudioOutputStream(manager, params);
16 }
17
18 VirtualAudioOutputStream::VirtualAudioOutputStream(
19 AudioManagerBase* manager, const AudioParameters& params)
20 : audio_manager_(manager),
21 callback_(NULL),
22 volume_(1.0f) {
23 }
24
25 VirtualAudioOutputStream::~VirtualAudioOutputStream() {
26 DCHECK(!callback_);
27 }
28
29 bool VirtualAudioOutputStream::Open() {
30 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
31 return true;
32 }
33
34 void VirtualAudioOutputStream::Start(AudioSourceCallback* callback) {
35 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
36 callback_ = callback;
37 }
38
39 void VirtualAudioOutputStream::Stop() {
40 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
41 callback_ = NULL;
42 }
43
44 void VirtualAudioOutputStream::Close() {
45 DCHECK(!callback_);
46 DCHECK(audio_manager_->GetMessageLoop()->BelongsToCurrentThread());
47 audio_manager_->ReleaseOutputStream(this);
48 }
49
50 void VirtualAudioOutputStream::SetVolume(double volume) {
51 volume_ = static_cast<float>(volume);
52 }
53
54 void VirtualAudioOutputStream::GetVolume(double* volume) {
55 *volume = volume_;
56 }
57
58 double VirtualAudioOutputStream::ProvideInput(
59 AudioBus* audio_bus, base::TimeDelta buffer_delay) {
60 if (callback_ == NULL)
DaleCurtis 2012/11/21 23:45:43 if (!callback) You need to DCHECK that this is on
justinlin 2012/11/26 20:19:20 Done.
61 return 0;
62
63 audio_bus->Zero();
DaleCurtis 2012/11/21 23:45:43 I'd just ZeroFramesPartial() if frames < audio_bus
justinlin 2012/11/26 20:19:20 Done.
64 int frames = callback_->OnMoreData(audio_bus, AudioBuffersState());
65
66 return frames > 0 ? 1 : 0;
67 }
68
69 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698