Domanda

I am trying to capture audio from the mic using the windows core audio APIs

The relevant lines of code are

const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);  
const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
IMMDeviceEnumerator *pEnumerator = NULL;  
hr = CoCreateInstance(CLSID_MMDeviceEnumerator,NULL,CLSCTX_ALL,IID_IMMDeviceEnumerator,   (void**)&pEnumerator);

hr returns the following value-

0x800401f0 : CoInitialize has not been called.

I have adapted the sample program from the msdn page - Capturing an audio stream

What could be wrong? Also I don't understand what the error means - from the descriptions I got from Google search and all.

I am using Visual studio 2012 express on Win7 Home Pro x64.

È stato utile?

Soluzione

Isn't the error message clear enough? You need to call CoInitialize before calling CoCreateInstance (or using COM in any other way).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top