Chromium Code Reviews| Index: webrtc/modules/audio_device/fine_audio_buffer.h |
| diff --git a/webrtc/modules/audio_device/fine_audio_buffer.h b/webrtc/modules/audio_device/fine_audio_buffer.h |
| index 306f9d24d377a7fe3ec31e0d01e298f86bf2db63..5ccb648b5df65306a024e970492595618eb94b5d 100644 |
| --- a/webrtc/modules/audio_device/fine_audio_buffer.h |
| +++ b/webrtc/modules/audio_device/fine_audio_buffer.h |
| @@ -13,6 +13,7 @@ |
| #include <memory> |
| +#include "webrtc/base/array_view.h" |
| #include "webrtc/base/buffer.h" |
| #include "webrtc/typedefs.h" |
| @@ -28,27 +29,26 @@ class AudioDeviceBuffer; |
| // in 10ms chunks when the size of the provided audio buffers differs from 10ms. |
| // As an example: calling DeliverRecordedData() with 5ms buffers will deliver |
| // accumulated 10ms worth of data to the ADB every second call. |
| +// TODO(henrika): add support for stereo when mobile platforms need it. |
| class FineAudioBuffer { |
| public: |
| // |device_buffer| is a buffer that provides 10ms of audio data. |
| - // |desired_frame_size_bytes| is the number of bytes of audio data |
| - // GetPlayoutData() should return on success. It is also the required size of |
| - // each recorded buffer used in DeliverRecordedData() calls. |
| // |sample_rate| is the sample rate of the audio data. This is needed because |
| // |device_buffer| delivers 10ms of data. Given the sample rate the number |
| - // of samples can be calculated. |
| + // of samples can be calculated. The |capacity| ensures that the buffer size |
| + // can be increased to at least capacity without further reallocation. |
| FineAudioBuffer(AudioDeviceBuffer* device_buffer, |
| - size_t desired_frame_size_bytes, |
| - int sample_rate); |
| + int sample_rate, |
| + size_t capacity); |
| ~FineAudioBuffer(); |
| // Clears buffers and counters dealing with playour and/or recording. |
| void ResetPlayout(); |
| void ResetRecord(); |
| - // |buffer| must be of equal or greater size than what is returned by |
| - // RequiredBufferSize(). This is to avoid unnecessary memcpy. |
| - void GetPlayoutData(int8_t* buffer); |
| + // Copies audio samples into |audio_buffer| where number of requested |
| + // elements is specified by |audio.buffer.size()|. |
|
kwiberg-webrtc
2017/05/29 04:09:02
One . should be _
henrika_webrtc
2017/05/29 10:33:51
Done.
|
| + void GetPlayoutData(rtc::ArrayView<int8_t> audio_buffer); |
|
kwiberg-webrtc
2017/05/29 04:09:02
Can it ever be the case that you're not able to fi
henrika_webrtc
2017/05/29 10:33:51
No. We ask native WebRTC until we get enough and i
kwiberg-webrtc
2017/05/29 11:07:01
OK. Document this?
henrika_webrtc
2017/05/29 14:30:05
Done.
|
| // Consumes the audio data in |buffer| and sends it to the WebRTC layer in |
| // chunks of 10ms. The provided delay estimates in |playout_delay_ms| and |
| @@ -73,15 +73,14 @@ class FineAudioBuffer { |
| // class and the owner must ensure that the pointer is valid during the life- |
| // time of this object. |
| AudioDeviceBuffer* const device_buffer_; |
| - // Number of bytes delivered by GetPlayoutData() call and provided to |
| - // DeliverRecordedData(). |
| - const size_t desired_frame_size_bytes_; |
| // Sample rate in Hertz. |
| const int sample_rate_; |
| // Number of audio samples per 10ms. |
| const size_t samples_per_10_ms_; |
| // Number of audio bytes per 10ms. |
| const size_t bytes_per_10_ms_; |
| + // Storage for output samples from which a consumer can read audio buffers |
| + // in any size using GetPlayoutData(). |
| rtc::BufferT<int8_t> playout_buffer_; |
| // Storage for input samples that are about to be delivered to the WebRTC |
| // ADB or remains from the last successful delivery of a 10ms audio buffer. |