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 #ifndef PPAPI_CPP_AUDIO_CONFIG_H_ | 5 #ifndef PPAPI_CPP_AUDIO_CONFIG_H_ |
6 #define PPAPI_CPP_AUDIO_CONFIG_H_ | 6 #define PPAPI_CPP_AUDIO_CONFIG_H_ |
7 | 7 |
8 #include "ppapi/c/ppb_audio_config.h" | 8 #include "ppapi/c/ppb_audio_config.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 | 12 |
13 /// @file | 13 /// @file |
14 /// This file defines the interface for establishing an | 14 /// This file defines the interface for establishing an |
15 /// audio configuration resource within the browser. | 15 /// audio configuration resource within the browser. |
16 | 16 |
17 namespace pp { | 17 namespace pp { |
18 | 18 |
19 class InstanceHandle; | 19 class InstanceHandle; |
20 | 20 |
21 /// A 16 bit stereo AudioConfig resource. Refer to the | 21 /// A 16 bit stereo AudioConfig resource. Refer to the |
22 /// <a href="/chrome/nativeclient/docs/audio.html">Pepper | 22 /// <a href="/native-client/{{pepperversion}}/devguide/coding/audio">Audio |
23 /// Audio API Code Walkthrough</a> for information on using this interface. | 23 /// </a> chapter in the Developer's Guide for information on using this |
| 24 /// interface. |
24 /// | 25 /// |
25 /// A single sample frame on a stereo device means one value for the left | 26 /// A single sample frame on a stereo device means one value for the left |
26 /// channel and one value for the right channel. | 27 /// channel and one value for the right channel. |
27 /// | 28 /// |
28 /// Buffer layout for a stereo int16 configuration: | 29 /// Buffer layout for a stereo int16 configuration: |
29 /// | 30 /// |
30 /// <code>int16_t *buffer16;</code> | 31 /// <code>int16_t *buffer16;</code> |
31 /// <code>buffer16[0]</code> is the first left channel sample. | 32 /// <code>buffer16[0]</code> is the first left channel sample. |
32 /// <code>buffer16[1]</code> is the first right channel sample. | 33 /// <code>buffer16[1]</code> is the first right channel sample. |
33 /// <code>buffer16[2]</code> is the second left channel sample. | 34 /// <code>buffer16[2]</code> is the second left channel sample. |
34 /// <code>buffer16[3]</code> is the second right channel sample. | 35 /// <code>buffer16[3]</code> is the second right channel sample. |
35 /// <code>...</code> | 36 /// <code>...</code> |
36 /// <code>buffer16[2 * (sample_frame_count - 1)]</code> is the last left | 37 /// <code>buffer16[2 * (sample_frame_count - 1)]</code> is the last left |
37 /// channel sample. | 38 /// channel sample. |
38 /// <code>buffer16[2 * (sample_frame_count - 1) + 1]</code> is the last right | 39 /// <code>buffer16[2 * (sample_frame_count - 1) + 1]</code> is the last right |
39 /// channel sample. | 40 /// channel sample. |
40 /// Data will always be in the native endian format of the platform. | 41 /// Data will always be in the native endian format of the platform. |
41 /// | 42 /// |
42 /// <strong>Example:</strong> | 43 /// <strong>Example:</strong> |
43 /// <code> | 44 /// @code |
44 /// | 45 /// |
45 /// // Create an audio config with a supported frame count. | 46 /// // Create an audio config with a supported frame count. |
46 /// uint32_t sample_frame_count = AudioConfig::RecommendSampleFrameCount( | 47 /// uint32_t sample_frame_count = AudioConfig::RecommendSampleFrameCount( |
47 /// PP_AUDIOSAMPLERATE_44100, 4096); | 48 /// PP_AUDIOSAMPLERATE_44100, 4096); |
48 /// AudioConfig config(PP_AUDIOSAMPLERATE_44100, sample_frame_count); | 49 /// AudioConfig config(PP_AUDIOSAMPLERATE_44100, sample_frame_count); |
49 /// if (config.is_null()) | 50 /// if (config.is_null()) |
50 /// return false; // Couldn't configure audio. | 51 /// return false; // Couldn't configure audio. |
51 /// | 52 /// |
52 /// // Then use the config to create your audio resource. | 53 /// // Then use the config to create your audio resource. |
53 /// Audio audio(instance, config, callback, user_data); | 54 /// Audio audio(instance, config, callback, user_data); |
54 /// if (audio.is_null()) | 55 /// if (audio.is_null()) |
55 /// return false; // Couldn't create audio. | 56 /// return false; // Couldn't create audio. |
56 /// </code> | 57 /// @endcode |
57 class AudioConfig : public Resource { | 58 class AudioConfig : public Resource { |
58 public: | 59 public: |
59 /// An empty constructor for an <code>AudioConfig</code> resource. | 60 /// An empty constructor for an <code>AudioConfig</code> resource. |
60 AudioConfig(); | 61 AudioConfig(); |
61 | 62 |
62 /// A constructor that creates an audio config based on the given sample rate | 63 /// A constructor that creates an audio config based on the given sample rate |
63 /// and frame count. If the rate and frame count aren't supported, the | 64 /// and frame count. If the rate and frame count aren't supported, the |
64 /// resulting resource will be is_null(). You can pass the result of | 65 /// resulting resource will be is_null(). You can pass the result of |
65 /// RecommendSampleFrameCount() as the sample frame count. | 66 /// RecommendSampleFrameCount() as the sample frame count. |
66 /// | 67 /// |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 | 122 |
122 private: | 123 private: |
123 PP_AudioSampleRate sample_rate_; | 124 PP_AudioSampleRate sample_rate_; |
124 uint32_t sample_frame_count_; | 125 uint32_t sample_frame_count_; |
125 }; | 126 }; |
126 | 127 |
127 } // namespace pp | 128 } // namespace pp |
128 | 129 |
129 #endif // PPAPI_CPP_AUDIO_CONFIG_H_ | 130 #endif // PPAPI_CPP_AUDIO_CONFIG_H_ |
130 | 131 |
OLD | NEW |