OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/cpp/dev/audio_output_dev.h" |
| 6 |
| 7 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_errors.h" |
| 9 #include "ppapi/cpp/instance_handle.h" |
| 10 #include "ppapi/cpp/module_impl.h" |
| 11 |
| 12 namespace pp { |
| 13 |
| 14 namespace { |
| 15 |
| 16 template <> |
| 17 const char* interface_name<PPB_AudioOutput_Dev_0_1>() { |
| 18 return PPB_AUDIO_OUTPUT_DEV_INTERFACE_0_1; |
| 19 } |
| 20 |
| 21 } // namespace |
| 22 |
| 23 AudioOutput_Dev::AudioOutput_Dev() {} |
| 24 |
| 25 AudioOutput_Dev::AudioOutput_Dev(const InstanceHandle& instance) { |
| 26 if (has_interface<PPB_AudioOutput_Dev_0_1>()) { |
| 27 PassRefFromConstructor(get_interface<PPB_AudioOutput_Dev_0_1>()->Create( |
| 28 instance.pp_instance())); |
| 29 } |
| 30 } |
| 31 |
| 32 AudioOutput_Dev::~AudioOutput_Dev() {} |
| 33 |
| 34 // static |
| 35 bool AudioOutput_Dev::IsAvailable() { |
| 36 return has_interface<PPB_AudioOutput_Dev_0_1>(); |
| 37 } |
| 38 |
| 39 int32_t AudioOutput_Dev::EnumerateDevices( |
| 40 const CompletionCallbackWithOutput<std::vector<DeviceRef_Dev> >& callback) { |
| 41 if (has_interface<PPB_AudioOutput_Dev_0_1>()) { |
| 42 return get_interface<PPB_AudioOutput_Dev_0_1>()->EnumerateDevices( |
| 43 pp_resource(), callback.output(), callback.pp_completion_callback()); |
| 44 } |
| 45 |
| 46 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 47 } |
| 48 |
| 49 int32_t AudioOutput_Dev::MonitorDeviceChange( |
| 50 PP_MonitorDeviceChangeCallback callback, |
| 51 void* user_data) { |
| 52 if (has_interface<PPB_AudioOutput_Dev_0_1>()) { |
| 53 return get_interface<PPB_AudioOutput_Dev_0_1>()->MonitorDeviceChange( |
| 54 pp_resource(), callback, user_data); |
| 55 } |
| 56 |
| 57 return PP_ERROR_NOINTERFACE; |
| 58 } |
| 59 |
| 60 int32_t AudioOutput_Dev::Open(const DeviceRef_Dev& device_ref, |
| 61 const AudioConfig& config, |
| 62 PPB_AudioOutput_Callback audio_output_callback, |
| 63 void* user_data, |
| 64 const CompletionCallback& callback) { |
| 65 if (has_interface<PPB_AudioOutput_Dev_0_1>()) { |
| 66 return get_interface<PPB_AudioOutput_Dev_0_1>()->Open( |
| 67 pp_resource(), device_ref.pp_resource(), config.pp_resource(), |
| 68 audio_output_callback, user_data, callback.pp_completion_callback()); |
| 69 } |
| 70 |
| 71 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 72 } |
| 73 |
| 74 bool AudioOutput_Dev::StartPlayback() { |
| 75 if (has_interface<PPB_AudioOutput_Dev_0_1>()) { |
| 76 return PP_ToBool( |
| 77 get_interface<PPB_AudioOutput_Dev_0_1>()->StartPlayback(pp_resource())); |
| 78 } |
| 79 |
| 80 return false; |
| 81 } |
| 82 |
| 83 bool AudioOutput_Dev::StopPlayback() { |
| 84 if (has_interface<PPB_AudioOutput_Dev_0_1>()) { |
| 85 return PP_ToBool( |
| 86 get_interface<PPB_AudioOutput_Dev_0_1>()->StopPlayback(pp_resource())); |
| 87 } |
| 88 |
| 89 return false; |
| 90 } |
| 91 |
| 92 void AudioOutput_Dev::Close() { |
| 93 if (has_interface<PPB_AudioOutput_Dev_0_1>()) { |
| 94 get_interface<PPB_AudioOutput_Dev_0_1>()->Close(pp_resource()); |
| 95 } |
| 96 } |
| 97 |
| 98 } // namespace pp |
OLD | NEW |