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

Side by Side Diff: media/audio/audio_io.h

Issue 11413078: Tab Audio Capture: Browser-side connect/disconnect functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move Diverter interface into audio_io.h. Replace use of singleton with BrowserMainLoop. Created 7 years, 11 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_AUDIO_AUDIO_IO_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_IO_H_
6 #define MEDIA_AUDIO_AUDIO_IO_H_ 6 #define MEDIA_AUDIO_AUDIO_IO_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "media/audio/audio_buffers_state.h" 9 #include "media/audio/audio_buffers_state.h"
10 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // Because we support more audio streams than physically available channels 42 // Because we support more audio streams than physically available channels
43 // a given AudioOutputStream might or might not talk directly to hardware. 43 // a given AudioOutputStream might or might not talk directly to hardware.
44 // An audio stream allocates several buffers for audio data and calls 44 // An audio stream allocates several buffers for audio data and calls
45 // AudioSourceCallback::OnMoreData() periodically to fill these buffers, 45 // AudioSourceCallback::OnMoreData() periodically to fill these buffers,
46 // as the data is written to the audio device. Size of each packet is determined 46 // as the data is written to the audio device. Size of each packet is determined
47 // by |samples_per_packet| specified in AudioParameters when the stream is 47 // by |samples_per_packet| specified in AudioParameters when the stream is
48 // created. 48 // created.
49 49
50 namespace media { 50 namespace media {
51 51
52 class AudioParameters;
53
52 class MEDIA_EXPORT AudioOutputStream { 54 class MEDIA_EXPORT AudioOutputStream {
53 public: 55 public:
54 // Audio sources must implement AudioSourceCallback. This interface will be 56 // Audio sources must implement AudioSourceCallback. This interface will be
55 // called in a random thread which very likely is a high priority thread. Do 57 // called in a random thread which very likely is a high priority thread. Do
56 // not rely on using this thread TLS or make calls that alter the thread 58 // not rely on using this thread TLS or make calls that alter the thread
57 // itself such as creating Windows or initializing COM. 59 // itself such as creating Windows or initializing COM.
58 class MEDIA_EXPORT AudioSourceCallback { 60 class MEDIA_EXPORT AudioSourceCallback {
59 public: 61 public:
60 // Provide more data by fully filling |dest|. The source will return 62 // Provide more data by fully filling |dest|. The source will return
61 // the number of frames it filled. |buffers_state| contains current state 63 // the number of frames it filled. |buffers_state| contains current state
(...skipping 15 matching lines...) Expand all
77 // Deprecated. DO NOT USE. Waits until data becomes available. Used only 79 // Deprecated. DO NOT USE. Waits until data becomes available. Used only
78 // by Windows' WaveOut clients which may be extremely laggy. Will yield the 80 // by Windows' WaveOut clients which may be extremely laggy. Will yield the
79 // current thread until the renderer client has written its audio data or 81 // current thread until the renderer client has written its audio data or
80 // 1.5 seconds have elapsed. 82 // 1.5 seconds have elapsed.
81 virtual void WaitTillDataReady() {} 83 virtual void WaitTillDataReady() {}
82 84
83 protected: 85 protected:
84 virtual ~AudioSourceCallback() {} 86 virtual ~AudioSourceCallback() {}
85 }; 87 };
86 88
89 // Audio sources may optionally implement AudioSourceDiverter to temporarily
90 // divert audio data to an alternate AudioOutputStream. This allows the
91 // audio data to be plumbed to an alternate consumer; for example, a loopback
92 // mechanism for audio mirroring.
93 class MEDIA_EXPORT AudioSourceDiverter {
DaleCurtis 2013/01/08 19:23:33 Does this need to be nested with AudioOutputStream
miu 2013/01/09 02:19:41 Done. Moved to: base/audio/audio_source_diverter.
94 public:
95 // Returns the audio parameters of the divertable audio data.
96 virtual const AudioParameters& GetAudioParameters() = 0;
97
98 // Start providing audio data to the given |to_stream|, which is in an
99 // unopened state. |to_stream| remains under the control of the
100 // AudioSourceDiverter.
101 virtual void StartDiverting(AudioOutputStream* to_stream) = 0;
102
103 // Stops diverting audio data to the stream. The AudioSourceDiverter is
104 // responsible for making sure the stream is closed, perhaps asynchronously.
105 virtual void StopDiverting() = 0;
106
107 protected:
108 virtual ~AudioSourceDiverter() {}
109 };
110
87 virtual ~AudioOutputStream() {} 111 virtual ~AudioOutputStream() {}
88 112
89 // Open the stream. false is returned if the stream cannot be opened. Open() 113 // Open the stream. false is returned if the stream cannot be opened. Open()
90 // must always be followed by a call to Close() even if Open() fails. 114 // must always be followed by a call to Close() even if Open() fails.
91 virtual bool Open() = 0; 115 virtual bool Open() = 0;
92 116
93 // Starts playing audio and generating AudioSourceCallback::OnMoreData(). 117 // Starts playing audio and generating AudioSourceCallback::OnMoreData().
94 // Since implementor of AudioOutputStream may have internal buffers, right 118 // Since implementor of AudioOutputStream may have internal buffers, right
95 // after calling this method initial buffers are fetched. 119 // after calling this method initial buffers are fetched.
96 // 120 //
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 // Sets the Automatic Gain Control (AGC) state. 195 // Sets the Automatic Gain Control (AGC) state.
172 virtual void SetAutomaticGainControl(bool enabled) = 0; 196 virtual void SetAutomaticGainControl(bool enabled) = 0;
173 197
174 // Returns the Automatic Gain Control (AGC) state. 198 // Returns the Automatic Gain Control (AGC) state.
175 virtual bool GetAutomaticGainControl() = 0; 199 virtual bool GetAutomaticGainControl() = 0;
176 }; 200 };
177 201
178 } // namespace media 202 } // namespace media
179 203
180 #endif // MEDIA_AUDIO_AUDIO_IO_H_ 204 #endif // MEDIA_AUDIO_AUDIO_IO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698