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);
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.