OLD | NEW |
---|---|
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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/time/time.h" | |
10 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
11 | 12 |
12 // Low-level audio output support. To make sound there are 3 objects involved: | 13 // Low-level audio output support. To make sound there are 3 objects involved: |
13 // - AudioSource : produces audio samples on a pull model. Implements | 14 // - AudioSource : produces audio samples on a pull model. Implements |
14 // the AudioSourceCallback interface. | 15 // the AudioSourceCallback interface. |
15 // - AudioOutputStream : uses the AudioSource to render audio on a given | 16 // - AudioOutputStream : uses the AudioSource to render audio on a given |
16 // channel, format and sample frequency configuration. Data from the | 17 // channel, format and sample frequency configuration. Data from the |
17 // AudioSource is delivered in a 'pull' model. | 18 // AudioSource is delivered in a 'pull' model. |
18 // - AudioManager : factory for the AudioOutputStream objects, manager | 19 // - AudioManager : factory for the AudioOutputStream objects, manager |
19 // of the hardware resources and mixer control. | 20 // of the hardware resources and mixer control. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 class MEDIA_EXPORT AudioSourceCallback { | 59 class MEDIA_EXPORT AudioSourceCallback { |
59 public: | 60 public: |
60 virtual ~AudioSourceCallback() {} | 61 virtual ~AudioSourceCallback() {} |
61 | 62 |
62 // Provide more data by fully filling |dest|. The source will return | 63 // Provide more data by fully filling |dest|. The source will return |
63 // the number of frames it filled. |total_bytes_delay| contains current | 64 // the number of frames it filled. |total_bytes_delay| contains current |
64 // number of bytes of delay buffered by the AudioOutputStream. | 65 // number of bytes of delay buffered by the AudioOutputStream. |
65 // |frames_skipped| contains the number of frames skipped by the consumer. | 66 // |frames_skipped| contains the number of frames skipped by the consumer. |
66 virtual int OnMoreData(AudioBus* dest, | 67 virtual int OnMoreData(AudioBus* dest, |
67 uint32_t total_bytes_delay, | 68 uint32_t total_bytes_delay, |
69 base::TimeDelta delay_timestamp, | |
alokp
2016/06/30 23:37:39
please add comments
jameswest
2016/07/01 00:08:45
Done.
| |
68 uint32_t frames_skipped) = 0; | 70 uint32_t frames_skipped) = 0; |
69 | 71 |
70 // There was an error while playing a buffer. Audio source cannot be | 72 // There was an error while playing a buffer. Audio source cannot be |
71 // destroyed yet. No direct action needed by the AudioStream, but it is | 73 // destroyed yet. No direct action needed by the AudioStream, but it is |
72 // a good place to stop accumulating sound data since is is likely that | 74 // a good place to stop accumulating sound data since is is likely that |
73 // playback will not continue. | 75 // playback will not continue. |
74 virtual void OnError(AudioOutputStream* stream) = 0; | 76 virtual void OnError(AudioOutputStream* stream) = 0; |
75 }; | 77 }; |
76 | 78 |
77 virtual ~AudioOutputStream() {} | 79 virtual ~AudioOutputStream() {} |
(...skipping 29 matching lines...) Expand all Loading... | |
107 public: | 109 public: |
108 class MEDIA_EXPORT AudioInputCallback { | 110 class MEDIA_EXPORT AudioInputCallback { |
109 public: | 111 public: |
110 // Called by the audio recorder when a full packet of audio data is | 112 // Called by the audio recorder when a full packet of audio data is |
111 // available. This is called from a special audio thread and the | 113 // available. This is called from a special audio thread and the |
112 // implementation should return as soon as possible. | 114 // implementation should return as soon as possible. |
113 // TODO(henrika): should be pure virtual when old OnData() is phased out. | 115 // TODO(henrika): should be pure virtual when old OnData() is phased out. |
114 virtual void OnData(AudioInputStream* stream, | 116 virtual void OnData(AudioInputStream* stream, |
115 const AudioBus* source, | 117 const AudioBus* source, |
116 uint32_t hardware_delay_bytes, | 118 uint32_t hardware_delay_bytes, |
117 double volume){}; | 119 double volume) {} |
118 | 120 |
119 // TODO(henrika): don't use; to be removed. | 121 // TODO(henrika): don't use; to be removed. |
120 virtual void OnData(AudioInputStream* stream, | 122 virtual void OnData(AudioInputStream* stream, |
121 const uint8_t* src, | 123 const uint8_t* src, |
122 uint32_t size, | 124 uint32_t size, |
123 uint32_t hardware_delay_bytes, | 125 uint32_t hardware_delay_bytes, |
124 double volume){}; | 126 double volume) {} |
125 | 127 |
126 // There was an error while recording audio. The audio sink cannot be | 128 // There was an error while recording audio. The audio sink cannot be |
127 // destroyed yet. No direct action needed by the AudioInputStream, but it | 129 // destroyed yet. No direct action needed by the AudioInputStream, but it |
128 // is a good place to stop accumulating sound data since is is likely that | 130 // is a good place to stop accumulating sound data since is is likely that |
129 // recording will not continue. | 131 // recording will not continue. |
130 virtual void OnError(AudioInputStream* stream) = 0; | 132 virtual void OnError(AudioInputStream* stream) = 0; |
131 | 133 |
132 protected: | 134 protected: |
133 virtual ~AudioInputCallback() {} | 135 virtual ~AudioInputCallback() {} |
134 }; | 136 }; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 // Returns the Automatic Gain Control (AGC) state. | 170 // Returns the Automatic Gain Control (AGC) state. |
169 virtual bool GetAutomaticGainControl() = 0; | 171 virtual bool GetAutomaticGainControl() = 0; |
170 | 172 |
171 // Returns the current muting state for the microphone. | 173 // Returns the current muting state for the microphone. |
172 virtual bool IsMuted() = 0; | 174 virtual bool IsMuted() = 0; |
173 }; | 175 }; |
174 | 176 |
175 } // namespace media | 177 } // namespace media |
176 | 178 |
177 #endif // MEDIA_AUDIO_AUDIO_IO_H_ | 179 #endif // MEDIA_AUDIO_AUDIO_IO_H_ |
OLD | NEW |