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