Plugins:PepperAudioAPI: Difference between revisions

no edit summary
No edit summary
Line 35: Line 35:
The browser might be responsible for applying additional user volume or muting control,and may upsample/downsample the audio data before mixing with other browser audiosources.  
The browser might be responsible for applying additional user volume or muting control,and may upsample/downsample the audio data before mixing with other browser audiosources.  


All future versions of PEPPER will support version 1 (this proposal) as a bare minimum.  
All future versions of PEPPER will support version 1 (this proposal) as a bare minimum.


Trusted PEPPER modules will be able to open more than one audio context.Untrusted PEPPER modules might be restricted to a single audio context.In either environment, it is assumed multi-threading is available.  
Trusted PEPPER modules will be able to open more than one audio context. Untrusted PEPPER modules might be restricted to a single audio context. In either environment, it is assumed multi-threading is available.


This document contains two models - one based on callbacks, and one based on a blockingpush model. While both models are fundamentally the same, they do carry some subtledifferences:  
This document contains two models - one based on callbacks, and one based on a blocking push model. While both models are fundamentally the same, they do carry some subtle differences:  


*Blocking Push API provides more control, and assumes threading will be explicitly handled by the application. When writing trusted PEPPER modules without a platform independent threading library, this may imply the application writer to #if WIN32, #if PTHREADS, etc. around the application's audio thread setup code.  
*Blocking Push API provides more control, and assumes threading will be explicitly handled by the application. When writing trusted PEPPER modules without a platform independent threading library, this may imply the application writer to #if WIN32, #if PTHREADS, etc. around the application's audio thread setup code.  
*Callback API does not require application to setup/teardown audio thread, and the API entry points are all on the NPAPI thread -- only the callback occurs on an implicit, dedicated audio thread.  
*Callback API does not require application to setup/teardown audio thread, and the API entry points are all on the NPAPI thread -- only the callback occurs on an implicit, dedicated audio thread.  
*There might be some subtle implementation details when it comes to how each model needs to signal between the audio device and the PEPPER audio interface. These signals will need to be as fast and low latency as possible, so minimizing how many signals are required will be important.
*There might be some subtle implementation details when it comes to how each model needs to signal between the audio device and the PEPPER audio interface. These signals will need to be as fast and low latency as possible, so minimizing how many signals are required will be important.


=====Background:=====
=====Background:=====
Native Client plug-ns have up until now used an audio API very similar to a blockingflushContext() call, usually done on a thread dedicated to audio. The API call wasimplemented as a syscall, and at the service runtime (kernel) level used SDL to deliver lowlatency audio across multiple platforms. As Native Client moves into a more securesandbox environment, untrusted code will no longer be able to communicate directly withaudio devices in the same process. In the new audio model, trusted code in anotherprocess will be attached to the audio device, and the sandboxed Native Client untrustedapplication will use shared memory and sockets to communicate its audio needs outside thesandbox. The new API for this model will be part of PEPPER, a variant of NPAPI that isdesigned to be platform neutral.


Please refer to Appendix A for a list of links pertaining to audio.Please refer to Appendix B for PEPPER design wiki -- where this document will migrate onceapproved.  
Native Client plug-ins have up until now used an audio API very similar to a blockingflushContext() call, usually done on a thread dedicated to audio. The API call wasimplemented as a syscall, and at the service runtime (kernel) level used SDL to deliver low latency audio across multiple platforms. As Native Client moves into a more secure sandbox environment, untrusted code will no longer be able to communicate directly with audio devices in the same process. In the new audio model, trusted code in another process will be attached to the audio device, and the sandboxed Native Client untrusted application will use shared memory and sockets to communicate its audio needs outside the sandbox. The new API for this model will be part of PEPPER, a variant of NPAPI that is designed to be platform neutral.  


Both models will need additional PEPPER events. Please refer to Appendix C for audiorelated events.  
Please refer to Appendix A for a list of links pertaining to audio.Please refer to Appendix B for PEPPER design wiki -- where this document will migrate once approved.  


Both models support multi-channel configurations. Please refer to Appendix E for multi-channel output scenarios.Please refer to Appendix F for input scenarios.Please refer to Appendix G for contributers.  
Both models will need additional PEPPER events. Please refer to Appendix C for audio related events.
 
Both models support multi-channel configurations. Please refer to Appendix E for multi-channel output scenarios.Please refer to Appendix F for input scenarios. Please refer to Appendix G for contributors.  


===Changes to Pepper's Device API===
===Changes to Pepper's Device API===
Previously, Pepper's device API consisted of the methods initializeContext, flushContext, and destroyContext. Audio extends this API to queryCapability, queryConfig, initializeContext, flushContext, getState, setState, and destroyContext.   
 
Previously, Pepper's device API consisted of the methods initializeContext, flushContext, and destroyContext. Audio extends this API to queryCapability, queryConfig, initializeContext, flushContext, getState, setState, and destroyContext.   


:queryCapability - ask a device about a specific capability  
:queryCapability - ask a device about a specific capability  
Confirmed users, Bureaucrats and Sysops emeriti
1,680

edits