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