| OLD | NEW |
| (Empty) |
| 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 // From ppb_audio_frame.idl modified Thu Jan 23 15:09:57 2014. | |
| 6 | |
| 7 #include "ppapi/c/pp_errors.h" | |
| 8 #include "ppapi/c/ppb_audio_frame.h" | |
| 9 #include "ppapi/shared_impl/tracked_callback.h" | |
| 10 #include "ppapi/thunk/enter.h" | |
| 11 #include "ppapi/thunk/ppapi_thunk_export.h" | |
| 12 #include "ppapi/thunk/ppb_audio_frame_api.h" | |
| 13 | |
| 14 namespace ppapi { | |
| 15 namespace thunk { | |
| 16 | |
| 17 namespace { | |
| 18 | |
| 19 PP_Bool IsAudioFrame(PP_Resource resource) { | |
| 20 VLOG(4) << "PPB_AudioFrame::IsAudioFrame()"; | |
| 21 EnterResource<PPB_AudioFrame_API> enter(resource, false); | |
| 22 return PP_FromBool(enter.succeeded()); | |
| 23 } | |
| 24 | |
| 25 PP_TimeDelta GetTimestamp(PP_Resource frame) { | |
| 26 VLOG(4) << "PPB_AudioFrame::GetTimestamp()"; | |
| 27 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 28 if (enter.failed()) | |
| 29 return 0.0; | |
| 30 return enter.object()->GetTimestamp(); | |
| 31 } | |
| 32 | |
| 33 void SetTimestamp(PP_Resource frame, PP_TimeDelta timestamp) { | |
| 34 VLOG(4) << "PPB_AudioFrame::SetTimestamp()"; | |
| 35 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 36 if (enter.failed()) | |
| 37 return; | |
| 38 enter.object()->SetTimestamp(timestamp); | |
| 39 } | |
| 40 | |
| 41 PP_AudioFrame_SampleRate GetSampleRate(PP_Resource frame) { | |
| 42 VLOG(4) << "PPB_AudioFrame::GetSampleRate()"; | |
| 43 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 44 if (enter.failed()) | |
| 45 return PP_AUDIOFRAME_SAMPLERATE_UNKNOWN; | |
| 46 return enter.object()->GetSampleRate(); | |
| 47 } | |
| 48 | |
| 49 PP_AudioFrame_SampleSize GetSampleSize(PP_Resource frame) { | |
| 50 VLOG(4) << "PPB_AudioFrame::GetSampleSize()"; | |
| 51 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 52 if (enter.failed()) | |
| 53 return PP_AUDIOFRAME_SAMPLESIZE_UNKNOWN; | |
| 54 return enter.object()->GetSampleSize(); | |
| 55 } | |
| 56 | |
| 57 uint32_t GetNumberOfChannels(PP_Resource frame) { | |
| 58 VLOG(4) << "PPB_AudioFrame::GetNumberOfChannels()"; | |
| 59 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 60 if (enter.failed()) | |
| 61 return 0; | |
| 62 return enter.object()->GetNumberOfChannels(); | |
| 63 } | |
| 64 | |
| 65 uint32_t GetNumberOfSamples(PP_Resource frame) { | |
| 66 VLOG(4) << "PPB_AudioFrame::GetNumberOfSamples()"; | |
| 67 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 68 if (enter.failed()) | |
| 69 return 0; | |
| 70 return enter.object()->GetNumberOfSamples(); | |
| 71 } | |
| 72 | |
| 73 void* GetDataBuffer(PP_Resource frame) { | |
| 74 VLOG(4) << "PPB_AudioFrame::GetDataBuffer()"; | |
| 75 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 76 if (enter.failed()) | |
| 77 return NULL; | |
| 78 return enter.object()->GetDataBuffer(); | |
| 79 } | |
| 80 | |
| 81 uint32_t GetDataBufferSize(PP_Resource frame) { | |
| 82 VLOG(4) << "PPB_AudioFrame::GetDataBufferSize()"; | |
| 83 EnterResource<PPB_AudioFrame_API> enter(frame, true); | |
| 84 if (enter.failed()) | |
| 85 return 0; | |
| 86 return enter.object()->GetDataBufferSize(); | |
| 87 } | |
| 88 | |
| 89 const PPB_AudioFrame_0_1 g_ppb_audioframe_thunk_0_1 = { | |
| 90 &IsAudioFrame, | |
| 91 &GetTimestamp, | |
| 92 &SetTimestamp, | |
| 93 &GetSampleRate, | |
| 94 &GetSampleSize, | |
| 95 &GetNumberOfChannels, | |
| 96 &GetNumberOfSamples, | |
| 97 &GetDataBuffer, | |
| 98 &GetDataBufferSize | |
| 99 }; | |
| 100 | |
| 101 } // namespace | |
| 102 | |
| 103 PPAPI_THUNK_EXPORT const PPB_AudioFrame_0_1* GetPPB_AudioFrame_0_1_Thunk() { | |
| 104 return &g_ppb_audioframe_thunk_0_1; | |
| 105 } | |
| 106 | |
| 107 } // namespace thunk | |
| 108 } // namespace ppapi | |
| OLD | NEW |