Introduction and Overview
SharedSoundBuffer is a module for playing raw data using the SharedSound module. It requires SharedSound version 1.0 or later.
The module has been designed so it is easy to play sounds from any application.
Technical Details
In order to play audio data, SharedSoundBuffer is called in the background by SharedSound. This allows the module to continue in, and out of the desktop. Data may be passed during callbacks, allowing the system as a whole to run independent on any foreground application.
When streaming, an application must feed data to SharedSoundBuffer in a timely fashion. Data is supplied as arbitrary sized blocks, which are consulted in the order in which they were presented to the module. If the player runs out of data it will pause until some more data is supplied. Blocks are copied by SharedSoundBuffer, so they must only be kept for the duration of the call to AddBlock.
When the end of a buffer is reached, the player will continue seamlessly to the next buffer. The data should be frame-aligned, i.e. each block supplied should be a multiple of four bytes, but it is not necessary to ensure that they are a multiple of the SharedSound fill buffer.
A base handle is provided, this is always present and has a stream handle of zero. This does not need to be opened, and cannot be closed, and should be used by programs which only output short, atomic samples. It should not be used by programs which multi-task between adding blocks, otherwise other programs may intersperse their data in with it. It should also not be used by background routines for the same reasons.
SWI calls
Errors
This error is returned by SWI SharedSoundBuffer_AddBlock when the block passed would cause there to be more data buffered than the threshold set with SWI SharedSoundBuffer_SetBuffer. The block passed is not added to the queue.