1 // Copyright 2014 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_buffer.h"
7 #include "ppapi/cpp/module.h"
8 #include "ppapi/cpp/module_impl.h"
14 template <> const char* interface_name
<PPB_AudioBuffer_0_1
>() {
15 return PPB_AUDIOBUFFER_INTERFACE_0_1
;
20 AudioBuffer::AudioBuffer() {
23 AudioBuffer::AudioBuffer(const AudioBuffer
& other
) : Resource(other
) {
26 AudioBuffer::AudioBuffer(const Resource
& resource
) : Resource(resource
) {
29 AudioBuffer::AudioBuffer(PassRef
, PP_Resource resource
)
30 : Resource(PASS_REF
, resource
) {
33 AudioBuffer::~AudioBuffer() {
36 PP_TimeDelta
AudioBuffer::GetTimestamp() const {
37 if (has_interface
<PPB_AudioBuffer_0_1
>())
38 return get_interface
<PPB_AudioBuffer_0_1
>()->GetTimestamp(pp_resource());
42 void AudioBuffer::SetTimestamp(PP_TimeDelta timestamp
) {
43 if (has_interface
<PPB_AudioBuffer_0_1
>()) {
44 get_interface
<PPB_AudioBuffer_0_1
>()->SetTimestamp(pp_resource(),
49 PP_AudioBuffer_SampleRate
AudioBuffer::GetSampleRate() const {
50 if (has_interface
<PPB_AudioBuffer_0_1
>())
51 return get_interface
<PPB_AudioBuffer_0_1
>()->GetSampleRate(pp_resource());
52 return PP_AUDIOBUFFER_SAMPLERATE_UNKNOWN
;
55 PP_AudioBuffer_SampleSize
AudioBuffer::GetSampleSize() const {
56 if (has_interface
<PPB_AudioBuffer_0_1
>())
57 return get_interface
<PPB_AudioBuffer_0_1
>()->GetSampleSize(pp_resource());
58 return PP_AUDIOBUFFER_SAMPLESIZE_UNKNOWN
;
61 uint32_t AudioBuffer::GetNumberOfChannels() const {
62 if (has_interface
<PPB_AudioBuffer_0_1
>()) {
63 return get_interface
<PPB_AudioBuffer_0_1
>()->GetNumberOfChannels(
69 uint32_t AudioBuffer::GetNumberOfSamples() const {
70 if (has_interface
<PPB_AudioBuffer_0_1
>()) {
71 return get_interface
<PPB_AudioBuffer_0_1
>()->GetNumberOfSamples(
77 void* AudioBuffer::GetDataBuffer() {
78 if (has_interface
<PPB_AudioBuffer_0_1
>())
79 return get_interface
<PPB_AudioBuffer_0_1
>()->GetDataBuffer(pp_resource());
83 uint32_t AudioBuffer::GetDataBufferSize() const {
84 if (has_interface
<PPB_AudioBuffer_0_1
>()) {
85 return get_interface
<PPB_AudioBuffer_0_1
>()->GetDataBufferSize(