| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 #ifndef PPAPI_CPP_DEV_AUDIO_CONFIG_DEV_H_ | |
| 6 #define PPAPI_CPP_DEV_AUDIO_CONFIG_DEV_H_ | |
| 7 | |
| 8 #include "ppapi/c/dev/ppb_audio_config_dev.h" | |
| 9 #include "ppapi/c/pp_stdint.h" | |
| 10 #include "ppapi/cpp/resource.h" | |
| 11 | |
| 12 namespace pp { | |
| 13 | |
| 14 class Instance; | |
| 15 | |
| 16 // Typical usage: | |
| 17 // | |
| 18 // // Create an audio config with a supported frame count. | |
| 19 // uint32_t sample_frame_count = | |
| 20 // AudioConfig_Dev::RecommendSampleFrameCount(4096); | |
| 21 // AudioConfig_Dev config(PP_AUDIOSAMPLERATE_44100, sample_frame_count); | |
| 22 // if (config.is_null()) | |
| 23 // return false; // Couldn't configure audio. | |
| 24 // | |
| 25 // // Then use the config to create your audio resource. | |
| 26 // Audio_dev audio(..., config, ...); | |
| 27 // if (audio.is_null()) | |
| 28 // return false; // Couldn't create audio. | |
| 29 class AudioConfig_Dev : public Resource { | |
| 30 public: | |
| 31 AudioConfig_Dev(); | |
| 32 | |
| 33 // Creates an audio config based on the given sample rate and frame count. | |
| 34 // If the rate and frame count aren't supported, the resulting resource | |
| 35 // will be is_null(). Pass the result of RecommendSampleFrameCount as the | |
| 36 // sample frame count. | |
| 37 // | |
| 38 // See PPB_AudioConfigDev.CreateStereo16Bit for more. | |
| 39 AudioConfig_Dev(Instance* instance, | |
| 40 PP_AudioSampleRate_Dev sample_rate, | |
| 41 uint32_t sample_frame_count); | |
| 42 | |
| 43 // Returns a supported frame count for use in the constructor. | |
| 44 // | |
| 45 // See PPB_AudioConfigDev.RecommendSampleFrameCount. | |
| 46 static uint32_t RecommendSampleFrameCount( | |
| 47 uint32_t requested_sample_frame_count); | |
| 48 | |
| 49 PP_AudioSampleRate_Dev sample_rate() const { return sample_rate_; } | |
| 50 uint32_t sample_frame_count() { return sample_frame_count_; } | |
| 51 | |
| 52 private: | |
| 53 PP_AudioSampleRate_Dev sample_rate_; | |
| 54 uint32_t sample_frame_count_; | |
| 55 }; | |
| 56 | |
| 57 } // namespace pp | |
| 58 | |
| 59 #endif // PPAPI_CPP_DEV_AUDIO_CONFIG_DEV_H_ | |
| 60 | |
| OLD | NEW |