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