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_H_ | 5 #ifndef PPAPI_CPP_AUDIO_H_ |
6 #define PPAPI_CPP_AUDIO_H_ | 6 #define PPAPI_CPP_AUDIO_H_ |
7 | 7 |
8 #include "ppapi/c/pp_stdint.h" | 8 #include "ppapi/c/pp_stdint.h" |
9 #include "ppapi/c/ppb_audio.h" | 9 #include "ppapi/c/ppb_audio.h" |
10 #include "ppapi/cpp/audio_config.h" | 10 #include "ppapi/cpp/audio_config.h" |
11 #include "ppapi/cpp/instance.h" | |
12 #include "ppapi/cpp/resource.h" | 11 #include "ppapi/cpp/resource.h" |
13 | 12 |
14 /// @file | 13 /// @file |
15 /// This file defines the API to create realtime stereo audio streaming | 14 /// This file defines the API to create realtime stereo audio streaming |
16 /// capabilities. | 15 /// capabilities. |
17 | 16 |
18 namespace pp { | 17 namespace pp { |
19 | 18 |
| 19 class InstanceHandle; |
| 20 |
20 /// An audio resource. Refer to the | 21 /// An audio resource. Refer to the |
21 /// <a href="/native-client/devguide/coding/audio">Audio</a> | 22 /// <a href="/native-client/devguide/coding/audio">Audio</a> |
22 /// chapter in the Developer's Guide for information on using this interface. | 23 /// chapter in the Developer's Guide for information on using this interface. |
23 class Audio : public Resource { | 24 class Audio : public Resource { |
24 public: | 25 public: |
25 | 26 |
26 /// An empty constructor for an Audio resource. | 27 /// An empty constructor for an Audio resource. |
27 Audio() {} | 28 Audio() {} |
28 | 29 |
29 /// A constructor that creates an Audio resource. No sound will be heard | 30 /// A constructor that creates an Audio resource. No sound will be heard |
30 /// until StartPlayback() is called. The callback is called with the buffer | 31 /// until StartPlayback() is called. The callback is called with the buffer |
31 /// address and given user data whenever the buffer needs to be filled. | 32 /// address and given user data whenever the buffer needs to be filled. |
32 /// From within the callback, you should not call <code>PPB_Audio</code> | 33 /// From within the callback, you should not call <code>PPB_Audio</code> |
33 /// functions. The callback will be called on a different thread than the one | 34 /// functions. The callback will be called on a different thread than the one |
34 /// which created the interface. For performance-critical applications (such | 35 /// which created the interface. For performance-critical applications (such |
35 /// as low-latency audio), the callback should avoid blocking or calling | 36 /// as low-latency audio), the callback should avoid blocking or calling |
36 /// functions that can obtain locks, such as malloc. The layout and the size | 37 /// functions that can obtain locks, such as malloc. The layout and the size |
37 /// of the buffer passed to the audio callback will be determined by | 38 /// of the buffer passed to the audio callback will be determined by |
38 /// the device configuration and is specified in the <code>AudioConfig</code> | 39 /// the device configuration and is specified in the <code>AudioConfig</code> |
39 /// documentation. | 40 /// documentation. |
40 /// | 41 /// |
41 /// @param[in] instance A pointer to an <code>Instance</code> identifying one | 42 /// @param[in] instance The instance with which this resource will be |
42 /// instance of a module. | 43 /// associated. |
| 44 // |
43 /// @param[in] config An <code>AudioConfig</code> containing the audio config | 45 /// @param[in] config An <code>AudioConfig</code> containing the audio config |
44 /// resource. | 46 /// resource. |
| 47 // |
45 /// @param[in] callback A <code>PPB_Audio_Callback</code> callback function | 48 /// @param[in] callback A <code>PPB_Audio_Callback</code> callback function |
46 /// that the browser calls when it needs more samples to play. | 49 /// that the browser calls when it needs more samples to play. |
| 50 // |
47 /// @param[in] user_data A pointer to user data used in the callback function. | 51 /// @param[in] user_data A pointer to user data used in the callback function. |
48 Audio(Instance* instance, | 52 Audio(const InstanceHandle& instance, |
49 const AudioConfig& config, | 53 const AudioConfig& config, |
50 PPB_Audio_Callback callback, | 54 PPB_Audio_Callback callback, |
51 void* user_data); | 55 void* user_data); |
52 | 56 |
53 /// Getter function for returning the internal <code>PPB_AudioConfig</code> | 57 /// Getter function for returning the internal <code>PPB_AudioConfig</code> |
54 /// struct. | 58 /// struct. |
55 /// | 59 /// |
56 /// @return A mutable reference to the PPB_AudioConfig struct. | 60 /// @return A mutable reference to the PPB_AudioConfig struct. |
57 AudioConfig& config() { return config_; } | 61 AudioConfig& config() { return config_; } |
58 | 62 |
(...skipping 15 matching lines...) Expand all Loading... |
74 bool StopPlayback(); | 78 bool StopPlayback(); |
75 | 79 |
76 private: | 80 private: |
77 AudioConfig config_; | 81 AudioConfig config_; |
78 }; | 82 }; |
79 | 83 |
80 } // namespace pp | 84 } // namespace pp |
81 | 85 |
82 #endif // PPAPI_CPP_AUDIO_H_ | 86 #endif // PPAPI_CPP_AUDIO_H_ |
83 | 87 |
OLD | NEW |