Hi, listers:
There is a USB audio
device be pluged in Mac Mini(Mac OSX), and The system recognised this device
with "Input/Output Name: Generic USB Audio Device". I want to control this
device's volume, I wrote like this(In X-code, use Carbon):
//---------------------------------------------------------------------
// Get & Set AudioDevice Output
Volume ComponentDescription cdOutput = { kSoundOutputDeviceType, 0, 0,
0, 0 }; Component cOutput = 0;
cOutput = FindNextComponent(cOutput,
&cdOutput);
Handle myName = NewHandleClear(128);
GetComponentInfo(cOutput, &cdOutput, myName, nil,
nil); // myName = "\0x16Generic USB Audio Device"
long lOutputVolume = 0; ComponentResult
cResult; ComponentInstance ciOutput = OpenComponent( cOutput
);
cResult = SoundComponentSetInfo( ciOutput, NULL,
siHardwareVolume, 0x150015);// The Audio Device Output Volume was
set to 0x150015 successfully CloseComponent( ciOutput
);
// Get AudioDevice Input
Volume ComponentDescription cdInput = { kSoundInputDeviceType, 0, 0, 0,
0 }; Component cInput = 0; cInput = FindNextComponent(cInput,
&cdInput); GetComponentInfo(cInput, &cdInput, myName, nil,
nil); // myName = "\DVUSB Audio Device"
long lInputVolume = 0; ComponentInstance ciInput =
OpenComponent( cInput ); cResult = SoundComponentGetInfo(ciInput, NULL,
siHardwareVolume, &lInputVolume);// Get Volume Error, Return By "cResult =
-50" CloseComponent( ciInput );
//---------------------------------------------------
I don't know why I can't get the Input volume. Can you help me ? Any idea
will be great help. Thanks a lot!
|