Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2201)

Unified Diff: ppapi/examples/audio_input/audio_input.cc

Issue 9965080: Change the cpp wrappers of audio input/video capture to use CompletionCallbackWithOutput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More changes in response to Brett's comments. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/cpp/output_traits.h ('k') | ppapi/examples/video_capture/video_capture.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/examples/audio_input/audio_input.cc
diff --git a/ppapi/examples/audio_input/audio_input.cc b/ppapi/examples/audio_input/audio_input.cc
index 7d156b72e6381d00b6fcde660edc262a66c6507c..62bf2995cc86a8d7544a2068bdb6054f8f6f99b3 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();
« no previous file with comments | « ppapi/cpp/output_traits.h ('k') | ppapi/examples/video_capture/video_capture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698