Bonjour je cherche à lister les infos des périphériques audio connectés à un PC, j'en suis à l'étape de test pour connaitre le nombre de sorties et d'entrées disponibles pour un périphérique.
J'ai donc fait une petite fonction :
int AudioDrivers::TestAudioDriver(LPAUDIODRIVERSLIST audiodrv,unsigned int channels,double SampleRate,int Resolution){
if(audiodrv)
if(audiodrv->type==AUDIO_TYPE_WDM){
WAVEFORMATEXTENSIBLE wfxs;
wfxs.Format.wFormatTag=WAVE_FORMAT_EXTENSIBLE;
wfxs.Format.nChannels=0;
unsigned int channelmask=channels;
while( channelmask != 0 ){ wfxs.Format.nChannels += ( channelmask & 1L );
channelmask >>= 1;
}
wfxs.Format.nSamplesPerSec=(DWORD)SampleRate;
wfxs.Format.wBitsPerSample=8*(1+(int)(Resolution/8));
wfxs.Format.nBlockAlign=wfxs.Format.wBitsPerSample*wfxs.Format.nChannels/8;
wfxs.Format.nAvgBytesPerSec=wfxs.Format.nBlockAlign*wfxs.Format.wBitsPerSample;
wfxs.Format.cbSize=sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
wfxs.Samples.wValidBitsPerSample=Resolution;
wfxs.Samples.wSamplesPerBlock=512;
wfxs.Samples.wReserved=0;
wfxs.dwChannelMask=channels;
wfxs.SubFormat=KSDATAFORMAT_SUBTYPE_PCM;
MMRESULT open;
if((open=waveOutOpen(NULL,audiodrv->drvID,(LPCWAVEFORMATEX)&wfxs,0,0,CALLBACK_NULL|WAVE_FORMAT_QUERY))==MMSYSERR_NOERROR)return 1;
else if(open==MMSYSERR_ALLOCATED)strcpy(audiodrv->errorMessage, "Specified resource is already allocated.");
else if(open==MMSYSERR_BADDEVICEID)strcpy(audiodrv->errorMessage, "Specified device identifier is out of range.");
else if(open==MMSYSERR_NODRIVER)strcpy(audiodrv->errorMessage, "No device driver is present.");
else if(open==MMSYSERR_NOMEM)strcpy(audiodrv->errorMessage, "Unable to allocate or lock memory.");
else if(open==WAVERR_BADFORMAT)strcpy(audiodrv->errorMessage, "Attempted to open with an unsupported waveform-audio format.");
else if(open==WAVERR_SYNC)strcpy(audiodrv->errorMessage, "The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag.");
}
}
return 0;
}
que j'appelle de la façon suivante (ici test pour du 7.1 par exemple):
if(TestAudioDriver(audiodrv,SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT,44100.,16))audiodrv->OutputChannels=8;
Le soucis est que sur une carte audio qui dispose de 2 sorties, cet exemple donne quand même un résultat positif. Je voudrais savoir comment obtenir plus concrètement les infos d'une carte son, puis l'utiliser en se servant le moins possibles des fioritures de windows.
Merci d'avance
