SPBOpenDevice
You can use the SPBOpenDevice function to open a sound input device.
FUNCTION SPBOpenDevice (deviceName: Str255; permission: Integer;
VAR inRefNum: LongInt): OSErr;
deviceName
- The name of the sound input device to open, or the empty string if the default sound input device is to be opened.
permission
- A flag that indicates whether subsequent operations with that device are to be read/write or read-only.
inRefNum
- On exit, if the function is successful, a device reference number for the open sound input device.
DESCRIPTION
The SPBOpenDevice function attempts to open a sound input device having the name indicated by the deviceName parameter. If SPBOpenDevice succeeds, it returns a device reference number in the inRefNum parameter. The permission parameter indicates whether subsequent operations with that device are to be read/write or read-only. If the device is not already in use, read/write permission is granted; otherwise, only read-only operations are allowed. To make any recording requests or to call the SPBSetDeviceInfo function, read/write permission must be available. Use these constants to request the appropriate permission:
CONST
siReadPermission = 0; {open device for reading}
siWritePermission = 1; {open device for reading/writing}
You can request that the current default sound input device be opened by passing either a zero-length string or a NIL string as the deviceName parameter. If only one sound input device is installed, that device is used. Generally you should open the default device unless you specifically want to use some other device. You can get a list of the available devices by calling the SPBGetIndexedDevice function.
SPECIAL CONSIDERATIONS
Because the SPBOpenDevice function allocates memory, you should not call it at interrupt time.
ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for the SPBOpenDevice function are
| Trap macro | Selector |
| _SoundDispatch | $05180014 |
RESULT CODES
| noErr | 0 | No error |
| permErr | -54 | Device already open for writing |
| siBadDeviceName | -228 | Invalid device name |