Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 // Provide more data by filling |dest| up to |max_size| bytes. The provided | 53 // Provide more data by filling |dest| up to |max_size| bytes. The provided |
| 54 // buffer size is usually what is specified in Open(). The source | 54 // buffer size is usually what is specified in Open(). The source |
| 55 // will return the number of bytes it filled. The expected structure of | 55 // will return the number of bytes it filled. The expected structure of |
| 56 // |dest| is platform and format specific. | 56 // |dest| is platform and format specific. |
| 57 // |pending_bytes| is the number of bytes will be played before the | 57 // |pending_bytes| is the number of bytes will be played before the |
| 58 // requested data is played. | 58 // requested data is played. |
| 59 virtual uint32 OnMoreData( | 59 virtual uint32 OnMoreData( |
| 60 AudioOutputStream* stream, uint8* dest, uint32 max_size, | 60 AudioOutputStream* stream, uint8* dest, uint32 max_size, |
| 61 AudioBuffersState buffers_state) = 0; | 61 AudioBuffersState buffers_state) = 0; |
| 62 | 62 |
| 63 // The stream is done with this callback. After this call the audio source | |
| 64 // can go away or be destroyed. | |
| 65 virtual void OnClose(AudioOutputStream* stream) = 0; | |
| 66 | |
| 67 // There was an error while playing a buffer. Audio source cannot be | 63 // There was an error while playing a buffer. Audio source cannot be |
| 68 // destroyed yet. No direct action needed by the AudioStream, but it is | 64 // destroyed yet. No direct action needed by the AudioStream, but it is |
| 69 // a good place to stop accumulating sound data since is is likely that | 65 // a good place to stop accumulating sound data since is is likely that |
| 70 // playback will not continue. |code| is an error code that is platform | 66 // playback will not continue. |code| is an error code that is platform |
| 71 // specific. | 67 // specific. |
| 72 virtual void OnError(AudioOutputStream* stream, int code) = 0; | 68 virtual void OnError(AudioOutputStream* stream, int code) = 0; |
| 73 }; | 69 }; |
| 74 | 70 |
| 75 // Open the stream. |packet_size| is the requested buffer allocation which | 71 // Open the stream. |
|
scherkus (not reviewing)
2010/11/09 02:28:31
so a lot of the comments went away
does it not ap
Sergey Ulanov
2010/11/09 22:29:58
The comments about |packet_size| do not apply anym
| |
| 76 // the audio source thinks it can usually fill without blocking. Internally | 72 virtual bool Open() = 0; |
| 77 // two or three buffers of |packet_size| size are created, one will be | |
| 78 // locked for playback and one will be ready to be filled in the call to | |
| 79 // AudioSourceCallback::OnMoreData(). | |
| 80 // The number of buffers is controlled by AUDIO_PCM_LOW_LATENCY. See more | |
| 81 // information below. | |
| 82 // | |
| 83 // TODO(ajwong): Streams are not reusable, so try to move packet_size into the | |
| 84 // constructor. | |
| 85 virtual bool Open(uint32 packet_size) = 0; | |
| 86 | 73 |
| 87 // Starts playing audio and generating AudioSourceCallback::OnMoreData(). | 74 // Starts playing audio and generating AudioSourceCallback::OnMoreData(). |
| 88 // Since implementor of AudioOutputStream may have internal buffers, right | 75 // Since implementor of AudioOutputStream may have internal buffers, right |
| 89 // after calling this method initial buffers are fetched. | 76 // after calling this method initial buffers are fetched. |
| 90 // | 77 // |
| 91 // The output stream does not take ownership of this callback. | 78 // The output stream does not take ownership of this callback. |
| 92 virtual void Start(AudioSourceCallback* callback) = 0; | 79 virtual void Start(AudioSourceCallback* callback) = 0; |
| 93 | 80 |
| 94 // Stops playing audio. Effect might not be instantaneous as the hardware | 81 // Stops playing audio. Effect might not be instantaneous as the hardware |
| 95 // might have locked audio data that is processing. | 82 // might have locked audio data that is processing. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 | 136 |
| 150 // Close the stream. This also generates AudioInputCallback::OnClose(). This | 137 // Close the stream. This also generates AudioInputCallback::OnClose(). This |
| 151 // should be the last call made on this object. | 138 // should be the last call made on this object. |
| 152 virtual void Close() = 0; | 139 virtual void Close() = 0; |
| 153 | 140 |
| 154 protected: | 141 protected: |
| 155 virtual ~AudioInputStream() {} | 142 virtual ~AudioInputStream() {} |
| 156 }; | 143 }; |
| 157 | 144 |
| 158 #endif // MEDIA_AUDIO_AUDIO_IO_H_ | 145 #endif // MEDIA_AUDIO_AUDIO_IO_H_ |
| OLD | NEW |