diff options
Diffstat (limited to 'ppapi/examples')
-rw-r--r-- | ppapi/examples/audio_input/audio_input.cc | 11 | ||||
-rw-r--r-- | ppapi/examples/video_capture/video_capture.cc | 15 |
2 files changed, 17 insertions, 9 deletions
diff --git a/ppapi/examples/audio_input/audio_input.cc b/ppapi/examples/audio_input/audio_input.cc index 7d156b7..62bf299 100644 --- a/ppapi/examples/audio_input/audio_input.cc +++ b/ppapi/examples/audio_input/audio_input.cc @@ -93,9 +93,10 @@ class MyInstance : public pp::Instance { if (message_data.is_string()) { std::string event = message_data.AsString(); if (event == "PageInitialized") { - pp::CompletionCallback callback = callback_factory_.NewCallback( - &MyInstance::EnumerateDevicesFinished); - int32_t result = audio_input_.EnumerateDevices(&devices_, callback); + pp::CompletionCallbackWithOutput<std::vector<pp::DeviceRef_Dev> > + callback = callback_factory_.NewCallbackWithOutput( + &MyInstance::EnumerateDevicesFinished); + int32_t result = audio_input_.EnumerateDevices(callback); if (result != PP_OK_COMPLETIONPENDING) PostMessage(pp::Var("EnumerationFailed")); } else if (event == "UseDefault") { @@ -241,10 +242,12 @@ class MyInstance : public pp::Instance { } } - void EnumerateDevicesFinished(int32_t result) { + void EnumerateDevicesFinished(int32_t result, + std::vector<pp::DeviceRef_Dev>& devices) { static const char* const kDelimiter = "#__#"; if (result == PP_OK) { + devices_.swap(devices); std::string device_names; for (size_t index = 0; index < devices_.size(); ++index) { pp::Var name = devices_[index].GetName(); diff --git a/ppapi/examples/video_capture/video_capture.cc b/ppapi/examples/video_capture/video_capture.cc index 20c0c75..07239c6 100644 --- a/ppapi/examples/video_capture/video_capture.cc +++ b/ppapi/examples/video_capture/video_capture.cc @@ -118,7 +118,8 @@ class VCDemoInstance : public pp::Instance, void CreateYUVTextures(); void Open(const pp::DeviceRef_Dev& device); - void EnumerateDevicesFinished(int32_t result); + void EnumerateDevicesFinished(int32_t result, + std::vector<pp::DeviceRef_Dev>& devices); void OpenFinished(int32_t result); pp::Size position_size_; @@ -185,9 +186,10 @@ void VCDemoInstance::HandleMessage(const pp::Var& message_data) { if (message_data.is_string()) { std::string event = message_data.AsString(); if (event == "PageInitialized") { - pp::CompletionCallback callback = callback_factory_.NewCallback( - &VCDemoInstance::EnumerateDevicesFinished); - video_capture_.EnumerateDevices(&devices_, callback); + pp::CompletionCallbackWithOutput<std::vector<pp::DeviceRef_Dev> > + callback = callback_factory_.NewCallbackWithOutput( + &VCDemoInstance::EnumerateDevicesFinished); + video_capture_.EnumerateDevices(callback); } else if (event == "UseDefault") { Open(pp::DeviceRef_Dev()); } else if (event == "UseDefault(v0.1)") { @@ -403,10 +405,13 @@ void VCDemoInstance::Open(const pp::DeviceRef_Dev& device) { video_capture_.Open(device, capture_info_, 4, callback); } -void VCDemoInstance::EnumerateDevicesFinished(int32_t result) { +void VCDemoInstance::EnumerateDevicesFinished( + int32_t result, + std::vector<pp::DeviceRef_Dev>& devices) { static const char* const kDelimiter = "#__#"; if (result == PP_OK) { + devices_.swap(devices); std::string device_names; for (size_t index = 0; index < devices_.size(); ++index) { pp::Var name = devices_[index].GetName(); |