How to detect the presence of a default recording device in the system?

0 votes
asked Sep 3, 2008 by rotem

How do I detect if the system has a default recording device installed? I bet this can be done through some calls to the Win32 API, anyone has any experience with this?

I'm talking about doing this through code, not by opening the control panel and taking a look under sound options.

3 Answers

0 votes
answered Sep 3, 2008 by espo

There is an Open Source Audio API called PortAudio that has a method you could use. I think the method is called Pa_GetDeviceInfo() or something.

0 votes
answered Sep 3, 2008 by jeff-hillman

Using the DirectX SDK, you can call DirectSoundCaptureEnumerate, which will call your DSEnumCallback function for each DirectSoundCapture device on the system. The first parameter passed to your DSEnumCallback is an LPGUID, which is the "Address of the GUID that identifies the device being enumerated, or NULL for the primary device".

If all you need to do is find out if a recording device is present (I don't think this is good enough if you really need to know the default device), you can use waveInGetNumDevs:

#include <tchar.h>
#include <windows.h>
#include "mmsystem.h"

int _tmain( int argc, wchar_t *argv[] )
{
    UINT deviceCount = waveInGetNumDevs();

    if ( deviceCount > 0 )
    {
        for ( int i = 0; i < deviceCount; i++ )
        {
            WAVEINCAPSW waveInCaps;

            waveInGetDevCapsW( i, &waveInCaps, sizeof( WAVEINCAPS ) );

            // do some stuff with waveInCaps...
        }
    }

    return 0;
}
0 votes
answered Sep 6, 2008 by lars-truijens

The win32 api has a function called waveInGetNumDevs for it.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...