Ho scritto il seguente codice passo dopo passo da msdn di microsoft
// c++ dx dsound.cpp : definisce il punto di ingresso dell'applicazione console.
//
#include "stdafx.h"
#include <dsound.h>
#pragma comment(lib, "dsound.lib")
#pragma comment(lib, "dxguid.lib")
LPDIRECTSOUNDCAPTUREBUFFER8* ppDSCB8;
LPDIRECTSOUNDCAPTURE8 pDSC;
HRESULT CreateCaptureBuffer(LPDIRECTSOUNDCAPTURE8 pDSC, LPDIRECTSOUNDCAPTUREBUFFER8* ppDSCB8);
void dsError(HRESULT hr);
int _tmain(int argc, _TCHAR* argv[])
{
LPDIRECTSOUNDCAPTURE8 lpds;
HRESULT hr = DirectSoundCaptureCreate8(NULL, &lpds, NULL);
printf("%d \n", hr);
dsError(hr);
system("PAUSE");
hr = CoInitializeEx(NULL, 0);
printf("%d \n", hr);
dsError(hr);
system("PAUSE");
hr = CoCreateInstance(CLSID_DirectSoundCapture8, NULL, CLSCTX_INPROC_SERVER, IID_IDirectSoundCapture8, (LPVOID*) &lpds);
printf("%d \n", hr);
dsError(hr);
system("PAUSE");
hr = lpds->Initialize(NULL);
printf("%d \n", hr);
dsError(hr);
system("PAUSE");
hr = CreateCaptureBuffer(pDSC, ppDSCB8);
printf("%d \n", hr);
dsError(hr);
system("PAUSE");
return 0;
}
HRESULT CreateCaptureBuffer(LPDIRECTSOUNDCAPTURE8 pDSC, LPDIRECTSOUNDCAPTUREBUFFER8* ppDSCB8)
{
HRESULT hr;
DSCBUFFERDESC dscbd;
LPDIRECTSOUNDCAPTUREBUFFER pDSCB;
WAVEFORMATEX wfx =
{WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0};
// wFormatTag, nChannels, nSamplesPerSec, mAvgBytesPerSec,
// nBlockAlign, wBitsPerSample, cbSize
if ((NULL == pDSC) || (NULL == ppDSCB8)) return E_INVALIDARG;
dscbd.dwSize = sizeof(DSCBUFFERDESC);
dscbd.dwFlags = 0;
dscbd.dwBufferBytes = wfx.nAvgBytesPerSec;
dscbd.dwReserved = 0;
dscbd.lpwfxFormat = &wfx;
dscbd.dwFXCount = 0;
dscbd.lpDSCFXDesc = NULL;
if (SUCCEEDED(hr = pDSC->CreateCaptureBuffer(&dscbd, &pDSCB, NULL)))
{
printf("QueryInterface\n");
hr = pDSCB->QueryInterface(IID_IDirectSoundCaptureBuffer8, (LPVOID*)ppDSCB8);
pDSCB->Release();
}
return hr;
}
void dsError(HRESULT hr) {
}
Mi restituisce l'errore numero -2147024809 che equivale a
An invalid paramer was passed to the returning the function.
all'istruzione hr = pDSC->CreateCaptureBuffer(&dscbd, &pDSCB, NULL).
Praticamente sono punto e a capo con lo stesso errore!!!!!
Qualcuno mi sa aiutare!!!!
Grazie per la collaborazione.
Marcello