Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ppapi/shared_impl/ppb_audio_config_shared.h" | 5 #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
| 6 #include "ppapi/thunk/thunk.h" | 6 #include "ppapi/thunk/thunk.h" |
| 7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
| 8 #include "ppapi/thunk/ppb_audio_config_api.h" | 8 #include "ppapi/thunk/ppb_audio_config_api.h" |
| 9 #include "ppapi/thunk/resource_creation_api.h" | 9 #include "ppapi/thunk/resource_creation_api.h" |
| 10 | 10 |
| 11 namespace ppapi { | 11 namespace ppapi { |
| 12 namespace thunk { | 12 namespace thunk { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 PP_Resource CreateStereo16bit(PP_Instance instance, | 16 PP_Resource CreateStereo16bit(PP_Instance instance, |
| 17 PP_AudioSampleRate sample_rate, | 17 PP_AudioSampleRate sample_rate, |
| 18 uint32_t sample_frame_count) { | 18 uint32_t sample_frame_count) { |
| 19 VLOG(4) << "PPB_AudioConfig::CreateStereo16Bit()"; | 19 VLOG(4) << "PPB_AudioConfig::CreateStereo16Bit()"; |
| 20 EnterResourceCreation enter(instance); | 20 EnterResourceCreation enter(instance); |
| 21 if (enter.failed()) | 21 if (enter.failed()) |
| 22 return 0; | 22 return 0; |
| 23 return enter.functions()->CreateAudioConfig(instance, sample_rate, | 23 return enter.functions()->CreateAudioConfig( |
| 24 sample_frame_count); | 24 instance, sample_rate, sample_frame_count); |
| 25 } | 25 } |
| 26 | 26 |
| 27 uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate, | 27 uint32_t RecommendSampleFrameCount_1_0(PP_AudioSampleRate sample_rate, |
| 28 uint32_t requested_sample_frame_count) { | 28 uint32_t requested_sample_frame_count) { |
| 29 VLOG(4) << "PPB_AudioConfig::RecommendSampleFrameCount()"; | 29 VLOG(4) << "PPB_AudioConfig::RecommendSampleFrameCount()"; |
| 30 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_0(sample_rate, | 30 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_0( |
| 31 requested_sample_frame_count); | 31 sample_rate, requested_sample_frame_count); |
| 32 } | 32 } |
| 33 | 33 |
| 34 uint32_t RecommendSampleFrameCount_1_1(PP_Instance instance, | 34 uint32_t RecommendSampleFrameCount_1_1(PP_Instance instance, |
| 35 PP_AudioSampleRate sample_rate, | 35 PP_AudioSampleRate sample_rate, |
| 36 uint32_t requested_sample_frame_count) { | 36 uint32_t requested_sample_frame_count) { |
| 37 VLOG(4) << "PPB_AudioConfig::RecommendSampleFrameCount()"; | 37 VLOG(4) << "PPB_AudioConfig::RecommendSampleFrameCount()"; |
| 38 EnterInstance enter(instance); | 38 EnterInstance enter(instance); |
| 39 if (enter.failed()) | 39 if (enter.failed()) |
| 40 return 0; | 40 return 0; |
| 41 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1(instance, | 41 return PPB_AudioConfig_Shared::RecommendSampleFrameCount_1_1( |
| 42 sample_rate, requested_sample_frame_count); | 42 instance, sample_rate, requested_sample_frame_count); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | |
| 46 PP_Bool IsAudioConfig(PP_Resource resource) { | 45 PP_Bool IsAudioConfig(PP_Resource resource) { |
| 47 VLOG(4) << "PPB_AudioConfig::IsAudioConfig()"; | 46 VLOG(4) << "PPB_AudioConfig::IsAudioConfig()"; |
| 48 EnterResource<PPB_AudioConfig_API> enter(resource, false); | 47 EnterResource<PPB_AudioConfig_API> enter(resource, false); |
| 49 return PP_FromBool(enter.succeeded()); | 48 return PP_FromBool(enter.succeeded()); |
| 50 } | 49 } |
| 51 | 50 |
| 52 PP_AudioSampleRate GetSampleRate(PP_Resource config_id) { | 51 PP_AudioSampleRate GetSampleRate(PP_Resource config_id) { |
| 53 VLOG(4) << "PPB_AudioConfig::GetSampleRate()"; | 52 VLOG(4) << "PPB_AudioConfig::GetSampleRate()"; |
| 54 EnterResource<PPB_AudioConfig_API> enter(config_id, true); | 53 EnterResource<PPB_AudioConfig_API> enter(config_id, true); |
| 55 if (enter.failed()) | 54 if (enter.failed()) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 67 | 66 |
| 68 PP_AudioSampleRate RecommendSampleRate(PP_Instance instance) { | 67 PP_AudioSampleRate RecommendSampleRate(PP_Instance instance) { |
| 69 VLOG(4) << "PPB_AudioConfig::RecommendSampleRate()"; | 68 VLOG(4) << "PPB_AudioConfig::RecommendSampleRate()"; |
| 70 EnterInstance enter(instance); | 69 EnterInstance enter(instance); |
| 71 if (enter.failed()) | 70 if (enter.failed()) |
| 72 return PP_AUDIOSAMPLERATE_NONE; | 71 return PP_AUDIOSAMPLERATE_NONE; |
| 73 return PPB_AudioConfig_Shared::RecommendSampleRate(instance); | 72 return PPB_AudioConfig_Shared::RecommendSampleRate(instance); |
| 74 } | 73 } |
| 75 | 74 |
| 76 const PPB_AudioConfig_1_0 g_ppb_audio_config_thunk_1_0 = { | 75 const PPB_AudioConfig_1_0 g_ppb_audio_config_thunk_1_0 = { |
| 77 &CreateStereo16bit, | 76 &CreateStereo16bit, &RecommendSampleFrameCount_1_0, &IsAudioConfig, |
|
teravest
2014/04/16 15:19:16
:(
| |
| 78 &RecommendSampleFrameCount_1_0, | 77 &GetSampleRate, &GetSampleFrameCount}; |
| 79 &IsAudioConfig, | |
| 80 &GetSampleRate, | |
| 81 &GetSampleFrameCount | |
| 82 }; | |
| 83 | 78 |
| 84 const PPB_AudioConfig_1_1 g_ppb_audio_config_thunk_1_1 = { | 79 const PPB_AudioConfig_1_1 g_ppb_audio_config_thunk_1_1 = { |
| 85 &CreateStereo16bit, | 80 &CreateStereo16bit, &RecommendSampleFrameCount_1_1, &IsAudioConfig, |
| 86 &RecommendSampleFrameCount_1_1, | 81 &GetSampleRate, &GetSampleFrameCount, &RecommendSampleRate}; |
| 87 &IsAudioConfig, | |
| 88 &GetSampleRate, | |
| 89 &GetSampleFrameCount, | |
| 90 &RecommendSampleRate | |
| 91 }; | |
| 92 | |
| 93 | 82 |
| 94 } // namespace | 83 } // namespace |
| 95 | 84 |
| 96 const PPB_AudioConfig_1_0* GetPPB_AudioConfig_1_0_Thunk() { | 85 const PPB_AudioConfig_1_0* GetPPB_AudioConfig_1_0_Thunk() { |
| 97 return &g_ppb_audio_config_thunk_1_0; | 86 return &g_ppb_audio_config_thunk_1_0; |
| 98 } | 87 } |
| 99 | 88 |
| 100 const PPB_AudioConfig_1_1* GetPPB_AudioConfig_1_1_Thunk() { | 89 const PPB_AudioConfig_1_1* GetPPB_AudioConfig_1_1_Thunk() { |
| 101 return &g_ppb_audio_config_thunk_1_1; | 90 return &g_ppb_audio_config_thunk_1_1; |
| 102 } | 91 } |
| 103 | 92 |
| 104 } // namespace thunk | 93 } // namespace thunk |
| 105 } // namespace ppapi | 94 } // namespace ppapi |
| OLD | NEW |