XaudioShmSampleBuffer

Section: AUDIO Extension (3)
Updated: 2008-01-17
Index Return to Main Contents
 

NAME

XaudioQueryShmSampleFormat, XaudioShmAttach, XaudioShmDetach, XaudioCreateShmSampleBuffer, - Shared memory sample buffers  

SYNOPSIS

#include <X11/extensions/Xaudio.h>

unsigned int XaudioQueryShmSampleFormat(Display *display);

XaudioShmSegment XaudioShmAttach(Display *display, int shmid, int readonly);

void XaudioShmDetach(Display *display, XaudioShmSegment shmseg);

XaudioSampleBuffer XaudioCreateShmSampleBuffer(Display *display, unsigned int size , unsigned int space, XaudioShmSegment shmseg, unsigned int offset, unsigned int baseptr_offset);

 

ARGUMENTS

display
Specifies the connection to the X server.
shmid
Kernel shared memory id.
readonly
Attach read-only to shared memory segment.
shmseg
Shared memory segment mapped into X server.
size
Number of samples stored in the buffer.
space
Number of samples slots resevred in the buffer.
offset
Byte offset into shared memory segment for sample data.
baseptr_offset
Byte offset into shared memory segment for the base index.

 

DESCRIPTION

These functions provide support for creating sample buffers in shared memory that can directly be accessed by both client application and X server. The XaudioQueryShmSampleFormat function queries the format the X server expects the samples to be in. See XaudioSampleBuffer for a list of possible formats.

The XaudioShmAttach and XaudioShmDetach functions instruct the server to attach to/ detach from a given shared memory segment. These functions will be replaced by XShmAttach/XShmDetach in later revisions.

The XaudioCreateShmSampleBuffer will create a sample buffer in shared memory. The size parameter specifies the number of valid sample values stored in the buffer, while space indicates the total space reserved within the shared memory area. space must always be an exact power of two and greater than size. offset specifies the byte offset into the shared memory segment where the sample data should be placed and baseptr_offset specifies the location of the base index; this means that multiple sample buffers may be placed into the same shared memory segment.

The shared buffer is organized as a ring buffer. Let ptr be a pointer offset bytes into the shared memory area; the sample value corresponding to index n will then be found at memory location ptr[n%space], assuming that n is inside the range of currently valid index values for the given sample buffer (see XaudioSampleBuffer(3) for a discussion of indices into sample buffers).

The base index of the sample buffer can also be placed in the shared memory segment by passing a valid offset value for baseptr_offset (passing a value of -1 or any other invalid value indicates that the pointer should not be put into shared memory); if it is placed in shared memory, it can be read and written by the client application directly, bypassing the X protocol.

Otherwise the base pointer must be modified through XaudioSampleBufferSetBase(3) or XaudioSampleBufferShiftBase(3) as usual, but these requests will not replace sample values with zero for index values that are shifted into the window; the client application is expected to clear (or put meaningful values into) the memory area before modifying the base index. Caution: Do not mix these calls with direct writes to an index value located in shared memory! No atomicity guarantees are made with respect to modification.

If synchronization with the X server is required the application should call XaudioSampleBufferGetInfo to determine the current base index from the server's point of view.

 

SEE ALSO

XaudioSampleBuffer(3), XShmAttach(3), shmat(2), shmdt(2)


 

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