OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Needed on Windows to get |M_PI| from math.h. | 5 // Needed on Windows to get |M_PI| from math.h. |
6 #ifdef _WIN32 | 6 #ifdef _WIN32 |
7 #define _USE_MATH_DEFINES | 7 #define _USE_MATH_DEFINES |
8 #endif | 8 #endif |
9 | 9 |
10 #include <math.h> | 10 #include <math.h> |
11 #include <stdlib.h> | 11 #include <stdlib.h> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 int value = atoi(argv[i]); | 49 int value = atoi(argv[i]); |
50 if (value > 0 && value <= 1000000) | 50 if (value > 0 && value <= 1000000) |
51 sample_rate_ = static_cast<PP_AudioSampleRate>(value); | 51 sample_rate_ = static_cast<PP_AudioSampleRate>(value); |
52 else | 52 else |
53 return false; | 53 return false; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 pp::AudioConfig config; | 57 pp::AudioConfig config; |
58 sample_count_ = pp::AudioConfig::RecommendSampleFrameCount( | 58 sample_count_ = pp::AudioConfig::RecommendSampleFrameCount( |
59 sample_rate_, kDefaultSampleCount); | 59 this, sample_rate_, kDefaultSampleCount); |
60 config = pp::AudioConfig(this, sample_rate_, sample_count_); | 60 config = pp::AudioConfig(this, sample_rate_, sample_count_); |
61 audio_ = pp::Audio(this, config, SineWaveCallbackTrampoline, this); | 61 audio_ = pp::Audio(this, config, SineWaveCallbackTrampoline, this); |
62 return audio_.StartPlayback(); | 62 return audio_.StartPlayback(); |
63 } | 63 } |
64 | 64 |
65 virtual void DidChangeView(const pp::View& view) { | 65 virtual void DidChangeView(const pp::View& view) { |
66 // The frequency will change depending on whether the page is in the | 66 // The frequency will change depending on whether the page is in the |
67 // foreground or background. | 67 // foreground or background. |
68 visible_ = view.IsPageVisible(); | 68 visible_ = view.IsPageVisible(); |
69 } | 69 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 }; | 124 }; |
125 | 125 |
126 namespace pp { | 126 namespace pp { |
127 | 127 |
128 // Factory function for your specialization of the Module object. | 128 // Factory function for your specialization of the Module object. |
129 Module* CreateModule() { | 129 Module* CreateModule() { |
130 return new MyModule(); | 130 return new MyModule(); |
131 } | 131 } |
132 | 132 |
133 } // namespace pp | 133 } // namespace pp |
OLD | NEW |