| OLD | NEW |
| 1 // Copyright (c) 2012 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 if (!BindGraphics(device_context_)) | 86 if (!BindGraphics(device_context_)) |
| 87 return; | 87 return; |
| 88 | 88 |
| 89 Paint(); | 89 Paint(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual void HandleMessage(const pp::Var& message_data) { | 92 virtual void HandleMessage(const pp::Var& message_data) { |
| 93 if (message_data.is_string()) { | 93 if (message_data.is_string()) { |
| 94 std::string event = message_data.AsString(); | 94 std::string event = message_data.AsString(); |
| 95 if (event == "PageInitialized") { | 95 if (event == "PageInitialized") { |
| 96 pp::CompletionCallback callback = callback_factory_.NewCallback( | 96 pp::CompletionCallbackWithOutput<std::vector<pp::DeviceRef_Dev> > |
| 97 &MyInstance::EnumerateDevicesFinished); | 97 callback = callback_factory_.NewCallbackWithOutput( |
| 98 int32_t result = audio_input_.EnumerateDevices(&devices_, callback); | 98 &MyInstance::EnumerateDevicesFinished); |
| 99 int32_t result = audio_input_.EnumerateDevices(callback); |
| 99 if (result != PP_OK_COMPLETIONPENDING) | 100 if (result != PP_OK_COMPLETIONPENDING) |
| 100 PostMessage(pp::Var("EnumerationFailed")); | 101 PostMessage(pp::Var("EnumerationFailed")); |
| 101 } else if (event == "UseDefault") { | 102 } else if (event == "UseDefault") { |
| 102 Open(pp::DeviceRef_Dev()); | 103 Open(pp::DeviceRef_Dev()); |
| 103 } else if (event == "UseDefault(v0.1)") { | 104 } else if (event == "UseDefault(v0.1)") { |
| 104 audio_input_0_1_ = audio_input_interface_0_1_->Create( | 105 audio_input_0_1_ = audio_input_interface_0_1_->Create( |
| 105 pp_instance(), audio_input_.config().pp_resource(), | 106 pp_instance(), audio_input_.config().pp_resource(), |
| 106 CaptureCallback, this); | 107 CaptureCallback, this); |
| 107 if (audio_input_0_1_ != 0) { | 108 if (audio_input_0_1_ != 0) { |
| 108 if (!audio_input_interface_0_1_->StartCapture(audio_input_0_1_)) | 109 if (!audio_input_interface_0_1_->StartCapture(audio_input_0_1_)) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 void Start() { | 235 void Start() { |
| 235 if (!audio_input_.is_null()) { | 236 if (!audio_input_.is_null()) { |
| 236 if (!audio_input_.StartCapture()) | 237 if (!audio_input_.StartCapture()) |
| 237 PostMessage(pp::Var("StartFailed")); | 238 PostMessage(pp::Var("StartFailed")); |
| 238 } else if (audio_input_0_1_ != 0) { | 239 } else if (audio_input_0_1_ != 0) { |
| 239 if (!audio_input_interface_0_1_->StartCapture(audio_input_0_1_)) | 240 if (!audio_input_interface_0_1_->StartCapture(audio_input_0_1_)) |
| 240 PostMessage(pp::Var("StartFailed")); | 241 PostMessage(pp::Var("StartFailed")); |
| 241 } | 242 } |
| 242 } | 243 } |
| 243 | 244 |
| 244 void EnumerateDevicesFinished(int32_t result) { | 245 void EnumerateDevicesFinished(int32_t result, |
| 246 std::vector<pp::DeviceRef_Dev>& devices) { |
| 245 static const char* const kDelimiter = "#__#"; | 247 static const char* const kDelimiter = "#__#"; |
| 246 | 248 |
| 247 if (result == PP_OK) { | 249 if (result == PP_OK) { |
| 250 devices_.swap(devices); |
| 248 std::string device_names; | 251 std::string device_names; |
| 249 for (size_t index = 0; index < devices_.size(); ++index) { | 252 for (size_t index = 0; index < devices_.size(); ++index) { |
| 250 pp::Var name = devices_[index].GetName(); | 253 pp::Var name = devices_[index].GetName(); |
| 251 PP_DCHECK(name.is_string()); | 254 PP_DCHECK(name.is_string()); |
| 252 | 255 |
| 253 if (index != 0) | 256 if (index != 0) |
| 254 device_names += kDelimiter; | 257 device_names += kDelimiter; |
| 255 device_names += name.AsString(); | 258 device_names += name.AsString(); |
| 256 } | 259 } |
| 257 PostMessage(pp::Var(device_names)); | 260 PostMessage(pp::Var(device_names)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 }; | 302 }; |
| 300 | 303 |
| 301 namespace pp { | 304 namespace pp { |
| 302 | 305 |
| 303 // Factory function for your specialization of the Module object. | 306 // Factory function for your specialization of the Module object. |
| 304 Module* CreateModule() { | 307 Module* CreateModule() { |
| 305 return new MyModule(); | 308 return new MyModule(); |
| 306 } | 309 } |
| 307 | 310 |
| 308 } // namespace pp | 311 } // namespace pp |
| OLD | NEW |