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

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

Issue 10830268: Allow audio system to handle synchronized low-latency audio I/O (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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_OUTPUT_CONTROLLER_H_ 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // synchronous reading. 85 // synchronous reading.
86 class SyncReader { 86 class SyncReader {
87 public: 87 public:
88 virtual ~SyncReader() {} 88 virtual ~SyncReader() {}
89 89
90 // Notify the synchronous reader the number of bytes in the 90 // Notify the synchronous reader the number of bytes in the
91 // AudioOutputController not yet played. This is used by SyncReader to 91 // AudioOutputController not yet played. This is used by SyncReader to
92 // prepare more data and perform synchronization. 92 // prepare more data and perform synchronization.
93 virtual void UpdatePendingBytes(uint32 bytes) = 0; 93 virtual void UpdatePendingBytes(uint32 bytes) = 0;
94 94
95 // Attempt to completely fill |audio_bus|, return the actual number of 95 // Attempt to completely fill |dest|, return the actual number of
96 // frames that could be read. 96 // frames that could be read.
97 virtual int Read(AudioBus* audio_bus) = 0; 97 // |source| may optionally be provided for input data.
98 virtual int Read(AudioBus* source, AudioBus* dest) = 0;
DaleCurtis 2012/09/11 09:44:39 This is a bit confusing now; SyncReader and Read()
scherkus (not reviewing) 2012/09/11 12:13:00 Do you have a suggestion for a name? Perhaps we ca
DaleCurtis 2012/09/11 12:22:23 TODO-ify is fine with me. No suggestions that I ac
98 99
99 // Close this synchronous reader. 100 // Close this synchronous reader.
100 virtual void Close() = 0; 101 virtual void Close() = 0;
101 102
102 // Poll if data is ready. 103 // Poll if data is ready.
103 // Not reliable, as there is no guarantee that renderer is "new-style" 104 // Not reliable, as there is no guarantee that renderer is "new-style"
104 // renderer that writes metadata into buffer. After several unsuccessful 105 // renderer that writes metadata into buffer. After several unsuccessful
105 // attempts caller should assume the data is ready even if that function 106 // attempts caller should assume the data is ready even if that function
106 // returns false. 107 // returns false.
107 virtual bool DataReady() = 0; 108 virtual bool DataReady() = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // will have no effect. 140 // will have no effect.
140 void Close(const base::Closure& closed_task); 141 void Close(const base::Closure& closed_task);
141 142
142 // Sets the volume of the audio output stream. 143 // Sets the volume of the audio output stream.
143 void SetVolume(double volume); 144 void SetVolume(double volume);
144 145
145 /////////////////////////////////////////////////////////////////////////// 146 ///////////////////////////////////////////////////////////////////////////
146 // AudioSourceCallback methods. 147 // AudioSourceCallback methods.
147 virtual int OnMoreData(AudioBus* audio_bus, 148 virtual int OnMoreData(AudioBus* audio_bus,
148 AudioBuffersState buffers_state) OVERRIDE; 149 AudioBuffersState buffers_state) OVERRIDE;
150 virtual int OnMoreIOData(AudioBus* source,
151 AudioBus* dest,
152 AudioBuffersState buffers_state) OVERRIDE;
149 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; 153 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE;
150 virtual void WaitTillDataReady() OVERRIDE; 154 virtual void WaitTillDataReady() OVERRIDE;
151 155
152 protected: 156 protected:
153 // Internal state of the source. 157 // Internal state of the source.
154 enum State { 158 enum State {
155 kEmpty, 159 kEmpty,
156 kCreated, 160 kCreated,
157 kPlaying, 161 kPlaying,
158 kStarting, 162 kStarting,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // shutdown and force it to wait for the most delayed task. 228 // shutdown and force it to wait for the most delayed task.
225 // Also, if we're shutting down, we do not want to poll for more data. 229 // Also, if we're shutting down, we do not want to poll for more data.
226 base::WeakPtrFactory<AudioOutputController> weak_this_; 230 base::WeakPtrFactory<AudioOutputController> weak_this_;
227 231
228 DISALLOW_COPY_AND_ASSIGN(AudioOutputController); 232 DISALLOW_COPY_AND_ASSIGN(AudioOutputController);
229 }; 233 };
230 234
231 } // namespace media 235 } // namespace media
232 236
233 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_ 237 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698