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

Unified Diff: ppapi/cpp/dev/audio_output_dev.cc

Issue 2755613002: Support audio output device enumeration and selection in PPAPI (Closed)
Patch Set: Fix format, Rebase Created 3 years, 8 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/dev/audio_output_dev.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/audio_output_dev.cc
diff --git a/ppapi/cpp/dev/audio_output_dev.cc b/ppapi/cpp/dev/audio_output_dev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..56e55b0923b91eb87e368bfb46b4a39c12d3c740
--- /dev/null
+++ b/ppapi/cpp/dev/audio_output_dev.cc
@@ -0,0 +1,98 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/cpp/dev/audio_output_dev.h"
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <>
+const char* interface_name<PPB_AudioOutput_Dev_0_1>() {
+ return PPB_AUDIO_OUTPUT_DEV_INTERFACE_0_1;
+}
+
+} // namespace
+
+AudioOutput_Dev::AudioOutput_Dev() {}
+
+AudioOutput_Dev::AudioOutput_Dev(const InstanceHandle& instance) {
+ if (has_interface<PPB_AudioOutput_Dev_0_1>()) {
+ PassRefFromConstructor(get_interface<PPB_AudioOutput_Dev_0_1>()->Create(
+ instance.pp_instance()));
+ }
+}
+
+AudioOutput_Dev::~AudioOutput_Dev() {}
+
+// static
+bool AudioOutput_Dev::IsAvailable() {
+ return has_interface<PPB_AudioOutput_Dev_0_1>();
+}
+
+int32_t AudioOutput_Dev::EnumerateDevices(
+ const CompletionCallbackWithOutput<std::vector<DeviceRef_Dev> >& callback) {
+ if (has_interface<PPB_AudioOutput_Dev_0_1>()) {
+ return get_interface<PPB_AudioOutput_Dev_0_1>()->EnumerateDevices(
+ pp_resource(), callback.output(), callback.pp_completion_callback());
+ }
+
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+int32_t AudioOutput_Dev::MonitorDeviceChange(
+ PP_MonitorDeviceChangeCallback callback,
+ void* user_data) {
+ if (has_interface<PPB_AudioOutput_Dev_0_1>()) {
+ return get_interface<PPB_AudioOutput_Dev_0_1>()->MonitorDeviceChange(
+ pp_resource(), callback, user_data);
+ }
+
+ return PP_ERROR_NOINTERFACE;
+}
+
+int32_t AudioOutput_Dev::Open(const DeviceRef_Dev& device_ref,
+ const AudioConfig& config,
+ PPB_AudioOutput_Callback audio_output_callback,
+ void* user_data,
+ const CompletionCallback& callback) {
+ if (has_interface<PPB_AudioOutput_Dev_0_1>()) {
+ return get_interface<PPB_AudioOutput_Dev_0_1>()->Open(
+ pp_resource(), device_ref.pp_resource(), config.pp_resource(),
+ audio_output_callback, user_data, callback.pp_completion_callback());
+ }
+
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+}
+
+bool AudioOutput_Dev::StartPlayback() {
+ if (has_interface<PPB_AudioOutput_Dev_0_1>()) {
+ return PP_ToBool(
+ get_interface<PPB_AudioOutput_Dev_0_1>()->StartPlayback(pp_resource()));
+ }
+
+ return false;
+}
+
+bool AudioOutput_Dev::StopPlayback() {
+ if (has_interface<PPB_AudioOutput_Dev_0_1>()) {
+ return PP_ToBool(
+ get_interface<PPB_AudioOutput_Dev_0_1>()->StopPlayback(pp_resource()));
+ }
+
+ return false;
+}
+
+void AudioOutput_Dev::Close() {
+ if (has_interface<PPB_AudioOutput_Dev_0_1>()) {
+ get_interface<PPB_AudioOutput_Dev_0_1>()->Close(pp_resource());
+ }
+}
+
+} // namespace pp
« no previous file with comments | « ppapi/cpp/dev/audio_output_dev.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698