ADC Home > Reference Library > Technical Q&As > Audio > Carbon >
Important: The information in this document is Not Recommended and should not be used for new development.
Current information on this Reference Library topic can be found here:
|
Q How do I use the new siMonitorAvailable
and siMonitorSource selectors?A These selectors work with the sound output component to select the source that the user hears and makes that source the default recording source. Because this selector works with only with the sound output component, you don't need a sound channel to use it. The Here is some sample code showing how to find a sound output
component and use the include <Sound.h> #include <Errors.h> #include <Memory.h> // A simple application that gets the available monitor sources, // finds each of the monitor source names, // determines which sources are enabled, and sets various sources. void main(void) { NumVersionVariant smVersion; ComponentResult err; OSType source; SoundInfoList monitorList; Component device; ComponentDescription looking; smVersion.parts = SndSoundManagerVersion(); // Only Sound Manager 3.1 or later implements the SoundComponentGet/SetInfo calls. // If you know you're going to run on System 7.5 or later, // you can skip the SM version check. if (smVersion.whole >= 0x03100000) { looking.componentType = kSoundOutputDeviceType; looking.componentSubType = 0; looking.componentManufacturer = kAppleManufacturer; looking.componentFlags = 0; looking.componentFlagsMask = 0; device = FindNextComponent (0, &looking); // here's how to get a list of the available monitor sources // (and tell if monitor sources are supported) // this returns a list of the OSTypes for the sources // (don't forget to dispose of the handle later) err = GetSoundOutputInfo(device, siMonitorAvailable, &monitorList); if (err != noErr) // monitor sources not supported, bail in your own way goto Exit; DisposeHandle(monitorList.infoHandle); // don't forget to dispose of the returned handle // find out which source is monitored GetSoundOutputInfo(device, siMonitorSource, &source); // set CD as the monitor source (if it is present - err <> noErr if not available) err = SetSoundOutputInfo(device, siMonitorSource, (void *)kCDSource); // find out which source is monitored again, to check that the setting made above worked err = GetSoundOutputInfo(device, siMonitorSource, &source); } Exit: return; } The selectors are defined in Universal Headers 3.1 and later. They are: siMonitorAvailable = FOUR_CHAR_CODE('mnav'), siMonitorSource = FOUR_CHAR_CODE('mons'), [Apr 12 1998] |
|