Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 2 - Sound Manager / Sound Manager Reference
Application-Defined Routines / Doubleback Procedures


Legacy Documentclose button

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 to SndPlayDoubleBuffer 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 dbLastBuffer bit of the dbFlags 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 the dbUserInfo field of the sound double buffer record specified by the exhaustedBuffer 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.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996