简体   繁体   中英

OS X play Audio Frames are they are sent to me

What API can I use in OS X 10.7 to output linear PCM audio frames that are being generated by an existing object that I cannot alter, and passed to an object of a class of my creation? I don't have access to the originating audio stream, just the packets. Can a CoreAudio AudioUnit or AudioQueue, or maybe an AVAudioPlayer be set up to simply play these frames as they are sent to my object?

There is no public API on a Mac OS X or iOS device that can play a stream of PCM audio samples as they are generated by an existing source.

Both the Audio Queue and (RemoteIO) Audio Unit APIs are callback ("pull") based, run at strict sample rates, and have real-time requirements (eg you can't just wait for data in a callback). Your object will have to save the audio PCM frames, as they are generated by the source, within its own buffers or data structures, and then copy samples from those buffers in the amounts requested by the audio callbacks. Your object may also have to preload buffers by some amount before starting audio, adaptively handle underflow if samples are generated at a rate less than the audio callbacks require, as well as handle overflow if it receives more data than it can buffer somewhere and play in a timely manner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM