• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "ppapi/cpp/audio_buffer.h"
6 
7 #include "ppapi/cpp/module.h"
8 #include "ppapi/cpp/module_impl.h"
9 
10 namespace pp {
11 
12 namespace {
13 
interface_name()14 template <> const char* interface_name<PPB_AudioBuffer_0_1>() {
15   return PPB_AUDIOBUFFER_INTERFACE_0_1;
16 }
17 
18 }  // namespace
19 
AudioBuffer()20 AudioBuffer::AudioBuffer() {
21 }
22 
AudioBuffer(const AudioBuffer & other)23 AudioBuffer::AudioBuffer(const AudioBuffer& other) : Resource(other) {
24 }
25 
AudioBuffer(const Resource & resource)26 AudioBuffer::AudioBuffer(const Resource& resource) : Resource(resource) {
27 }
28 
AudioBuffer(PassRef,PP_Resource resource)29 AudioBuffer::AudioBuffer(PassRef, PP_Resource resource)
30     : Resource(PASS_REF, resource) {
31 }
32 
~AudioBuffer()33 AudioBuffer::~AudioBuffer() {
34 }
35 
GetTimestamp() const36 PP_TimeDelta AudioBuffer::GetTimestamp() const {
37   if (has_interface<PPB_AudioBuffer_0_1>())
38     return get_interface<PPB_AudioBuffer_0_1>()->GetTimestamp(pp_resource());
39   return 0.0;
40 }
41 
SetTimestamp(PP_TimeDelta timestamp)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(),
45                                                        timestamp);
46   }
47 }
48 
GetSampleRate() const49 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;
53 }
54 
GetSampleSize() const55 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;
59 }
60 
GetNumberOfChannels() const61 uint32_t AudioBuffer::GetNumberOfChannels() const {
62   if (has_interface<PPB_AudioBuffer_0_1>()) {
63     return get_interface<PPB_AudioBuffer_0_1>()->GetNumberOfChannels(
64         pp_resource());
65   }
66   return 0;
67 }
68 
GetNumberOfSamples() const69 uint32_t AudioBuffer::GetNumberOfSamples() const {
70   if (has_interface<PPB_AudioBuffer_0_1>()) {
71     return get_interface<PPB_AudioBuffer_0_1>()->GetNumberOfSamples(
72         pp_resource());
73   }
74   return 0;
75 }
76 
GetDataBuffer()77 void* AudioBuffer::GetDataBuffer() {
78   if (has_interface<PPB_AudioBuffer_0_1>())
79     return get_interface<PPB_AudioBuffer_0_1>()->GetDataBuffer(pp_resource());
80   return NULL;
81 }
82 
GetDataBufferSize() const83 uint32_t AudioBuffer::GetDataBufferSize() const {
84   if (has_interface<PPB_AudioBuffer_0_1>()) {
85     return get_interface<PPB_AudioBuffer_0_1>()->GetDataBufferSize(
86         pp_resource());
87   }
88   return 0;
89 }
90 
91 }  // namespace pp
92