AudioQueue Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Base class for Input and Output audio queues.
public abstract class AudioQueue : IDisposable
type AudioQueue = class
interface IDisposable
- Inheritance
-
AudioQueue
- Derived
- Implements
Remarks
AudioQueues can be used to record audio from the system input devices into a stream, and to play back audio. They are responsible for encoding your audio when recording or decoding your compressed audio when playing back and interact directly with the audio hardware and decoding hardware where appropriate.
AudioQueue is a base class for both the InputAudioQueue which is used to record audio and the OutputAudioQueue which is used to playback audio. This class provides services to start, prime, stop, pause the queues as well as volume control, resource management and event notifications.
When you use AudioQueues, you must allocate buffers for playback or recording. You use the AllocateBuffer(Int32, AudioQueueBuffer*) method or the AllocateBufferWithPacketDescriptors(Int32, Int32, IntPtr) to allocate them and you use the FreeBuffer(IntPtr) to release them. You keep a collection of buffers around that the underlying hardware can use to either playback audio, or record into. As the buffers are used, a notification callback is invoked. In the OutputAudioQueue case, you connect to the OutputCompleted event to be notified when a buffer has been fully played back, and in the InputAudioQueue you use the InputCompleted event to be notified when a recording has fully utilized a buffer.
Unless otherwise specified, the callbacks for processing a filled audio buffer, or filling out an audio buffer are invoked on an AudioQueue thread. You can change this by providing an instance of the CFRunLoop that you want to use for processing the events in your queue.
When processing an input or output queue, you might want to listen to a few property changes raised by the queues during their processing (See the E:AudioToolBox.AudioQueueProperty for a list of events that you can listen to). To do this, use the AddListener(AudioQueueProperty, AudioQueue+AudioQueuePropertyChanged) method to add a listener and use the RemoveListener(AudioQueueProperty, AudioQueue+AudioQueuePropertyChanged) method to remove the listener.
You can see the StreamingAudio to see how to use AudioBuffers.
The various AudioQueue properties are exposed as high-level C# properties. In addition to the high-level properties, a low-level interface to the AudioQueue property system is exposed in case Apple introduces a new property that was not previously bound or if you need finer grained control. The low-level interface is provided by the GetProperty and SetProperty family of methods.
Fields
gch | |
handle |
Properties
AudioStreamDescription | |
AudioStreamPacketDescription |
Obsolete.
The audio queue's AudioStreamBasicDescription. |
ChannelLayout |
The audio queue channel layout. |
ConverterError |
Contains the most recent error generated in the audio queue's encoding or decoding process. |
CurrentDevice |
Unique identifier for the device associated with this Audio Queue. |
CurrentLevelMeter |
Current Level meters, one per channel in the range zero (minimum) to one (maximum). |
CurrentLevelMeterDB |
Current Level meters, one per channel in decibels. |
CurrentTime |
Returns the current time for the hardware device. |
DecodeBufferSizeFrames | |
DeviceChannels | |
EnableLevelMetering |
Enables level metering on the audio queue. |
Handle |
Handle (pointer) to the unmanaged object representation. |
HardwareCodecPolicy | |
IsRunning | |
MagicCookie |
Audio metadata required by certain formats. |
MaximumOutputPacketSize | |
Pan | |
SampleRate | |
Volume |
The volume |
VolumeRampTime |