本文整理汇总了C++中LPDIRECTSOUND8::GetCaps方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTSOUND8::GetCaps方法的具体用法?C++ LPDIRECTSOUND8::GetCaps怎么用?C++ LPDIRECTSOUND8::GetCaps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTSOUND8
的用法示例。
在下文中一共展示了LPDIRECTSOUND8::GetCaps方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
LPDIRECTSOUND8 lpsd;
//DirectSound基于COM,but you do not have to initilize COM, if you don't use effective DMOs
//HRESULT hr = DirectSoundCreate8(NULL, &lpsd, NULL);
//if (FAILED(hr)){
// cout << "DirectSound Create failed" << endl;
// return 0;
//}
hr = CoInitializeEx(NULL, 0);
if (FAILED(hRes)){
cout << "CoInitializeEx failed" << endl;
return 0;
}
hr = CoCreateInstanceEx(&CLSID_DirectSound8,
NULL,
CLSTX_INPROC_SERVER,
IID_IDirectSound8,
(LPVOID*)&lpsd);
if (FAILED(hr)){
cout << "CoCreateInstanceEx failed" << endl;
return 0;
}
hr = lpsd->Initialize(NULL);
if (FAILED(hr)){
cout << "DirectSound Device Initialize failed" << endl;
return 0;
}
//不设置这个,没有声音
hr = lpsd->SetCooperativeLevel(NULL, DSSCL_PRIORITY);
if (FAILED(hr)){
cout << "SetCooperativeLevel Failed" << endl;
return 0;
}
DSCAPS dscaps;
dscaps.dwSize = sizeof(DSCAPS);
hr = lpsd->GetCaps(&dscaps);//得到设备的相关参数,这一步一般不需要做
if (FAILED(hr)){
cout << "GetCaps failed" << endl;
return 0;
}
//创建二级缓存,这个控制声音从源到目的地, source sound can come from synthesizer,another buffer,a wav file,resource
//CreateBaseBuffer(lpsd, );
CoUninitialize();
return 0;
}
示例2: SNDDMA_InitDirect
/*
==================
SNDDMA_InitDirect
Direct-Sound support
==================
*/
sndinitstat SNDDMA_InitDirect (void)
{
DSCAPS dscaps;
HRESULT hresult;
dma.channels = CHANNELS;
dma.samplebits = SAMPLEBITS;
Com_Printf( "Initializing DirectSound 8\n");
if ( !hInstDS )
{
Com_Printf( "...loading dsound.dll: " );
hInstDS = LoadLibrary("dsound.dll");
if (hInstDS == NULL)
{
Com_Printf ("failed\n");
return SIS_FAILURE;
}
Com_Printf ("ok\n");
pDirectSoundCreate8 = GetProcAddress(hInstDS,"DirectSoundCreate8");
if (!pDirectSoundCreate8)
{
Com_Printf ("*** couldn't get DirectSound 8 process address ***\n");
return SIS_FAILURE;
}
}
Com_Printf( "...creating DirectSound 8 object: " );
while ( ( hresult = pDirectSoundCreate8( NULL, &pDS, NULL ) ) != DS_OK )
{
if (hresult != DSERR_ALLOCATED)
{
Com_Printf( "failed\n" );
return SIS_FAILURE;
}
if (MessageBox (NULL,
"The sound hardware is in use by another application.\n\n"
"Select Retry to try to start sound again or Cancel to run with no sound.",
"Sound not available",
MB_RETRYCANCEL | MB_SETFOREGROUND | MB_ICONEXCLAMATION) != IDRETRY)
{
Com_Printf ("failed, hardware already in use\n" );
return SIS_NOTAVAIL;
}
}
Com_Printf( "ok\n" );
dscaps.dwSize = sizeof(dscaps);
#ifdef QDSNDCOMPILERHACK
if ( DS_OK != pDS->lpVtbl->GetCaps( pDS, &dscaps ) )
#else
if ( DS_OK != pDS->GetCaps( &dscaps ) )
#endif
{
Com_Printf ("*** couldn't get DirectSound 8 caps ***\n");
}
if ( dscaps.dwFlags & DSCAPS_EMULDRIVER )
{
Com_Printf ("...no DirectSound 8 driver found\n" );
FreeSound();
return SIS_FAILURE;
}
if ( !DS_CreateBuffers() )
return SIS_FAILURE;
dsound_init = 1;
Com_Printf("...completed successfully\n" );
return SIS_SUCCESS;
}