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
3 // found in the LICENSE file.
5 #include "ppapi/cpp/audio.h"
7 #include "ppapi/cpp/instance_handle.h"
8 #include "ppapi/cpp/module_impl.h"
14 template <> const char* interface_name
<PPB_Audio_1_0
>() {
15 return PPB_AUDIO_INTERFACE_1_0
;
18 template <> const char* interface_name
<PPB_Audio_1_1
>() {
19 return PPB_AUDIO_INTERFACE_1_1
;
24 Audio::Audio(const InstanceHandle
& instance
,
25 const AudioConfig
& config
,
26 PPB_Audio_Callback callback
,
29 use_1_0_interface_(false) {
30 if (has_interface
<PPB_Audio_1_1
>()) {
31 PassRefFromConstructor(get_interface
<PPB_Audio_1_1
>()->Create(
32 instance
.pp_instance(), config
.pp_resource(), callback
, user_data
));
36 Audio::Audio(const InstanceHandle
& instance
,
37 const AudioConfig
& config
,
38 PPB_Audio_Callback_1_0 callback
,
41 use_1_0_interface_(true) {
42 if (has_interface
<PPB_Audio_1_0
>()) {
43 PassRefFromConstructor(get_interface
<PPB_Audio_1_0
>()->Create(
44 instance
.pp_instance(), config
.pp_resource(), callback
, user_data
));
48 bool Audio::StartPlayback() {
49 if (has_interface
<PPB_Audio_1_1
>() && !use_1_0_interface_
) {
50 return PP_ToBool(get_interface
<PPB_Audio_1_1
>()->StartPlayback(
53 if (has_interface
<PPB_Audio_1_0
>()) {
54 return PP_ToBool(get_interface
<PPB_Audio_1_0
>()->StartPlayback(
60 bool Audio::StopPlayback() {
61 if (has_interface
<PPB_Audio_1_1
>() && !use_1_0_interface_
) {
62 return PP_ToBool(get_interface
<PPB_Audio_1_1
>()->StopPlayback(
65 if (has_interface
<PPB_Audio_1_0
>()) {
66 return PP_ToBool(get_interface
<PPB_Audio_1_0
>()->StopPlayback(