| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // samples. | 25 // samples. |
| 26 class FineAudioBuffer { | 26 class FineAudioBuffer { |
| 27 public: | 27 public: |
| 28 // |device_buffer| is a buffer that provides 10ms of audio data. | 28 // |device_buffer| is a buffer that provides 10ms of audio data. |
| 29 // |desired_frame_size_bytes| is the number of bytes of audio data | 29 // |desired_frame_size_bytes| is the number of bytes of audio data |
| 30 // (not samples) |GetBufferData| should return on success. | 30 // (not samples) |GetBufferData| should return on success. |
| 31 // |sample_rate| is the sample rate of the audio data. This is needed because | 31 // |sample_rate| is the sample rate of the audio data. This is needed because |
| 32 // |device_buffer| delivers 10ms of data. Given the sample rate the number | 32 // |device_buffer| delivers 10ms of data. Given the sample rate the number |
| 33 // of samples can be calculated. | 33 // of samples can be calculated. |
| 34 FineAudioBuffer(AudioDeviceBuffer* device_buffer, | 34 FineAudioBuffer(AudioDeviceBuffer* device_buffer, |
| 35 int desired_frame_size_bytes, | 35 size_t desired_frame_size_bytes, |
| 36 int sample_rate); | 36 int sample_rate); |
| 37 ~FineAudioBuffer(); | 37 ~FineAudioBuffer(); |
| 38 | 38 |
| 39 // Returns the required size of |buffer| when calling GetBufferData. If the | 39 // Returns the required size of |buffer| when calling GetBufferData. If the |
| 40 // buffer is smaller memory trampling will happen. | 40 // buffer is smaller memory trampling will happen. |
| 41 // |desired_frame_size_bytes| and |samples_rate| are as described in the | 41 // |desired_frame_size_bytes| and |samples_rate| are as described in the |
| 42 // constructor. | 42 // constructor. |
| 43 int RequiredBufferSizeBytes(); | 43 size_t RequiredBufferSizeBytes(); |
| 44 | 44 |
| 45 // |buffer| must be of equal or greater size than what is returned by | 45 // |buffer| must be of equal or greater size than what is returned by |
| 46 // RequiredBufferSize. This is to avoid unnecessary memcpy. | 46 // RequiredBufferSize. This is to avoid unnecessary memcpy. |
| 47 void GetBufferData(int8_t* buffer); | 47 void GetBufferData(int8_t* buffer); |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 // Device buffer that provides 10ms chunks of data. | 50 // Device buffer that provides 10ms chunks of data. |
| 51 AudioDeviceBuffer* device_buffer_; | 51 AudioDeviceBuffer* device_buffer_; |
| 52 // Number of bytes delivered per GetBufferData | 52 // Number of bytes delivered per GetBufferData |
| 53 int desired_frame_size_bytes_; | 53 size_t desired_frame_size_bytes_; |
| 54 int sample_rate_; | 54 int sample_rate_; |
| 55 int samples_per_10_ms_; | 55 size_t samples_per_10_ms_; |
| 56 // Convenience parameter to avoid converting from samples | 56 // Convenience parameter to avoid converting from samples |
| 57 int bytes_per_10_ms_; | 57 size_t bytes_per_10_ms_; |
| 58 | 58 |
| 59 // Storage for samples that are not yet asked for. | 59 // Storage for samples that are not yet asked for. |
| 60 rtc::scoped_ptr<int8_t[]> cache_buffer_; | 60 rtc::scoped_ptr<int8_t[]> cache_buffer_; |
| 61 // Location of first unread sample. | 61 // Location of first unread sample. |
| 62 int cached_buffer_start_; | 62 size_t cached_buffer_start_; |
| 63 // Number of bytes stored in cache. | 63 // Number of bytes stored in cache. |
| 64 int cached_bytes_; | 64 size_t cached_bytes_; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 } // namespace webrtc | 67 } // namespace webrtc |
| 68 | 68 |
| 69 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_FINE_AUDIO_BUFFER_H_ | 69 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_FINE_AUDIO_BUFFER_H_ |
| OLD | NEW |