Important: Inside Macintosh: Sound is deprecated as of Mac OS X v10.5. For new audio development in Mac OS X, use Core Audio. See the Audio page in the ADC Reference Library.
MyDoubleBackProc
A doubleback procedure has the following syntax:
PROCEDURE MyDoubleBackProc (chan: SndChannelPtr; exhaustedBuffer: SndDoubleBufferPtr);
chan
- A pointer to a sound channel on which a play from disk is executing.
exhaustedBuffer
- A pointer to a sound double buffer record
DESCRIPTION
The Sound Manager calls the doubleback procedure associated with a play from disk whenever the Sound Manager has exhausted the buffer. As the doubleback procedure refills the buffer, the Sound Manager plays the other buffer. Your application might also call the doubleback procedure twice to fill both buffers before the initial call toSndPlayDoubleBuffer
function.When your doubleback procedure is called, it must
If your doubleback procedure fills the buffer with the last frames of sound that need to be played, then your procedure should set the
- fill the buffer specified in the
exhaustedBuffer
parameter with the next set of sound frames that the Sound Manager must play- set the
dbNumFrames
field of the sound double buffer record to the number of frames in the buffer- set the
dbBufferReady
bit of thedbFlags
field of the sound double buffer record
dbLastBuffer
bit of thedbFlags
field of the sound double buffer record.Your doubleback procedure might fill the buffer with data from any of several sources. For example, the doubleback procedure might compute the data, copy it from elsewhere in RAM, or read it from disk. A doubleback procedure can also read data from disk and then modify the data. This might be useful, for example, if you would like the Sound Manager to be able to play sampled-sound data stored in 16-bit binary offset format. Your doubleback procedure could translate the data to the 8-bit binary offset format that the Sound Manager can read before placing it in the buffer.
SPECIAL CONSIDERATIONS
A doubleback procedure is called at interrupt time. It must not make any calls to the Memory Manager, either directly or indirectly. If your callback procedure needs to access your application's global variables, you must ensure that register A5 contains your application's A5. (You can use one of the two long integers in thedbUserInfo
field of the sound double buffer record specified by theexhaustedBuffer
parameter to pass that value to your callback procedure.)ASSEMBLY-LANGUAGE INFORMATION
Because a doubleback procedure is called at interrupt time, it must preserve all registers other than A0-A1 and D0-D2.SEE ALSO
For an example of how you might use doubleback procedures, see "Using Double Buffers" on page 2-68.