OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BASE_AUDIO_LATENCY_H_ | 5 #ifndef MEDIA_BASE_AUDIO_LATENCY_H_ |
6 #define MEDIA_BASE_AUDIO_LATENCY_H_ | 6 #define MEDIA_BASE_AUDIO_LATENCY_H_ |
7 | 7 |
8 #include "media/base/media_export.h" | 8 #include "media/base/media_export.h" |
9 | 9 |
| 10 namespace base { |
| 11 class TimeDelta; |
| 12 } |
| 13 |
10 namespace media { | 14 namespace media { |
11 | 15 |
12 class MEDIA_EXPORT AudioLatency { | 16 class MEDIA_EXPORT AudioLatency { |
13 public: | 17 public: |
14 // Categories of expected latencies for input/output audio. Do not change | 18 // Categories of expected latencies for input/output audio. Do not change |
15 // existing values, they are used for UMA histogram reporting. | 19 // existing values, they are used for UMA histogram reporting. |
16 enum LatencyType { | 20 enum LatencyType { |
17 // Specific latency in milliseconds. | 21 // Specific latency in milliseconds. |
18 LATENCY_EXACT_MS = 0, | 22 LATENCY_EXACT_MS = 0, |
19 // Lowest possible latency which does not cause glitches. | 23 // Lowest possible latency which does not cause glitches. |
20 LATENCY_INTERACTIVE = 1, | 24 LATENCY_INTERACTIVE = 1, |
21 // Latency optimized for real time communication. | 25 // Latency optimized for real time communication. |
22 LATENCY_RTC = 2, | 26 LATENCY_RTC = 2, |
23 // Latency optimized for continuous playback and power saving. | 27 // Latency optimized for continuous playback and power saving. |
24 LATENCY_PLAYBACK = 3, | 28 LATENCY_PLAYBACK = 3, |
25 // For validation only. | 29 // For validation only. |
26 LATENCY_LAST = LATENCY_PLAYBACK, | 30 LATENCY_LAST = LATENCY_PLAYBACK, |
27 LATENCY_COUNT = LATENCY_LAST + 1 | 31 LATENCY_COUNT = LATENCY_LAST + 1 |
28 }; | 32 }; |
29 | 33 |
30 // |preferred_buffer_size| should be set to 0 if a client has no preference. | 34 // |preferred_buffer_size| should be set to 0 if a client has no preference. |
31 static int GetHighLatencyBufferSize(int sample_rate, | 35 static int GetHighLatencyBufferSize(int sample_rate, |
32 int preferred_buffer_size); | 36 int preferred_buffer_size); |
33 | 37 |
34 // |hardware_buffer_size| should be set to 0 if unknown/invalid/not preferred. | 38 // |hardware_buffer_size| should be set to 0 if unknown/invalid/not preferred. |
35 static int GetRtcBufferSize(int sample_rate, int hardware_buffer_size); | 39 static int GetRtcBufferSize(int sample_rate, int hardware_buffer_size); |
36 | 40 |
37 static int GetInteractiveBufferSize(int hardware_buffer_size); | 41 static int GetInteractiveBufferSize(int hardware_buffer_size); |
| 42 |
| 43 static int GetExactBufferSize(base::TimeDelta duration, |
| 44 int sample_rate, |
| 45 int hardware_buffer_size); |
38 }; | 46 }; |
39 | 47 |
40 } // namespace media | 48 } // namespace media |
41 | 49 |
42 #endif // MEDIA_BASE_AUDIO_LATENCY_H_ | 50 #endif // MEDIA_BASE_AUDIO_LATENCY_H_ |
OLD | NEW |