// Having an IltmmCapture Interface, pCap:
IltmmAudioFormats *pAudioFormats;
IltmmAudioFormat *pAudioFormat;
long lCount;
long lFreq, lBits, lChannels;
long lFoundAt;
long lSelection;
VARIANT_BOOL bSelected;
// get the audio formats collection:
IltmmCapture__get_AudioCaptureFormats(pCap, &pAudioFormats);
IltmmAudioFormats__get_Count(pAudioFormats, &lCount);
for( i=0; i<lCount; i++ )
{
// get the item at index I
IltmmAudioFormats_Item(pAudioFormats, i, &pAudioFormat);
// do something with this item, like viewing its information:
IltmmAudioFormat__get_SampleFrequency(pAudioFormat,
&lFreq);
IltmmAudioFormat__get_BitsPerSample(pAudioFormat, &lBits);
IltmmAudioFormat__get_Channels(pAudioFormat, &lChannels);
IltmmAudioFormat__get_Selected(pAudioFormat, &bSelected);
// view information …
// you may select the format if it matches some criteria:
if( lFreq == 8000 && lBits == 8 && lChannels
== 1 )
IltmmAudioFormat__put_Selected(pAudioFormat,
VARIANT_TRUE);
// free the item
IUnknown_Release(pAudioFormat);
}
// you might use the Find method to search for a specific format:
IltmmAudioFormats__Find(pAudioFormats, 16000, 16, 2, &lFoundAt);
If( lFoundAt != -1 )
{
// do something with it:
// check if it is already selected, and if not, select it:
IltmmAudioFormats__get_Selection(pAudioFormats, &lSelection);
If( lSelection != lFoundAt )
{
IltmmAudioFormats__put_Selection(pAudioFormats,
lFoundAt);
}
}
// free the audio formats collection
IUnknown_Release(pAudioFormats);