| 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_C_DEV_PPB_AUDIO_DEV_H_ | 5 #ifndef PPAPI_C_DEV_PPB_AUDIO_DEV_H_ |
| 6 #define PPAPI_C_DEV_PPB_AUDIO_DEV_H_ | 6 #define PPAPI_C_DEV_PPB_AUDIO_DEV_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_bool.h" |
| 8 #include "ppapi/c/pp_instance.h" | 9 #include "ppapi/c/pp_instance.h" |
| 9 #include "ppapi/c/pp_module.h" | 10 #include "ppapi/c/pp_module.h" |
| 10 #include "ppapi/c/pp_resource.h" | 11 #include "ppapi/c/pp_resource.h" |
| 11 #include "ppapi/c/pp_stdint.h" | 12 #include "ppapi/c/pp_stdint.h" |
| 12 | 13 |
| 13 #define PPB_AUDIO_DEV_INTERFACE "PPB_Audio(Dev);0.2" | 14 #define PPB_AUDIO_DEV_INTERFACE "PPB_Audio(Dev);0.3" |
| 14 | 15 |
| 15 // Callback function type for SetCallback. | 16 // Callback function type for SetCallback. |
| 16 typedef void (*PPB_Audio_Callback)(void* sample_buffer, | 17 typedef void (*PPB_Audio_Callback)(void* sample_buffer, |
| 17 size_t buffer_size_in_bytes, | 18 size_t buffer_size_in_bytes, |
| 18 void* user_data); | 19 void* user_data); |
| 19 | 20 |
| 20 // Callback-based audio interface. User of audio must set the callback that will | 21 // Callback-based audio interface. User of audio must set the callback that will |
| 21 // be called each time that the buffer needs to be filled. | 22 // be called each time that the buffer needs to be filled. |
| 22 // | 23 // |
| 23 // A C++ example: | 24 // A C++ example: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 // performance-critical applications (i.e. low-latency audio), the callback | 43 // performance-critical applications (i.e. low-latency audio), the callback |
| 43 // should avoid blocking or calling functions that can obtain locks, such as | 44 // should avoid blocking or calling functions that can obtain locks, such as |
| 44 // malloc. The layout and the size of the buffer passed to the audio callback | 45 // malloc. The layout and the size of the buffer passed to the audio callback |
| 45 // will be determined by the device configuration and is specified in the | 46 // will be determined by the device configuration and is specified in the |
| 46 // AudioConfig documentation. If the configuration cannot be honored, or the | 47 // AudioConfig documentation. If the configuration cannot be honored, or the |
| 47 // callback is null, the function returns 0. | 48 // callback is null, the function returns 0. |
| 48 PP_Resource (*Create)(PP_Instance instance, PP_Resource config, | 49 PP_Resource (*Create)(PP_Instance instance, PP_Resource config, |
| 49 PPB_Audio_Callback audio_callback, void* user_data); | 50 PPB_Audio_Callback audio_callback, void* user_data); |
| 50 | 51 |
| 51 /** | 52 /** |
| 52 * Returns true if the given resource is an Audio resource. | 53 * Returns PP_TRUE if the given resource is an Audio resource, PP_FALSE |
| 54 * otherwise. |
| 53 */ | 55 */ |
| 54 bool (*IsAudio)(PP_Resource resource); | 56 PP_Bool (*IsAudio)(PP_Resource resource); |
| 55 | 57 |
| 56 // Get the current configuration. | 58 // Get the current configuration. |
| 57 PP_Resource (*GetCurrentConfig)(PP_Resource audio); | 59 PP_Resource (*GetCurrentConfig)(PP_Resource audio); |
| 58 | 60 |
| 59 // Start the playback. Begin periodically calling the callback. If called | 61 // Start the playback. Begin periodically calling the callback. If called |
| 60 // while playback is already in progress, will return true and be a no-op. | 62 // while playback is already in progress, will return PP_TRUE and be a no-op. |
| 61 // On error, return false. | 63 // On error, return PP_FALSE. |
| 62 bool (*StartPlayback)(PP_Resource audio); | 64 PP_Bool (*StartPlayback)(PP_Resource audio); |
| 63 | 65 |
| 64 // Stop the playback. If playback is already stopped, this is a no-op and | 66 // Stop the playback. If playback is already stopped, this is a no-op and |
| 65 // returns true. On error, returns false. If a callback is in progress, | 67 // returns PP_TRUE. On error, returns PP_FALSE. If a callback is in progress, |
| 66 // StopPlayback will block until callback completes. | 68 // StopPlayback will block until callback completes. |
| 67 bool (*StopPlayback)(PP_Resource audio); | 69 PP_Bool (*StopPlayback)(PP_Resource audio); |
| 68 }; | 70 }; |
| 69 | 71 |
| 70 #endif // PPAPI_C_DEV_PPB_DEVICE_CONTEXT_AUDIO_DEV_H_ | 72 #endif // PPAPI_C_DEV_PPB_DEVICE_CONTEXT_AUDIO_DEV_H_ |
| 71 | |
| OLD | NEW |