OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/audio/audio_buffers_state.h" |
10 | 10 |
11 // 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: |
(...skipping 26 matching lines...) Expand all Loading... |
38 | 38 |
39 | 39 |
40 // Models an audio stream that gets rendered to the audio hardware output. | 40 // Models an audio stream that gets rendered to the audio hardware output. |
41 // Because we support more audio streams than physically available channels | 41 // Because we support more audio streams than physically available channels |
42 // a given AudioOutputStream might or might not talk directly to hardware. | 42 // a given AudioOutputStream might or might not talk directly to hardware. |
43 // An audio stream allocates several buffers for audio data and calls | 43 // An audio stream allocates several buffers for audio data and calls |
44 // AudioSourceCallback::OnModeData() periodically to fill these buffers, | 44 // AudioSourceCallback::OnModeData() periodically to fill these buffers, |
45 // as the data is written to the audio device. Size of each packet is determined | 45 // as the data is written to the audio device. Size of each packet is determined |
46 // by |samples_per_packet| specified in AudioParameters when the stream is | 46 // by |samples_per_packet| specified in AudioParameters when the stream is |
47 // created. | 47 // created. |
48 class MEDIA_EXPORT AudioOutputStream { | 48 class AudioOutputStream { |
49 public: | 49 public: |
50 // Audio sources must implement AudioSourceCallback. This interface will be | 50 // Audio sources must implement AudioSourceCallback. This interface will be |
51 // called in a random thread which very likely is a high priority thread. Do | 51 // called in a random thread which very likely is a high priority thread. Do |
52 // not rely on using this thread TLS or make calls that alter the thread | 52 // not rely on using this thread TLS or make calls that alter the thread |
53 // itself such as creating Windows or initializing COM. | 53 // itself such as creating Windows or initializing COM. |
54 class MEDIA_EXPORT AudioSourceCallback { | 54 class AudioSourceCallback { |
55 public: | 55 public: |
56 virtual ~AudioSourceCallback() {} | 56 virtual ~AudioSourceCallback() {} |
57 | 57 |
58 // Provide more data by filling |dest| up to |max_size| bytes. The provided | 58 // Provide more data by filling |dest| up to |max_size| bytes. The provided |
59 // buffer size is determined by the |samples_per_packet| specified in | 59 // buffer size is determined by the |samples_per_packet| specified in |
60 // AudioParameters when the stream is created. The source will return | 60 // AudioParameters when the stream is created. The source will return |
61 // the number of bytes it filled. The expected structure of |dest| is | 61 // the number of bytes it filled. The expected structure of |dest| is |
62 // platform and format specific. | 62 // platform and format specific. |
63 // |buffers_state| contains current state of the buffers, and can be used | 63 // |buffers_state| contains current state of the buffers, and can be used |
64 // by the source to calculate delay. | 64 // by the source to calculate delay. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 virtual void GetVolume(double* volume) = 0; | 97 virtual void GetVolume(double* volume) = 0; |
98 | 98 |
99 // Close the stream. This also generates AudioSourceCallback::OnClose(). | 99 // Close the stream. This also generates AudioSourceCallback::OnClose(). |
100 // After calling this method, the object should not be used anymore. | 100 // After calling this method, the object should not be used anymore. |
101 virtual void Close() = 0; | 101 virtual void Close() = 0; |
102 }; | 102 }; |
103 | 103 |
104 // Models an audio sink receiving recorded audio from the audio driver. | 104 // Models an audio sink receiving recorded audio from the audio driver. |
105 class AudioInputStream { | 105 class AudioInputStream { |
106 public: | 106 public: |
107 class MEDIA_EXPORT AudioInputCallback { | 107 class AudioInputCallback { |
108 public: | 108 public: |
109 virtual ~AudioInputCallback() {} | 109 virtual ~AudioInputCallback() {} |
110 | 110 |
111 // Called by the audio recorder when a full packet of audio data is | 111 // Called by the audio recorder when a full packet of audio data is |
112 // available. This is called from a special audio thread and the | 112 // available. This is called from a special audio thread and the |
113 // implementation should return as soon as possible. | 113 // implementation should return as soon as possible. |
114 virtual void OnData(AudioInputStream* stream, const uint8* src, | 114 virtual void OnData(AudioInputStream* stream, const uint8* src, |
115 uint32 size) = 0; | 115 uint32 size) = 0; |
116 | 116 |
117 // The stream is done with this callback, the last call received by this | 117 // The stream is done with this callback, the last call received by this |
(...skipping 23 matching lines...) Expand all Loading... |
141 | 141 |
142 // Close the stream. This also generates AudioInputCallback::OnClose(). This | 142 // Close the stream. This also generates AudioInputCallback::OnClose(). This |
143 // should be the last call made on this object. | 143 // should be the last call made on this object. |
144 virtual void Close() = 0; | 144 virtual void Close() = 0; |
145 | 145 |
146 protected: | 146 protected: |
147 virtual ~AudioInputStream() {} | 147 virtual ~AudioInputStream() {} |
148 }; | 148 }; |
149 | 149 |
150 #endif // MEDIA_AUDIO_AUDIO_IO_H_ | 150 #endif // MEDIA_AUDIO_AUDIO_IO_H_ |
OLD | NEW |