| 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 #include <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "ppapi/cpp/audio_config.h" | 10 #include "ppapi/cpp/audio_config.h" |
| 11 #include "ppapi/cpp/dev/audio_input_dev.h" | 11 #include "ppapi/cpp/dev/audio_input_dev.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 34 audio_input_.StopCapture(); | 34 audio_input_.StopCapture(); |
| 35 delete[] samples_; | 35 delete[] samples_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { | 38 virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { |
| 39 // This sample frequency is guaranteed to work. | 39 // This sample frequency is guaranteed to work. |
| 40 const PP_AudioSampleRate kSampleFrequency = PP_AUDIOSAMPLERATE_44100; | 40 const PP_AudioSampleRate kSampleFrequency = PP_AUDIOSAMPLERATE_44100; |
| 41 const uint32_t kSampleCount = 1024; | 41 const uint32_t kSampleCount = 1024; |
| 42 const uint32_t kChannelCount = 1; | 42 const uint32_t kChannelCount = 1; |
| 43 | 43 |
| 44 sample_count_ = pp::AudioConfig::RecommendSampleFrameCount(kSampleFrequency, | 44 sample_count_ = pp::AudioConfig::RecommendSampleFrameCount(this, |
| 45 kSampleFrequency, |
| 45 kSampleCount); | 46 kSampleCount); |
| 46 PP_DCHECK(sample_count_ > 0); | 47 PP_DCHECK(sample_count_ > 0); |
| 47 channel_count_ = kChannelCount; | 48 channel_count_ = kChannelCount; |
| 48 pp::AudioConfig config = pp::AudioConfig(this, | 49 pp::AudioConfig config = pp::AudioConfig(this, |
| 49 kSampleFrequency, | 50 kSampleFrequency, |
| 50 sample_count_); | 51 sample_count_); |
| 51 samples_ = new int16_t[sample_count_ * channel_count_]; | 52 samples_ = new int16_t[sample_count_ * channel_count_]; |
| 52 memset(samples_, 0, sample_count_ * channel_count_ * sizeof(int16_t)); | 53 memset(samples_, 0, sample_count_ * channel_count_ * sizeof(int16_t)); |
| 53 audio_input_ = pp::AudioInput_Dev(this, config, CaptureCallback, this); | 54 audio_input_ = pp::AudioInput_Dev(this, config, CaptureCallback, this); |
| 54 if (!audio_input_.StartCapture()) | 55 if (!audio_input_.StartCapture()) |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 }; | 186 }; |
| 186 | 187 |
| 187 namespace pp { | 188 namespace pp { |
| 188 | 189 |
| 189 // Factory function for your specialization of the Module object. | 190 // Factory function for your specialization of the Module object. |
| 190 Module* CreateModule() { | 191 Module* CreateModule() { |
| 191 return new MyModule(); | 192 return new MyModule(); |
| 192 } | 193 } |
| 193 | 194 |
| 194 } // namespace pp | 195 } // namespace pp |
| OLD | NEW |