OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WebAudioLatencyHint_h |
| 6 #define WebAudioLatencyHint_h |
| 7 |
| 8 #include "public/platform/WebString.h" |
| 9 |
| 10 namespace blink { |
| 11 |
| 12 class WebAudioLatencyHint { |
| 13 public: |
| 14 enum AudioContextLatencyCategory { |
| 15 kCategoryInteractive, |
| 16 kCategoryBalanced, |
| 17 kCategoryPlayback, |
| 18 kCategoryExact |
| 19 }; |
| 20 |
| 21 explicit WebAudioLatencyHint(const WebString& category) { |
| 22 if (category == "interactive") { |
| 23 m_category = kCategoryInteractive; |
| 24 } else if (category == "balanced") { |
| 25 m_category = kCategoryBalanced; |
| 26 } else if (category == "playback") { |
| 27 m_category = kCategoryPlayback; |
| 28 } else { |
| 29 NOTREACHED(); |
| 30 m_category = kCategoryInteractive; |
| 31 } |
| 32 } |
| 33 |
| 34 explicit WebAudioLatencyHint(AudioContextLatencyCategory category) |
| 35 : m_category(category), m_seconds(0) {} |
| 36 explicit WebAudioLatencyHint(double seconds) |
| 37 : m_category(kCategoryExact), m_seconds(seconds) {} |
| 38 |
| 39 AudioContextLatencyCategory category() const { return m_category; } |
| 40 double seconds() const { |
| 41 DCHECK_EQ(m_category, kCategoryExact); |
| 42 return m_seconds; |
| 43 } |
| 44 |
| 45 private: |
| 46 AudioContextLatencyCategory m_category; |
| 47 double m_seconds; |
| 48 }; |
| 49 |
| 50 } // namespace blink |
| 51 |
| 52 #endif |
OLD | NEW |