OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_AUDIO_CONFIG_H_ |
| 6 #define PPAPI_CPP_AUDIO_CONFIG_H_ |
| 7 |
| 8 #include "ppapi/c/ppb_audio_config.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 = AudioConfig::RecommendSampleFrameCount( |
| 20 // PP_AUDIOSAMPLERATE_44100, 4096); |
| 21 // AudioConfig 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 audio(..., config, ...); |
| 27 // if (audio.is_null()) |
| 28 // return false; // Couldn't create audio. |
| 29 class AudioConfig : public Resource { |
| 30 public: |
| 31 AudioConfig(); |
| 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_AudioConfig.CreateStereo16Bit for more. |
| 39 AudioConfig(Instance* instance, |
| 40 PP_AudioSampleRate sample_rate, |
| 41 uint32_t sample_frame_count); |
| 42 |
| 43 // Returns a supported frame count for use in the constructor. |
| 44 // |
| 45 // See PPB_AudioConfig.RecommendSampleFrameCount. |
| 46 static uint32_t RecommendSampleFrameCount( |
| 47 PP_AudioSampleRate sample_rate, |
| 48 uint32_t requested_sample_frame_count); |
| 49 |
| 50 PP_AudioSampleRate sample_rate() const { return sample_rate_; } |
| 51 uint32_t sample_frame_count() { return sample_frame_count_; } |
| 52 |
| 53 private: |
| 54 PP_AudioSampleRate sample_rate_; |
| 55 uint32_t sample_frame_count_; |
| 56 }; |
| 57 |
| 58 } // namespace pp |
| 59 |
| 60 #endif // PPAPI_CPP_AUDIO_CONFIG_H_ |
| 61 |
OLD | NEW |