ADC Home > Reference Library > Reference > Darwin > Kernel Framework Reference
|
IOAudioStream |
Inherits from: | |
Declared In: |
This class wraps a single sample buffer in an audio driver.
An IOAudioStream represents one hardware sample buffer as well as the direction of that buffer, the mix buffer that multiple clients mix into as well as a list of all of the formats to which this buffer can be set.
When an IOAudioEngine is created during init time in the driver, an IOAudioStream must be created for each sample buffer in the device. Typically, the sample buffer will be interleaved (or single channel), as a non-interleaved buffer should be divided into multiple single-channel buffers (and multiple IOAudioStreams).
Additionally, when an IOAudioStream is created it must have all of the possible formats (and allowed sample rates for each format) set and must have the currently set format specified (addAvailableFormat() and setFormat()).
- audioEngine
- audioIOFunctions
- availableFormatDictionaries
- availableFormats
- clientBufferListEnd
- clientBufferListStart
- clippedPosition
- commandGate
- createDictionaryFromFormat
- createFormatFromDictionary
- defaultAudioControls
- direction
- format
- maxNumChannels
- mixBuffer
- mixBufferSize
- numAvailableFormats
- numClients
- numIOFunctions
- sampleBuffer
- sampleBufferSize
- startingChannelID
- startingPosition
- streamAllocatedMixBuffer
- streamAvailable
- streamIOLock
- workLoop
- addAvailableFormat(const IOAudioStreamFormat *, const IOAudioSampleRate *, const IOAudioSampleRate *, AudioIOFunction)
- addAvailableFormat(const IOAudioStreamFormat *, const IOAudioSampleRate *, const IOAudioSampleRate *, const AudioIOFunction *, UInt32)
- addAvailableFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, const IOAudioSampleRate *, const IOAudioSampleRate *, AudioIOFunction)
- addAvailableFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, const IOAudioSampleRate *, const IOAudioSampleRate *, const AudioIOFunction *, UInt32)
- addClient
- addDefaultAudioControl
- clearAvailableFormats
- clearSampleBuffer
- clipIfNecessary
- clipOutputSamples
- free
- getDirection
- getFormat
- getFormatExtension
- getMaxNumChannels
- getMixBuffer
- getMixBufferSize
- getNumClients
- getNumSampleFramesRead
- getSampleBuffer
- getSampleBufferSize
- getStartingChannelID
- getStreamAvailable
- getWorkLoop
- hardwareFormatChanged
- initWithAudioEngine
- lockStreamForIO
- mixOutputSamples
- numSampleFramesPerBufferChanged
- processOutputSamples
- readInputSamples
- removeClient
- removeDefaultAudioControls
- resetClipInfo
- setDefaultNumSampleFramesRead
- setFormat
- setFormat(const IOAudioStreamFormat *, bool)
- setFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, bool)
- setFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, OSDictionary *, bool)
- setFormat(OSDictionary *)
- setFormatAction
- setIOFunction
- setIOFunctionList
- setMixBuffer
- setProperties
- setSampleBuffer
- setSampleLatency
- setStartingChannelNumber
- setStreamAvailable
- setTerminalType
- stop
- unlockStreamForIO
- updateNumClients
- userClientList
- validateFormat(IOAudioStreamFormat *, IOAudioStreamFormatDesc *)
- validateFormat(IOAudioStreamFormat *, IOAudioStreamFormatExtension *, IOAudioStreamFormatDesc *)
addAvailableFormat(const IOAudioStreamFormat *, const IOAudioSampleRate *, const IOAudioSampleRate *, AudioIOFunction) |
public
virtual void addAvailableFormat( const IOAudioStreamFormat *streamFormat, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, AudioIOFunction ioFunction);
Adds a single available sample format to an audio stream.
addAvailableFormat(const IOAudioStreamFormat *, const IOAudioSampleRate *, const IOAudioSampleRate *, const AudioIOFunction *, UInt32) |
public
virtual void addAvailableFormat( const IOAudioStreamFormat *streamFormat, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, const AudioIOFunction *ioFunctionList = NULL, UInt32 numFunctions = 0);
Adds a list of available sample formats to an audio stream.
addAvailableFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, const IOAudioSampleRate *, const IOAudioSampleRate *, AudioIOFunction) |
public
virtual void addAvailableFormat( const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, AudioIOFunction ioFunction);
Adds a single available format to the list of supported formats.
addAvailableFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, const IOAudioSampleRate *, const IOAudioSampleRate *, const AudioIOFunction *, UInt32) |
public
virtual void addAvailableFormat( const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, const IOAudioSampleRate *minRate, const IOAudioSampleRate *maxRate, const AudioIOFunction *ioFunctionList = NULL, UInt32 numFunctions = 0);
Adds multiple available formats to the list of supported formats in a single call.
addClient |
protected
virtual IOReturn addClient( IOAudioClientBuffer *clientBuffer);
Adds a new client to this stream..
addDefaultAudioControl |
public
virtual IOReturn addDefaultAudioControl( IOAudioControl *defaultAudioControl);
Adds a default audio control.
clearAvailableFormats |
public
virtual void clearAvailableFormats();
Clears the list of available formats.
clearSampleBuffer |
public
virtual void clearSampleBuffer();
This function zeroes the sample buffer. You should call this prior to starting the audio engine.
clipIfNecessary |
protected
virtual void clipIfNecessary();
Calls clipOutputSamples if there are frames in the mix buffer that have not been clipped.
clipOutputSamples |
protected
virtual void clipOutputSamples( UInt32 startingSampleFrame, UInt32 numSampleFrames);
Generally, this function calls the audio engine's clipOutputSamples function. This can, however, be overridden on a per-stream basis.
createDictionaryFromFormat |
public
static OSDictionary *createDictionaryFromFormat( const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, OSDictionary *formatDict = 0);
Creates an OSDictionary object from audio format values.
createFormatFromDictionary |
public
static IOAudioStreamFormat *createFormatFromDictionary( const OSDictionary *formatDict, IOAudioStreamFormat *streamFormat = 0, IOAudioStreamFormatExtension *formatExtension = 0);
Creates an audio format value from an OSDictionary object.
free |
public
virtual void free();
Frees a stream object and its instance variables.
getDirection |
public
virtual IOAudioStreamDirection getDirection();
Gets the direction of a stream.
getFormat |
public
virtual const IOAudioStreamFormat *getFormat();
Returns the current audio stream format.
getFormatExtension |
public
virtual const IOAudioStreamFormatExtension *getFormatExtension();
Gets the current format extension.
getMaxNumChannels |
public
virtual UInt32 getMaxNumChannels();
Returns the maximum number of channels for any format that this stream supports.
The next audio stream created should start at getStartingChannelID() +
getMaxNumChannels()
.
getMixBuffer |
public
virtual void *getMixBuffer();
Returns the current mix buffer.
getMixBufferSize |
public
virtual UInt32 getMixBufferSize();
Returns the size of the current mix buffer.
getNumClients |
protected
virtual UInt32 getNumClients();
Returns the current number of clients of this stream..
getNumSampleFramesRead |
public
virtual UInt32 getNumSampleFramesRead();
Returns the number of sample frames read.
getSampleBuffer |
public
virtual void *getSampleBuffer();
Returns the current sample buffer.
getSampleBufferSize |
public
virtual UInt32 getSampleBufferSize();
Returns the size of the current sample buffer.
getStartingChannelID |
public
virtual UInt32 getStartingChannelID();
Returns the first channel ID for this stream. Each successive channel
has an ID that is one higher than the last, up to getStartingChannelID() +
getMaxNumChannels() - 1
.
getStreamAvailable |
public
virtual bool getStreamAvailable();
Returns the stream's availability as set by setStreamAvailable
.
getWorkLoop |
public
virtual IOWorkLoop *getWorkLoop() const;
Returns the workloop associated with the stream.
hardwareFormatChanged |
public
virtual IOReturn hardwareFormatChanged( const IOAudioStreamFormat *streamFormat);
Notifies the Audio HAL that the hardware has requested an audio format change (such as when an external clock source changes rates).
initKeys |
public
static void initKeys();
Initializes keys to default values.
initWithAudioEngine |
public
virtual bool initWithAudioEngine( IOAudioEngine *engine, IOAudioStreamDirection dir, UInt32 startChannelID, const char *streamDescription = NULL, OSDictionary *properties = 0);
Initializes a stream object.
lockStreamForIO |
protected
virtual void lockStreamForIO();
Locks the stream for I/O.
mixOutputSamples |
public
virtual IOReturn mixOutputSamples( const void *sourceBuf, void *mixBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream);
Calls the Audio Engine's mixOutputSamples function. This may be overridden on a stream-by-stream basis by subclassing IOAudioStream.
numSampleFramesPerBufferChanged |
public
virtual void numSampleFramesPerBufferChanged();
This function should be called if you change the number of sample frames in the buffer.
processOutputSamples |
protected
virtual IOReturn processOutputSamples( IOAudioClientBuffer *clientBuffer, UInt32 firstSampleFrame, UInt32 loopCount, bool samplesAvailable);
Calls functions to mix source material into the mix buffer and, if necessary, clip the results.
readInputSamples |
protected
virtual IOReturn readInputSamples( IOAudioClientBuffer *clientBuffer, UInt32 firstSampleFrame);
Calls I/O functions to read input samples from hardware.
removeClient |
protected
virtual void removeClient( IOAudioClientBuffer *clientBuffer);
Removes a client of this stream.
removeDefaultAudioControls |
public
virtual void removeDefaultAudioControls();
Removes all default audio controls.
resetClipInfo |
protected
virtual void resetClipInfo();
Resets clip position information to zero.
setDefaultNumSampleFramesRead |
public
virtual void setDefaultNumSampleFramesRead( UInt32);
Sets the default number of sample frames read.
setFormat |
public
virtual IOReturn setFormat( const IOAudioStreamFormat *streamFormat, OSDictionary *formatDict, bool callDriver = true);
Sets the current stream format and stream format dictionary.
setFormat(const IOAudioStreamFormat *, bool) |
public
virtual IOReturn setFormat( const IOAudioStreamFormat *streamFormat, bool callDriver = true);
Sets the current stream format.
setFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, bool) |
public
virtual IOReturn setFormat( const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, bool callDriver = true);
Sets the current audio format.
setFormat(const IOAudioStreamFormat *, const IOAudioStreamFormatExtension *, OSDictionary *, bool) |
public
virtual IOReturn setFormat( const IOAudioStreamFormat *streamFormat, const IOAudioStreamFormatExtension *formatExtension, OSDictionary *formatDict, bool callDriver = true);
Sets the current audio format using a format dictionary.
setFormat(OSDictionary *) |
public
virtual IOReturn setFormat( OSDictionary *formatDict);
Sets the current stream format dictionary.
setFormatAction |
public
static IOReturn setFormatAction( OSObject *owner, void *arg1, void *arg2, void *arg3, void *arg4);
Assigns a format action callback. This function will be called when a format change occurs.
setIOFunction |
public
virtual void setIOFunction( AudioIOFunction ioFunction);
Assigns an I/O function to the stream.
setIOFunctionList |
public
virtual void setIOFunctionList( const AudioIOFunction *ioFunctionList, UInt32 numFunctions);
Assigns a list of I/O functions to the stream.
setMixBuffer |
public
virtual void setMixBuffer( void *buffer, UInt32 size);
Assigns a mix buffer of a given size to the stream.
setProperties |
public
virtual IOReturn setProperties( OSObject *properties);
Sets properties on a stream.
setSampleBuffer |
public
virtual void setSampleBuffer( void *buffer, UInt32 size);
Assigns a sample buffer of a given size to the stream.
setSampleLatency |
public
virtual void setSampleLatency( UInt32 numSamples);
Calls the Audio Engine's setSampleLatency function. This may be overridden on a stream-by-stream basis by subclassing IOAudioStream.
setStartingChannelNumber |
protected
virtual void setStartingChannelNumber( UInt32 channelNumber);
Sets the starting channel number for this stream.
setStreamAvailable |
public
virtual void setStreamAvailable( bool available);
Marks a stream as available or unavailable for use.
setTerminalType |
public
virtual void setTerminalType( const UInt32 terminalType);
Sets the terminal type of the current stream.
stop |
public
virtual void stop( IOService *provider);
Stops an audio stream.
unlockStreamForIO |
protected
virtual void unlockStreamForIO();
Unlocks the stream for I/O.
updateNumClients |
protected
virtual void updateNumClients();
Iterates the stream's client list and updates the current count of clients.
validateFormat(IOAudioStreamFormat *, IOAudioStreamFormatDesc *) |
public
virtual bool validateFormat( IOAudioStreamFormat *streamFormat, IOAudioStreamFormatDesc *formatDesc);
Validates an audio format.
validateFormat(IOAudioStreamFormat *, IOAudioStreamFormatExtension *, IOAudioStreamFormatDesc *) |
public
virtual bool validateFormat( IOAudioStreamFormat *streamFormat, IOAudioStreamFormatExtension *formatExtension, IOAudioStreamFormatDesc *formatDesc);
Validates an audio format format (with format extension).
AudioIOFunction |
public
typedef IOReturn ( *AudioIOFunction)( const void *mixBuf, void *sampleBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream);
The audio IO function pointer is the standard function prototype for various Audio I/O-related callbacks into device drivers from the Core Audio HAL.
audioEngine |
public
IOAudioEngine *audioEngine;
The audio engine associated with this stream.
audioIOFunctions |
public
AudioIOFunction *audioIOFunctions;
An array of audio IO function callbacks.
availableFormatDictionaries |
public
OSArray *availableFormatDictionaries;
An OSArray of available format dictionaries.
availableFormats |
public
IOAudioStreamFormatDesc *availableFormats;
A list of available stream formats.
clientBufferListEnd |
public
IOAudioClientBuffer *clientBufferListEnd;
The tail of a list of audio client buffers.
clientBufferListStart |
public
IOAudioClientBuffer *clientBufferListStart;
The head of a list of audio client buffers.
clippedPosition |
public
IOAudioEnginePosition clippedPosition;
The position in the sample buffer which has been clipped and is thus available for playback.
commandGate |
public
IOCommandGate *commandGate;
The command gate associated with this stream.
defaultAudioControls |
public
OSSet *defaultAudioControls;
A set of audion controls.
direction |
public
IOAudioStreamDirection direction;
The direction of the audio stream.
format |
public
IOAudioStreamFormat format;
An IOAudioStreamFormat object containing the stream's current format.
gAlignmentKey |
public
static const OSSymbol *gAlignmentKey;
Alignment value for streams that contain padding. Possible values are
described in IOAudioStreamAlignments
.
gBitDepthKey |
public
static const OSSymbol *gBitDepthKey;
Bit depth of samples.
gBitWidthKey |
public
static const OSSymbol *gBitWidthKey;
Bit width of samples (including padding).
gByteOrderKey |
public
static const OSSymbol *gByteOrderKey;
Byte order of samples within an audio stream. Possible values are
described in IOAudioStreamByteOrder
.
gDirectionKey |
public
static const OSSymbol *gDirectionKey;
Audio stream direction (possible values are "Output" and "Input").
gDriverTagKey |
public
static const OSSymbol *gDriverTagKey;
Driver tag key.
gIsMixableKey |
public
static const OSSymbol *gIsMixableKey;
Indicates whether the current format of the audio buffer is mixable. Examples of non-mixable formats include encoded formats such as AC-3.
gMaximumSampleRateKey |
public
static const OSSymbol *gMaximumSampleRateKey;
Maximum sample rate.
gMinimumSampleRateKey |
public
static const OSSymbol *gMinimumSampleRateKey;
Minimum sample rate.
gNumChannelsKey |
public
static const OSSymbol *gNumChannelsKey;
The number of channels in this stream.
gNumericRepresentationKey |
public
static const OSSymbol *gNumericRepresentationKey;
The numberic representation. Possible values are described in
IOAudioStreamNumericRepresentations
.
gSampleFormatKey |
public
static const OSSymbol *gSampleFormatKey;
The current sample format for this stream.
maxNumChannels |
public
UInt32 maxNumChannels;
The maximum number of channels of any format provided by this stream.
mixBuffer |
public
void *mixBuffer;
A pointer to the mix buffer
mixBufferSize |
public
UInt32 mixBufferSize;
The size of the mix buffer (in bytes)
numAvailableFormats |
public
UInt32 numAvailableFormats;
The number of available formats.
numClients |
public
UInt32 numClients;
The current number of clients utilizing this stream.
numIOFunctions |
public
UInt32 numIOFunctions;
The number of functions in the audioIOFunctions
array.
sampleBuffer |
public
void *sampleBuffer;
A pointer to the raw sample buffer
sampleBufferSize |
public
UInt32 sampleBufferSize;
The size of the sample buffer (in bytes)
startingChannelID |
public
UInt32 startingChannelID;
The starting channel ID.
startingPosition |
public
IOAudioEnginePosition startingPosition;
The starting position in the sample buffer.
streamAllocatedMixBuffer |
public
bool streamAllocatedMixBuffer;
Set to true if the audio stream contains a mix buffer that needs to be freed.
streamAvailable |
public
bool streamAvailable;
True if this stream is available.
streamIOLock |
public
IORecursiveLock *streamIOLock;
A stream-specific lock.
userClientList |
public
IOAudioClientBuffer *userClientList;
A list of user clients.
workLoop |
public
IOWorkLoop *workLoop;
The workloop associated with this stream.
|
Last Updated: 2008-12-19