XaudioPCMContext

Section: AUDIO Extension (3)
Updated: 2007-08-30
Index Return to Main Contents
 

NAME

XaudioCreatePCMContext, XaudioFreePCMContext, XaudioQueryChannelLayoutRange, XaudioQuerySampleRateRange, XaudioQueryMinimumLatency, XaudioQueryMinimumTimeResolution, XaudioSetChannelLayout, XaudioSetSampleRate, XaudioSetLatency, XaudioSetTimeResolution, XaudioGetPCMContextConfiguration, XaudioAssignChannel, XaudioStart, XaudioStop - PCM context management  

SYNOPSIS

#include <X11/extensions/Xaudio.h>

XaudioPCMContext XaudioCreatePCMContext(Display *display, XaudioPCMDevice pcmdev);

void XaudioFreePCMContext(Display *display, XaudioPCMContext context);

int XaudioQueryChannelLayoutRange(Display *display, XaudioPCMContext context, unsigned int *nlayouts, unsigned int **layouts);

int XaudioQuerySampleRateRange(Display *display, XaudioPCMContext context, unsigned int *nrate_stops, unsigned int **rate_stops);

unsigned int XaudioQueryMinimumLatency(Display *display, XaudioPCMContext context);

unsigned int XaudioQueryMinimumTimeResolution(Display *display, XaudioPCMContext context);

void XaudioSetChannelLayout(Display *display, XaudioPCMContext context, unsigned int channel_layout);

void XaudioSetSampleRate(Display *display , XaudioPCMContext context, unsigned int sample_rate);

void XaudioSetLatency(Display *display, XaudioPCMContext context, unsigned int latency);

void XaudioSetTimeResolution(Display *display, XaudioPCMContext context, unsigned int time_resolution);

int XaudioGetPCMContextConfiguration(Display *display, XaudioPCMContext context, unsigned int *channel_layout, unsigned int *sample_rate, unsigned int *latency, unsigned int *time_resolution, XaudioSampleBuffer **buffers, unsigned int **positions);

void XaudioAssignChannel(Display *display, XaudioPCMContext context, unsigned int channel, XaudioSampleBuffer buffer, int index);

void XaudioStart(Display *display, XaudioPCMContext context, int start_time, int end_time);

void XaudioStop(Display *display, XaudioPCMContext context);

 

ARGUMENTS

display
Specifies the connection to the X server.
pcmdev
PCM device.
context
PCM context.
nlayouts
Returns number of channel layouts.
layouts
Returns pointer to array of supported channel layouts.
nrate_stops
Returns number of entries in sample rate ranges list.
rate_stops
Returns pointer to array of sample rate ranges.
channel_layout
Channel layout.
sample_rate
Sample rate in HZ.
latency
Buffer latency in number of samples.
time_resolution
Timer resolution in number of samples.
channel
Channel to assign sample buffer to.
buffer
Sample buffer to playback samples from/capture samples to.
index
Index of first sample to play from/first sample to capture to buffer.

 

DESCRIPTION

The XaudioCreatePCMContext function creates a PCM context; depending on the type of PCM device chosen the context will either support playback samples from or capture samples to one or more sample buffers. The XaudioFreePCMContext will free a previously allocated context.

Before PCM contexts can be used for playback or capture of audio data they must be configured. The parameters that must be set are:

*
Channel layout: Determines the number of audio channels used as well as their semantic
*
Sample rate: Determines the master sample rate; usually this equals the number of samples played or recorded for each channel per second (some channel layouts may however support a low frequency channel operating at a lower sample rate)
*
Latency: Measured in terms of the sample rate above. For playback this parameter determines the temporal distance between the sample currently played and the earliest sample that must already be available in the sample buffers. For capture this parameter determines the temporal distance between the sample currently recorded and the sample that is already available for reading from the sample buffers.
*
Time resolution: Measured in terms of the sample rate above. Determines the maximum time interval between two time ticks that the pcm context must generate.
*
Sample buffers: Sample buffers to read data from or write data to

The XaudioQueryChannelLayoutRange will return a list of supported channel layouts in an malloc'd area (the caller is responsible for freeing the memory afterwards). Applications can configure a context for a specific channel layout through the XaudioSetChannelLayout function. Each channel layout is represented as a 32 bit integer, where the lower 8 bits always correspond to the number of channels. The following symbolic constants are predefined:

XAUDIO_MONO
Single channel mono; spatial location of channels unspecified
XAUDIO_STEREO
Two channel stereo; spatial location of channels unspecified

Applications should use the closest matching channel layout from the list of supported layouts.

The XaudioQuerySampleRatetRange will return the supported sample rate ranges in an malloc'd area (the caller is responsible for freeing the memory afterwards). Applications can configure a context for a sample rate through the XaudioSetSampleRate function. The sample rates returned by XaudioQuerySampleRatetRange are encoded in the following way:

*
The ranges of supported sample rates are sorted into ascending order
*
A single supported sample rate is encoded as a 32 bit unsigned integer
*
A range of supported sample rates is encoded as two 32 bit unsigned integers: The first encodes the lower bound of the rate, the second encodes the upper bound of the range but with the highest bit set

Example: the set including the range 16000-48000 and the single value 96000 would be encoded as: 0x00003e80 0x8000bb80 0x0001770.

The XaudioQueryMinimumLatency function will return the minimum latency supported by the pcm context. Applications can configure a context for a specific latency through the XaudioSetLatency function. The latency is measured in terms of the sample rate. The exact interpretation depends on the type of context: For playback contexts the application must make sure that while the sample number n is playing, the sample numbered n+latency must already be available. For capture contexts the sample numbered n-latency is available for reading while the sample numbered n is being captured.

Applications have to schedule audio processing accordingly to take this latency into account.

The XaudioQueryMinimumTimeResolution function will return the minimum time resolution supported by the pcm context. Applications can configure a context for a specific time resolution through the XaudioSetTimeResolution function. The time resolution is measured in terms of the sample rate. Each pcm context can be used as a time source (see XtimeCreateScheduler(3) ), and the time resolution determines the temporal distance of ticks generated for this purpose. Applications must take the time resolution into account when scheduling operations (e.g. the validity interval of operations must not be shorter than the temporal distance of two ticks).

The XaudioAssignChannel function will assign a sample buffer to playback samples from/capture samples to. The index parameter identifies the first sample to read or write. The current position per channel will be updated as the PCM context progresses so that stopping and restarting a context will resume where it was stopped. Each individual channel used by a PCM context must individually be assigned a sample buffer (if no sample buffer is assigned then the channel is silenced), it is however permissible to assign the same sample buffer to multiple channels.

Reading samples from/writing samples to a sample buffer is subject to the access rules explained in XaudioSampleBuffer(3) - the base index of a sample buffer is not modified by the PCM context, it is the application's responsibility to update it in a timely fashion.

The XaudioGetPCMContextConfiguration returns the selected configuration of a pcm context. It may only be called after the context is fully configured. The function returns the sample buffer and index into the buffer for each channel as malloc'd arrays (the caller is responsible for freeing it afterwards). For channels were no buffer has been assigned zero is returned.

Applications can start playback or capture through the XaudioStart function. The start timestamp will be the initial time for the time source aspect of the pcm context (note that it does not in any way relate to the position within the sample buffers). Time will progress at the rate indicated by the sample rate. If the stop timestamp does not equal the start timestamp the context will implicitly stop at the given point in time.

Applications may stop playback or capture through the XaudioStop function.

 

SEE ALSO

XaudioSampleBuffer(3), XtimeAudio(3), XaudioPCMDevice(3)


 

Index

NAME
SYNOPSIS
ARGUMENTS
DESCRIPTION
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 13:14:25 GMT, January 31, 2008