OLD | NEW |
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_H_ |
6 #define MEDIA_AUDIO_AUDIO_OUTPUT_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 | 9 |
10 // Low-level audio output support. To make sound there are 3 objects involved: | 10 // Low-level audio output support. To make sound there are 3 objects involved: |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // Since implementor of AudioOutputStream may have internal buffers, right | 84 // Since implementor of AudioOutputStream may have internal buffers, right |
85 // after calling this method initial buffers are fetched. | 85 // after calling this method initial buffers are fetched. |
86 // | 86 // |
87 // The output stream does not take ownership of this callback. | 87 // The output stream does not take ownership of this callback. |
88 virtual void Start(AudioSourceCallback* callback) = 0; | 88 virtual void Start(AudioSourceCallback* callback) = 0; |
89 | 89 |
90 // Stops playing audio. Effect might not be instantaneous as the hardware | 90 // Stops playing audio. Effect might not be instantaneous as the hardware |
91 // might have locked audio data that is processing. | 91 // might have locked audio data that is processing. |
92 virtual void Stop() = 0; | 92 virtual void Stop() = 0; |
93 | 93 |
94 // Sets the relative volume, with range [0.0, 1.0] inclusive. For mono audio | 94 // Sets the relative volume, with range [0.0, 1.0] inclusive. |
95 // sources the volume must be the same in both channels. | 95 virtual void SetVolume(double volume) = 0; |
96 virtual void SetVolume(double left_level, double right_level) = 0; | |
97 | 96 |
98 // Gets the relative volume, with range [0.0, 1.0] inclusive. For mono audio | 97 // Gets the relative volume, with range [0.0, 1.0] inclusive. |
99 // sources the level is returned in both channels. | 98 virtual void GetVolume(double* volume) = 0; |
100 virtual void GetVolume(double* left_level, double* right_level) = 0; | |
101 | 99 |
102 // Close the stream. This also generates AudioSourceCallback::OnClose(). | 100 // Close the stream. This also generates AudioSourceCallback::OnClose(). |
103 // After calling this method, the object should not be used anymore. | 101 // After calling this method, the object should not be used anymore. |
104 virtual void Close() = 0; | 102 virtual void Close() = 0; |
105 | 103 |
106 protected: | 104 protected: |
107 virtual ~AudioOutputStream() {} | 105 virtual ~AudioOutputStream() {} |
108 }; | 106 }; |
109 | 107 |
110 // Manages all audio resources. In particular it owns the AudioOutputStream | 108 // Manages all audio resources. In particular it owns the AudioOutputStream |
111 // objects. Provides some convenience functions that avoid the need to provide | 109 // objects. Provides some convenience functions that avoid the need to provide |
112 // iterators over the existing streams. | 110 // iterators over the existing streams. |
113 class AudioManager { | 111 class AudioManager { |
114 public: | 112 public: |
115 enum Format { | 113 enum Format { |
116 AUDIO_PCM_LINEAR = 0, // Pulse code modulation means 'raw' amplitude | 114 AUDIO_PCM_LINEAR = 0, // Pulse code modulation means 'raw' amplitude |
117 // samples. | 115 // samples. |
118 AUDIO_PCM_DELTA, // Delta-encoded pulse code modulation. | 116 AUDIO_PCM_DELTA, // Delta-encoded pulse code modulation. |
119 AUDIO_MOCK, // Creates a dummy AudioOutputStream object. | 117 AUDIO_MOCK, // Creates a dummy AudioOutputStream object. |
120 AUDIO_LAST_FORMAT // Only used for validation of format. | 118 AUDIO_LAST_FORMAT // Only used for validation of format. |
121 }; | 119 }; |
122 | 120 |
123 // Telephone quality sample rate, mostly for speech-only audio. | 121 // Telephone quality sample rate, mostly for speech-only audio. |
124 static const int kTelephoneSampleRate = 8000; | 122 static const int kTelephoneSampleRate = 8000; |
125 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. | 123 // CD sampling rate is 44.1 KHz or conveniently 2x2x3x3x5x5x7x7. |
126 static const int kAudioCDSampleRate = 44100; | 124 static const int kAudioCDSampleRate = 44100; |
127 // Digital Audio Tape sample rate. | 125 // Digital Audio Tape sample rate. |
128 static const int kAudioDATSampleRate = 48000; | 126 static const int kAudioDATSampleRate = 48000; |
129 | 127 |
130 // Returns true if the OS reports existence of audio devices. This does not | 128 // Returns true if the OS reports existence of audio devices. This does not |
(...skipping 20 matching lines...) Expand all Loading... |
151 // Get AudioManager singleton. | 149 // Get AudioManager singleton. |
152 // TODO(cpu): Define threading requirements for interacting with AudioManager. | 150 // TODO(cpu): Define threading requirements for interacting with AudioManager. |
153 static AudioManager* GetAudioManager(); | 151 static AudioManager* GetAudioManager(); |
154 | 152 |
155 protected: | 153 protected: |
156 virtual ~AudioManager() {} | 154 virtual ~AudioManager() {} |
157 }; | 155 }; |
158 | 156 |
159 | 157 |
160 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_H_ | 158 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_H_ |
OLD | NEW |