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 "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "media/audio/audio_buffers_state.h" | |
10 #include "media/base/audio_bus.h" | 9 #include "media/base/audio_bus.h" |
11 | 10 |
12 // Low-level audio output support. To make sound there are 3 objects involved: | 11 // Low-level audio output support. To make sound there are 3 objects involved: |
13 // - AudioSource : produces audio samples on a pull model. Implements | 12 // - AudioSource : produces audio samples on a pull model. Implements |
14 // the AudioSourceCallback interface. | 13 // the AudioSourceCallback interface. |
15 // - AudioOutputStream : uses the AudioSource to render audio on a given | 14 // - AudioOutputStream : uses the AudioSource to render audio on a given |
16 // channel, format and sample frequency configuration. Data from the | 15 // channel, format and sample frequency configuration. Data from the |
17 // AudioSource is delivered in a 'pull' model. | 16 // AudioSource is delivered in a 'pull' model. |
18 // - AudioManager : factory for the AudioOutputStream objects, manager | 17 // - AudioManager : factory for the AudioOutputStream objects, manager |
19 // of the hardware resources and mixer control. | 18 // of the hardware resources and mixer control. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 50 |
52 class MEDIA_EXPORT AudioOutputStream { | 51 class MEDIA_EXPORT AudioOutputStream { |
53 public: | 52 public: |
54 // Audio sources must implement AudioSourceCallback. This interface will be | 53 // Audio sources must implement AudioSourceCallback. This interface will be |
55 // called in a random thread which very likely is a high priority thread. Do | 54 // 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 | 55 // not rely on using this thread TLS or make calls that alter the thread |
57 // itself such as creating Windows or initializing COM. | 56 // itself such as creating Windows or initializing COM. |
58 class MEDIA_EXPORT AudioSourceCallback { | 57 class MEDIA_EXPORT AudioSourceCallback { |
59 public: | 58 public: |
60 // Provide more data by fully filling |dest|. The source will return | 59 // Provide more data by fully filling |dest|. The source will return |
61 // the number of frames it filled. |buffers_state| contains current state | 60 // the number of frames it filled. |total_bytes_delay| contains current |
62 // of the buffers, and can be used by the source to calculate delay. | 61 // number of bytes of delay buffered by the AudioOutputStream. |
63 virtual int OnMoreData(AudioBus* dest, | 62 virtual int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) = 0; |
64 AudioBuffersState buffers_state) = 0; | |
65 | 63 |
66 // There was an error while playing a buffer. Audio source cannot be | 64 // There was an error while playing a buffer. Audio source cannot be |
67 // destroyed yet. No direct action needed by the AudioStream, but it is | 65 // destroyed yet. No direct action needed by the AudioStream, but it is |
68 // a good place to stop accumulating sound data since is is likely that | 66 // a good place to stop accumulating sound data since is is likely that |
69 // playback will not continue. | 67 // playback will not continue. |
70 virtual void OnError(AudioOutputStream* stream) = 0; | 68 virtual void OnError(AudioOutputStream* stream) = 0; |
71 | 69 |
72 protected: | 70 protected: |
73 virtual ~AudioSourceCallback() {} | 71 virtual ~AudioSourceCallback() {} |
74 }; | 72 }; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // Sets the Automatic Gain Control (AGC) state. | 162 // Sets the Automatic Gain Control (AGC) state. |
165 virtual void SetAutomaticGainControl(bool enabled) = 0; | 163 virtual void SetAutomaticGainControl(bool enabled) = 0; |
166 | 164 |
167 // Returns the Automatic Gain Control (AGC) state. | 165 // Returns the Automatic Gain Control (AGC) state. |
168 virtual bool GetAutomaticGainControl() = 0; | 166 virtual bool GetAutomaticGainControl() = 0; |
169 }; | 167 }; |
170 | 168 |
171 } // namespace media | 169 } // namespace media |
172 | 170 |
173 #endif // MEDIA_AUDIO_AUDIO_IO_H_ | 171 #endif // MEDIA_AUDIO_AUDIO_IO_H_ |
OLD | NEW |