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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 // called in a random thread which very likely is a high priority thread. Do | 56 // 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 | 57 // not rely on using this thread TLS or make calls that alter the thread |
57 // itself such as creating Windows or initializing COM. | 58 // itself such as creating Windows or initializing COM. |
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. |
66 // |delay_timestamp| is the time at which |total_bytes_delay| was measured. | |
65 // |frames_skipped| contains the number of frames skipped by the consumer. | 67 // |frames_skipped| contains the number of frames skipped by the consumer. |
66 virtual int OnMoreData(AudioBus* dest, | 68 virtual int OnMoreData(AudioBus* dest, |
67 uint32_t total_bytes_delay, | 69 uint32_t total_bytes_delay, |
70 base::TimeDelta delay_timestamp, | |
miu
2016/07/14 21:08:55
If "delay_timestamp is the time at which total_byt
| |
68 uint32_t frames_skipped) = 0; | 71 uint32_t frames_skipped) = 0; |
69 | 72 |
70 // There was an error while playing a buffer. Audio source cannot be | 73 // 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 | 74 // 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 | 75 // a good place to stop accumulating sound data since is is likely that |
73 // playback will not continue. | 76 // playback will not continue. |
74 virtual void OnError(AudioOutputStream* stream) = 0; | 77 virtual void OnError(AudioOutputStream* stream) = 0; |
75 }; | 78 }; |
76 | 79 |
77 virtual ~AudioOutputStream() {} | 80 virtual ~AudioOutputStream() {} |
(...skipping 29 matching lines...) Expand all Loading... | |
107 public: | 110 public: |
108 class MEDIA_EXPORT AudioInputCallback { | 111 class MEDIA_EXPORT AudioInputCallback { |
109 public: | 112 public: |
110 // Called by the audio recorder when a full packet of audio data is | 113 // 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 | 114 // available. This is called from a special audio thread and the |
112 // implementation should return as soon as possible. | 115 // implementation should return as soon as possible. |
113 // TODO(henrika): should be pure virtual when old OnData() is phased out. | 116 // TODO(henrika): should be pure virtual when old OnData() is phased out. |
114 virtual void OnData(AudioInputStream* stream, | 117 virtual void OnData(AudioInputStream* stream, |
115 const AudioBus* source, | 118 const AudioBus* source, |
116 uint32_t hardware_delay_bytes, | 119 uint32_t hardware_delay_bytes, |
117 double volume){}; | 120 double volume) {} |
118 | 121 |
119 // TODO(henrika): don't use; to be removed. | 122 // TODO(henrika): don't use; to be removed. |
120 virtual void OnData(AudioInputStream* stream, | 123 virtual void OnData(AudioInputStream* stream, |
121 const uint8_t* src, | 124 const uint8_t* src, |
122 uint32_t size, | 125 uint32_t size, |
123 uint32_t hardware_delay_bytes, | 126 uint32_t hardware_delay_bytes, |
124 double volume){}; | 127 double volume) {} |
125 | 128 |
126 // There was an error while recording audio. The audio sink cannot be | 129 // There was an error while recording audio. The audio sink cannot be |
127 // destroyed yet. No direct action needed by the AudioInputStream, but it | 130 // 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 | 131 // is a good place to stop accumulating sound data since is is likely that |
129 // recording will not continue. | 132 // recording will not continue. |
130 virtual void OnError(AudioInputStream* stream) = 0; | 133 virtual void OnError(AudioInputStream* stream) = 0; |
131 | 134 |
132 protected: | 135 protected: |
133 virtual ~AudioInputCallback() {} | 136 virtual ~AudioInputCallback() {} |
134 }; | 137 }; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 // Returns the Automatic Gain Control (AGC) state. | 171 // Returns the Automatic Gain Control (AGC) state. |
169 virtual bool GetAutomaticGainControl() = 0; | 172 virtual bool GetAutomaticGainControl() = 0; |
170 | 173 |
171 // Returns the current muting state for the microphone. | 174 // Returns the current muting state for the microphone. |
172 virtual bool IsMuted() = 0; | 175 virtual bool IsMuted() = 0; |
173 }; | 176 }; |
174 | 177 |
175 } // namespace media | 178 } // namespace media |
176 | 179 |
177 #endif // MEDIA_AUDIO_AUDIO_IO_H_ | 180 #endif // MEDIA_AUDIO_AUDIO_IO_H_ |
OLD | NEW |