本文整理汇总了C++中LPDIRECTSOUND::SetCooperativeLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTSOUND::SetCooperativeLevel方法的具体用法?C++ LPDIRECTSOUND::SetCooperativeLevel怎么用?C++ LPDIRECTSOUND::SetCooperativeLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTSOUND
的用法示例。
在下文中一共展示了LPDIRECTSOUND::SetCooperativeLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ds_Create
//-----------------------------------------------------------------------------
// Создание Direct Sound объекта
// на входе : window - идентификатор окна
// clsid_direct - идентификатор Direct Sound
// device - идентификатор устройства воспроизведения
// level - уровень кооперации
// на выходе : указатель на созданный Direct Sound объект, если значение
// равно 0 значит создание не состоялось
//-----------------------------------------------------------------------------
LPDIRECTSOUND ds_Create(HWND window, REFCLSID clsid_direct, LPGUID device,
int level)
{
// установка переменных
LPDIRECTSOUND direct = 0;
// Инициализация COM
CoInitialize(NULL);
// Создание Direct Sound обьекта
if (CoCreateInstance(clsid_direct,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDirectSound,
(void * *) &direct) != DS_OK)
return false;
// инициализация устройства воспроизведения
if (direct->Initialize(device) != DS_OK)
return false;
// установка приоритетного режима
if (direct->SetCooperativeLevel(window, level) != DS_OK)
return false;
return direct;
}
示例2: DoFormInitialize
// ============================== INITIALIZE FORM =======================================
void TsounEditForm::DoFormInitialize()
{
TTagEditForm::DoFormInitialize();
#if OPT_WINOS
if( lpDirectSound )
lpDirectSound->SetCooperativeLevel( GetWindow()->GetHWND(), DSSCL_NORMAL );
#endif
}
示例3: Open
int audioStreamer_ds::Open(int iswrite, int srate, int nch, int bps, int sleep, int nbufs, int bufsize, GUID *device)
{
// todo: use device
m_sleep = sleep >= 0 ? sleep : 0;
GUID zero={0,};
if (!memcmp(device,&zero,sizeof(zero))) device=NULL;
m_nch = nch;
m_srate=srate;
m_bps=bps;
int fmt_align=(bps>>3)*nch;
int fmt_mul=fmt_align*srate;
WAVEFORMATEX wfx={
WAVE_FORMAT_PCM,
nch,
srate,
fmt_mul,
fmt_align,
bps,
0
};
m_totalbufsize=nbufs*bufsize;
if (iswrite)
{
DirectSoundCreate(device,&m_lpds,NULL);
if (m_lpds)
{
HWND hWnd = GetForegroundWindow();
if (hWnd == NULL) hWnd = GetDesktopWindow();
m_lpds->SetCooperativeLevel(hWnd,DSSCL_PRIORITY);
// create a secondary buffer for now
DSBUFFERDESC ds={sizeof(ds),DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_GLOBALFOCUS,m_totalbufsize,0,&wfx, };
m_lpds->CreateSoundBuffer(&ds,&m_outbuf,NULL);
}
}
else
{
DirectSoundCaptureCreate(device,&m_lpcap,NULL);
if (m_lpcap)
{
DSCBUFFERDESC ds={sizeof(ds),0,m_totalbufsize,0,&wfx, };
m_lpcap->CreateCaptureBuffer(&ds,&m_inbuf,NULL);
}
}
m_bufsize=bufsize;
return 0;
}
示例4: dsoundcreate
static BRESULT dsoundcreate(HWND hWnd)
{
// DirectSoundの初期化
if (FAILED(DirectSoundCreate(0, &pDSound, 0))) {
goto dscre_err;
}
if (FAILED(pDSound->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)))
{
if (FAILED(pDSound->SetCooperativeLevel(hWnd, DSSCL_NORMAL)))
{
goto dscre_err;
}
}
return(SUCCESS);
dscre_err:
RELEASE(pDSound);
return(FAILURE);
}
示例5: SNDDMA_Activate
void SNDDMA_Activate() {
if ( !pDS ) {
return;
}
if ( DS_OK != pDS->SetCooperativeLevel( GMainWindow, DSSCL_PRIORITY ) ) {
common->Printf( "sound SetCooperativeLevel failed\n" );
SNDDMA_Shutdown();
}
}
示例6: SNDDMA_Activate
/*
=================
SNDDMA_Activate
When we change windows we need to do this
=================
*/
void SNDDMA_Activate( void ) {
if ( !pDS ) {
return;
}
if ( DS_OK != pDS->SetCooperativeLevel( g_wv.hWnd, DSSCL_PRIORITY ) ) {
Com_Printf ("sound SetCooperativeLevel failed\n");
SNDDMA_Shutdown ();
}
}
示例7: initializeImpl
// initialize
bool sspDSDeviceGroup::initializeImpl(LPVOID hWnd)
{
if (m_pDS.size() > 0) return TRUE; // Already initialized
if (hWnd == NULL)
{
// Error, invalid hwnd
DOUT (_T("ERROR: Invalid parameters, unable to initialize services\n\r"));
return FALSE;
}
m_hApp = (HWND) hWnd;
setBufferFormat(2);
m_pDS.reserve(m_nDevices.size());
m_pDSBuf.reserve(m_nDevices.size());
for (unsigned int i=0; i<m_nDevices.size(); i++) {
// Create DirectSound object
LPDIRECTSOUND ds;
HRESULT nResult = DirectSoundCreate(m_dsInfo[m_nDevices[i]]->lpGuid, &ds, NULL);
if (nResult == DS_OK) {
nResult = ds->SetCooperativeLevel(m_hApp, DSSCL_PRIORITY);
if (nResult == DS_OK) {
LPDIRECTSOUNDBUFFER dsbuf;
nResult = ds->CreateSoundBuffer(&m_dsBufDesc, &dsbuf, NULL);
if (nResult == DS_OK) {
nResult = dsbuf->SetFormat(&m_pcmWf);
if (nResult == DS_OK) {
DOUT (_T("SUCCESS: DirectSound created and formatted\n\r"));
}
else {
DOUT(_T("ERROR: Unable to set DirectSound format\n\r"));
return FALSE;
}
m_pDSBuf.push_back(dsbuf);
}
else {
DOUT(_T("ERROR: Unable to create DirectSound buffer\n\r"));
return FALSE;
}
}
else {
DOUT(_T("ERROR: Unable to set DirectSound cooperative level\n\r"));
return FALSE;
}
m_pDS.push_back(ds);
}
else {
// Error
DOUT(_T("ERROR: Unable to create DirectSound object\n\r"));
return FALSE;
}
}
return TRUE;
}
示例8: DSound_Init
int DSound_Init(void)
{
// this function initializes the sound system
static int first_time = 1; // used to track the first time the function
// is entered
// test for very first time
if (first_time)
{
// clear everything out
memset(sound_fx,0,sizeof(pcm_sound)*MAX_SOUNDS);
// reset first time
first_time = 0;
// create a directsound object
if (FAILED(DirectSoundCreate(NULL, &lpds, NULL)))
return(0);
// set cooperation level
if (FAILED(lpds->SetCooperativeLevel((HWND)main_window_handle,DSSCL_NORMAL)))
return(0);
} // end if
// initialize the sound fx array
for (int index=0; index<MAX_SOUNDS; index++)
{
// test if this sound has been loaded
if (sound_fx[index].dsbuffer)
{
// stop the sound
sound_fx[index].dsbuffer->Stop();
// release the buffer
sound_fx[index].dsbuffer->Release();
} // end if
// clear the record out
memset(&sound_fx[index],0,sizeof(pcm_sound));
// now set up the fields
sound_fx[index].state = SOUND_NULL;
sound_fx[index].id = index;
} // end for index
// return sucess
return(1);
} // end DSound_Init
示例9: Game_Init
int Game_Init(void *parms)
{
// this function is where you do all the initialization
// for your game
// create a directsound object
if (DirectSoundCreate(NULL, &lpds, NULL)!=DS_OK )
return(0);
// set cooperation level
if (lpds->SetCooperativeLevel(main_window_handle,DSSCL_NORMAL)!=DS_OK)
return(0);
// clear array out
memset(sound_fx,0,sizeof(pcm_sound)*MAX_SOUNDS);
// initialize the sound fx array
for (int index=0; index<MAX_SOUNDS; index++)
{
// test if this sound has been loaded
if (sound_fx[index].dsbuffer)
{
// stop the sound
sound_fx[index].dsbuffer->Stop();
// release the buffer
sound_fx[index].dsbuffer->Release();
} // end if
// clear the record out
memset(&sound_fx[index],0,sizeof(pcm_sound));
// now set up the fields
sound_fx[index].state = SOUND_NULL;
sound_fx[index].id = index;
} // end for index
// load a wav file in
if ((sound_id = DSound_Load_WAV("FLIGHT.WAV"))!=-1)
{
// start the voc playing in looping mode
sound_fx[sound_id].dsbuffer->Play(0,0,DSBPLAY_LOOPING);
} // end if
// return success
return(1);
} // end Game_Init
示例10: DirectSoundInitialisation
bool DirectSoundInitialisation()
{
const char DirectSoundInitialisationError[] = "Direct Sound Initialisation Error...";
HRESULT dsscl; // SetCooperativeLevel error description.
if(DirectSoundCreate(NULL, &lpDS, NULL) != DS_OK)
{
MessageBox(ghwnd, "DirectSound Initialisation failed!", DirectSoundInitialisationError, MB_OK | MB_ICONEXCLAMATION);
return false;
}
if((dsscl = lpDS->SetCooperativeLevel(ghwnd, DSSCL_NORMAL)) != DS_OK)
{
switch(dsscl)
{
case DSERR_ALLOCATED:
{
MessageBox(ghwnd, "DirectSound cooperative level setting failed... Resources tied up.", DirectSoundInitialisationError, MB_OK | MB_ICONEXCLAMATION);
break;
}
case DSERR_INVALIDPARAM:
{
MessageBox(ghwnd, "DirectSound cooperative level setting failed... Invalid parameter passed.", DirectSoundInitialisationError, MB_OK | MB_ICONEXCLAMATION);
break;
}
case DSERR_UNINITIALIZED:
{
MessageBox(ghwnd, "DirectSound cooperative level setting failed... IDirectSound::Initialize not called.", DirectSoundInitialisationError, MB_OK | MB_ICONEXCLAMATION);
break;
}
case DSERR_UNSUPPORTED:
{
MessageBox(ghwnd, "DirectSound cooperative level setting failed... Function not supported.", DirectSoundInitialisationError, MB_OK | MB_ICONEXCLAMATION);
break;
}
default:
break;
}
return false;
}
if(!load_sounds())
{
MessageBox(ghwnd, "Sound file loading for DirectSound failed!", DirectSoundInitialisationError, MB_OK | MB_ICONEXCLAMATION);
return false;
}
return true;
}
示例11: DSUtil_InitDirectSound
//-----------------------------------------------------------------------------
// Name: DSUtil_InitDirectSound()
// Desc:
//-----------------------------------------------------------------------------
HRESULT DSUtil_InitDirectSound( HWND hWnd )
{
if( FAILED( DirectSoundCreate( NULL, &g_pDS, NULL ) ) )
return E_FAIL;
if( FAILED( g_pDS->SetCooperativeLevel( hWnd, DSSCL_NORMAL ) ) )
{
g_pDS->Release();
g_pDS = NULL;
return E_FAIL;
}
return S_OK;
}
示例12: SNDDMA_Activate
/*
=================
SNDDMA_Activate
When we change windows we need to do this
=================
*/
void SNDDMA_Activate( qboolean bAppActive )
{
if (s_UseOpenAL)
{
S_AL_MuteAllSounds(!bAppActive);
}
if ( !pDS ) {
return;
}
if ( DS_OK != pDS->SetCooperativeLevel( g_wv.hWnd, DSSCL_PRIORITY ) ) {
Com_Printf ("sound SetCooperativeLevel failed\n");
SNDDMA_Shutdown ();
}
}
示例13: SNDDMA_Shutdown
/*
==================
SNDDMA_Shutdown
==================
*/
void SNDDMA_Shutdown( void ) {
Com_DPrintf( "Shutting down sound system\n" );
if ( pDS ) {
Com_DPrintf( "Destroying DS buffers\n" );
if ( pDS )
{
Com_DPrintf( "...setting NORMAL coop level\n" );
// FIXME JA was DSSCL_NORMAL and Q3 says DSSCL_PRIORITY but the printf says setting normal
pDS->SetCooperativeLevel( g_wv.hWnd, DSSCL_PRIORITY );
}
if ( pDSBuf )
{
Com_DPrintf( "...stopping and releasing sound buffer\n" );
pDSBuf->Stop( );
pDSBuf->Release( );
}
// only release primary buffer if it's not also the mixing buffer we just released
if ( pDSPBuf && ( pDSBuf != pDSPBuf ) )
{
Com_DPrintf( "...releasing primary buffer\n" );
pDSPBuf->Release( );
}
pDSBuf = NULL;
pDSPBuf = NULL;
dma.buffer = NULL;
Com_DPrintf( "...releasing DS object\n" );
pDS->Release( );
}
if ( hInstDS ) {
Com_DPrintf( "...freeing DSOUND.DLL\n" );
FreeLibrary( hInstDS );
hInstDS = NULL;
}
pDS = NULL;
pDSBuf = NULL;
pDSPBuf = NULL;
dsound_init = qfalse;
memset ((void *)&dma, 0, sizeof (dma));
CoUninitialize( );
}
示例14: DSInit
int DSInit(HWND hwnd)
{
static int first_time = 1; // used to track the first time the function is entered
int index;
// test for very first time
if (first_time) {
// clear everything out
memset(sound_fx, 0, sizeof(PCMSOUND) * MAX_SOUNDS);
// reset first time
first_time = 0;
// create a directsound object
if (DirectSoundCreate(NULL, &lpDS, NULL) != DS_OK) {
return(0);
}
// set cooperation level
if (lpDS->SetCooperativeLevel(hwnd, DSSCL_NORMAL) != DS_OK) {
return(0);
}
}
// initialize the sound fx array
for (index = 0; index < MAX_SOUNDS; index++) {
// test if this sound has been loaded
if (sound_fx[index].dsbuffer) {
// stop the sound
sound_fx[index].dsbuffer->Stop();
// release the buffer
sound_fx[index].dsbuffer->Release();
}
// clear the record out
memset(&sound_fx[index], 0, sizeof(PCMSOUND));
// now set up the fields
sound_fx[index].dsbuffer = NULL;
sound_fx[index].state = SOUND_NULL;
sound_fx[index].id = index;
}
// return sucess
return(1);
}
示例15: memset
BOOL LC3Sound::AppCreateWritePrimaryBuffer(
LPDIRECTSOUND lpDirectSound,
LPDIRECTSOUNDBUFFER *lplpDsb,
HWND hwnd)
{
DSBUFFERDESC dsbdesc;
HRESULT hr;
WAVEFORMATEX pcmwf;
// Set up wave format structure.
memset(&pcmwf, 0, sizeof(WAVEFORMATEX));
pcmwf.wFormatTag = WAVE_FORMAT_PCM;
pcmwf.nChannels = 1;
pcmwf.nSamplesPerSec = 22050;
pcmwf.wBitsPerSample = 8;
pcmwf.nBlockAlign = pcmwf.nChannels * (pcmwf.wBitsPerSample/8);
pcmwf.nAvgBytesPerSec = pcmwf.nSamplesPerSec * pcmwf.nBlockAlign;
// Set up DSBUFFERDESC structure.
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); // Zero it out.
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER; //; //DSBCAPS_GLOBALFOCUS; //;
dsbdesc.dwBufferBytes = 0; // Buffer size is determined
// by sound hardware.
dsbdesc.lpwfxFormat = NULL; // Must be NULL for primary buffers.
// Obtain write-primary cooperative level.
hr = lpDirectSound->SetCooperativeLevel(hwnd, DSSCL_PRIORITY);
if(DS_OK == hr)
{
// Succeeded! Try to create buffer.
hr = lpDirectSound->CreateSoundBuffer(
&dsbdesc, lplpDsb, NULL);
if(DS_OK == hr) {
// Succeeded! Set primary buffer to desired format.
hr = (*lplpDsb)->SetFormat(&pcmwf);
(*lplpDsb)->Play(0, 0, DSBPLAY_LOOPING);
return TRUE;
}
}
// If we got here, then we failed SetCooperativeLevel.
// CreateSoundBuffer, or SetFormat.
*lplpDsb = NULL;
return FALSE;
}