Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: webrtc/modules/audio_device/android/fine_audio_buffer.h

Issue 1254883002: Refactor the AudioDevice for iOS and improve the performance and stability (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased and cleaned up Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_FINE_AUDIO_BUFFER_H_
12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_FINE_AUDIO_BUFFER_H_
13
14 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/typedefs.h"
16
17 namespace webrtc {
18
19 class AudioDeviceBuffer;
20
21 // FineAudioBuffer takes an AudioDeviceBuffer which delivers audio data
22 // corresponding to 10ms of data. It then allows for this data to be pulled in
23 // a finer or coarser granularity. I.e. interacting with this class instead of
24 // directly with the AudioDeviceBuffer one can ask for any number of audio data
25 // samples.
26 class FineAudioBuffer {
27 public:
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
30 // (not samples) |GetBufferData| should return on success.
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
33 // of samples can be calculated.
34 FineAudioBuffer(AudioDeviceBuffer* device_buffer,
35 size_t desired_frame_size_bytes,
36 int sample_rate);
37 ~FineAudioBuffer();
38
39 // Returns the required size of |buffer| when calling GetBufferData. If the
40 // buffer is smaller memory trampling will happen.
41 // |desired_frame_size_bytes| and |samples_rate| are as described in the
42 // constructor.
43 size_t RequiredBufferSizeBytes();
44
45 // |buffer| must be of equal or greater size than what is returned by
46 // RequiredBufferSize. This is to avoid unnecessary memcpy.
47 void GetBufferData(int8_t* buffer);
48
49 private:
50 // Device buffer that provides 10ms chunks of data.
51 AudioDeviceBuffer* device_buffer_;
52 // Number of bytes delivered per GetBufferData
53 size_t desired_frame_size_bytes_;
54 int sample_rate_;
55 size_t samples_per_10_ms_;
56 // Convenience parameter to avoid converting from samples
57 size_t bytes_per_10_ms_;
58
59 // Storage for samples that are not yet asked for.
60 rtc::scoped_ptr<int8_t[]> cache_buffer_;
61 // Location of first unread sample.
62 size_t cached_buffer_start_;
63 // Number of bytes stored in cache.
64 size_t cached_bytes_;
65 };
66
67 } // namespace webrtc
68
69 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_FINE_AUDIO_BUFFER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_device/BUILD.gn ('k') | webrtc/modules/audio_device/android/fine_audio_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698