当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTSOUND::SetCooperativeLevel方法代码示例

本文整理汇总了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;
}
开发者ID:doveiya,项目名称:isilme,代码行数:36,代码来源:DirectSound.cpp

示例2: DoFormInitialize

// ==============================  INITIALIZE FORM =======================================
void TsounEditForm::DoFormInitialize()
{
	TTagEditForm::DoFormInitialize();

#if OPT_WINOS
	if( lpDirectSound )
		lpDirectSound->SetCooperativeLevel( GetWindow()->GetHWND(), DSSCL_NORMAL );
#endif
}
开发者ID:ElusiveMind,项目名称:ballistic,代码行数:10,代码来源:soun.cpp

示例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;
}
开发者ID:libninjam,项目名称:libninjam-win,代码行数:57,代码来源:audiostream_win32.cpp

示例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);
}
开发者ID:josejl1987,项目名称:neko-tracer,代码行数:19,代码来源:soundmng.cpp

示例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();
	}
}
开发者ID:janisl,项目名称:jlquake,代码行数:10,代码来源:driver_directsound.cpp

示例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 ();
	}
}
开发者ID:deathsythe47,项目名称:jaMME,代码行数:17,代码来源:win_snd.cpp

示例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;
}
开发者ID:ssaue,项目名称:soundspace,代码行数:54,代码来源:sspDirectSoundDevice.cpp

示例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
开发者ID:giantchen2012,项目名称:tricks-of-the-3d-game-programming-gurus,代码行数:52,代码来源:t3dlib3.cpp

示例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
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:50,代码来源:demo10_3.cpp

示例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;
}
开发者ID:ButchDean,项目名称:AntiVirusGame2,代码行数:50,代码来源:DirectSoundSource.cpp

示例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;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:18,代码来源:dsutil.cpp

示例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 ();
	}
}
开发者ID:ctoliver,项目名称:JediKnight2,代码行数:23,代码来源:win_snd.cpp

示例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( );
}
开发者ID:deathsythe47,项目名称:jaMME,代码行数:52,代码来源:win_snd.cpp

示例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);
}
开发者ID:mreiferson,项目名称:hajiworld,代码行数:46,代码来源:hwdsound.cpp

示例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;
}
开发者ID:MaddTheSane,项目名称:lc3tonegenerator,代码行数:45,代码来源:SoundHandler.cpp


注:本文中的LPDIRECTSOUND::SetCooperativeLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。