本文整理汇总了C++中IDirectSound_SetCooperativeLevel函数的典型用法代码示例。如果您正苦于以下问题:C++ IDirectSound_SetCooperativeLevel函数的具体用法?C++ IDirectSound_SetCooperativeLevel怎么用?C++ IDirectSound_SetCooperativeLevel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IDirectSound_SetCooperativeLevel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DSoundOpenPlayback
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
{
DSoundData *pData = NULL;
LPGUID guid = NULL;
HRESULT hr;
if(!DSoundLoad())
return ALC_FALSE;
if(!deviceName)
deviceName = dsDevice;
else if(strcmp(deviceName, dsDevice) != 0)
{
ALuint i;
if(!DeviceList)
{
hr = pDirectSoundEnumerateA(DSoundEnumDevices, NULL);
if(FAILED(hr))
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
}
for(i = 0; i < NumDevices; i++)
{
if(strcmp(deviceName, DeviceList[i].name) == 0)
{
if(i > 0)
guid = &DeviceList[i].guid;
break;
}
}
if(i == NumDevices)
return ALC_FALSE;
}
//Initialise requested device
pData = calloc(1, sizeof(DSoundData));
if(!pData)
{
alcSetError(device, ALC_OUT_OF_MEMORY);
return ALC_FALSE;
}
//DirectSound Init code
hr = pDirectSoundCreate(guid, &pData->lpDS, NULL);
if(SUCCEEDED(hr))
hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY);
if(FAILED(hr))
{
if(pData->lpDS)
IDirectSound_Release(pData->lpDS);
free(pData);
AL_PRINT("Device init failed: 0x%08lx\n", hr);
return ALC_FALSE;
}
device->szDeviceName = strdup(deviceName);
device->ExtraData = pData;
return ALC_TRUE;
}
示例2: gst_directsound_sink_open
static gboolean
gst_directsound_sink_open (GstAudioSink * asink)
{
GstDirectSoundSink *dsoundsink;
HRESULT hRes;
dsoundsink = GST_DIRECTSOUND_SINK (asink);
/* create and initialize a DirecSound object */
if (FAILED (hRes = DirectSoundCreate (NULL, &dsoundsink->pDS, NULL))) {
GST_ELEMENT_ERROR (dsoundsink, RESOURCE, OPEN_READ,
("gst_directsound_sink_open: DirectSoundCreate: %s",
DXGetErrorString9 (hRes)), (NULL));
return FALSE;
}
if (FAILED (hRes = IDirectSound_SetCooperativeLevel (dsoundsink->pDS,
GetDesktopWindow (), DSSCL_PRIORITY))) {
GST_ELEMENT_ERROR (dsoundsink, RESOURCE, OPEN_READ,
("gst_directsound_sink_open: IDirectSound_SetCooperativeLevel: %s",
DXGetErrorString9 (hRes)), (NULL));
return FALSE;
}
return TRUE;
}
示例3: FreeSound
static void
FreeSound (void)
{
if (pDSBuf) {
IDirectSoundBuffer_Stop (pDSBuf);
IDirectSound_Release (pDSBuf);
}
// release primary buffer only if it's not also the mixing buffer we just released
if (pDSPBuf && (pDSBuf != pDSPBuf)) {
IDirectSound_Release (pDSPBuf);
}
if (pDS) {
IDirectSound_SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
IDirectSound_Release (pDS);
}
pDS = NULL;
pDSBuf = NULL;
pDSPBuf = NULL;
hWaveOut = 0;
hData = 0;
hWaveHdr = 0;
lpData = NULL;
lpWaveHdr = NULL;
}
示例4: m1sdr_PlayStart
void m1sdr_PlayStart(void)
{
waveLogStart();
IDirectSound_SetCooperativeLevel(lpDS, GetForegroundWindow(), DSSCL_PRIORITY);
IDirectSoundBuffer_SetCurrentPosition(lpSecB, 0);
IDirectSoundBuffer_Play(lpSecB, 0, 0, DSBPLAY_LOOPING);
}
示例5: DSoundOpenPlayback
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
{
DSoundData *pData = NULL;
LPGUID guid = NULL;
HRESULT hr;
if(!deviceName)
deviceName = dsDevice;
else if(strcmp(deviceName, dsDevice) != 0)
{
ALuint i;
for(i = 0;i < NumDevices;i++)
{
if(strcmp(deviceName, DeviceList[i].name) == 0)
{
guid = &DeviceList[i].guid;
break;
}
}
if(i == NumDevices)
return ALC_FALSE;
}
DSoundLoad();
if(ds_handle == NULL)
return ALC_FALSE;
//Initialise requested device
pData = calloc(1, sizeof(DSoundData));
if(!pData)
{
alcSetError(ALC_OUT_OF_MEMORY);
DSoundUnload();
return ALC_FALSE;
}
//DirectSound Init code
hr = pDirectSoundCreate(guid, &pData->lpDS, NULL);
if(SUCCEEDED(hr))
hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY);
if(FAILED(hr))
{
if(pData->lpDS)
IDirectSound_Release(pData->lpDS);
free(pData);
DSoundUnload();
return ALC_FALSE;
}
device->szDeviceName = strdup(deviceName);
device->ExtraData = pData;
return ALC_TRUE;
}
示例6: FreeSound
/*
FreeSound
*/
void
FreeSound (void)
{
int i;
if (pDSBuf) {
IDirectSoundBuffer_Stop (pDSBuf);
IDirectSound_Release (pDSBuf);
}
// only release primary buffer if it's not also the mixing buffer we just released
if (pDSPBuf && (pDSBuf != pDSPBuf)) {
IDirectSound_Release (pDSPBuf);
}
if (pDS) {
IDirectSound_SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
IDirectSound_Release (pDS);
}
if (hWaveOut) {
waveOutReset (hWaveOut);
if (lpWaveHdr) {
for (i = 0; i < WAV_BUFFERS; i++)
waveOutUnprepareHeader (hWaveOut, lpWaveHdr + i,
sizeof (WAVEHDR));
}
waveOutClose (hWaveOut);
if (hWaveHdr) {
GlobalUnlock (hWaveHdr);
GlobalFree (hWaveHdr);
}
if (hData) {
GlobalUnlock (hData);
GlobalFree (hData);
}
}
pDS = NULL;
pDSBuf = NULL;
pDSPBuf = NULL;
hWaveOut = 0;
hData = 0;
hWaveHdr = 0;
lpData = NULL;
lpWaveHdr = NULL;
dsound_init = false;
wav_init = false;
}
示例7: SSInit
BOOL SSInit(HWND hWnd, int channels, unsigned flags)
{
LPDIRECTSOUNDBUFFER lpPrimaryBuffer;
LPDIRECTSOUND lpDS;
DSBUFFERDESC dsbd;
if (SSMixer.lpds) return TRUE;
// Perform Direct Sound Initialization
if (DirectSoundCreate(NULL, &lpDS, NULL) != DS_OK)
return FALSE;
SSMixer.lpds = lpDS;
if (IDirectSound_SetCooperativeLevel(lpDS, hWnd, DSSCL_NORMAL) != DS_OK) {
SSDestroy();
return FALSE;
}
// Start Mixer
memset(&dsbd, 0, sizeof(DSBUFFERDESC));
dsbd.dwSize = sizeof(DSBUFFERDESC);
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
if (IDirectSound_CreateSoundBuffer(SSMixer.lpds, &dsbd, &lpPrimaryBuffer, NULL) == DS_OK) {
if (IDirectSoundBuffer_Play(lpPrimaryBuffer, 0, 0, DSBPLAY_LOOPING) != DS_OK) {
IDirectSoundBuffer_Release(lpPrimaryBuffer);
SSDestroy();
return FALSE;
}
IDirectSoundBuffer_Release(lpPrimaryBuffer);
}
else {
SSDestroy();
return FALSE;
}
// Finish initializing SSMixer.
SSMixer.ch_cur = 0;
SSMixer.ch_list = (SSoundBuffer *)malloc(sizeof(SSoundBuffer)*channels);
if (!SSMixer.ch_list) return FALSE;
memset(SSMixer.ch_list, 0, sizeof(SSoundBuffer)*channels);
SSMixer.ch_num = channels;
// Determine Sound technology and volume caps
waveOutGetVolume((HWAVEOUT)WAVE_MAPPER, (LPDWORD)&SSMixer.old_master_vol);
// waveOutSetVolume((HWAVEOUT)WAVE_MAPPER, 0x40004000);
return TRUE;
}
示例8: pest_open
int pest_open( HWND win ){
HMODULE lib;
DIRECTSOUNDCREATE dsound_create;
WAVEFORMATEX format;
DSBUFFERDESC desc_primary, desc_secondary;
lib = (HMODULE)LoadLibrary("dsound.dll");
if(lib==NULL) return FALSE;
dsound_create = (DIRECTSOUNDCREATE)GetProcAddress(lib, "DirectSoundCreate");
if(dsound_create==NULL) return FALSE;
FreeLibrary(lib);
if( dsound_create( NULL, &dsound, NULL )!= DS_OK ) return FALSE;
if( IDirectSound_SetCooperativeLevel( dsound, win, DSSCL_EXCLUSIVE | DSSCL_PRIORITY ) != DS_OK ) return FALSE;
memset( &desc_primary, 0, sizeof(DSBUFFERDESC) );
desc_primary.dwSize = sizeof(DSBUFFERDESC);
desc_primary.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_STICKYFOCUS;
if(IDirectSound_CreateSoundBuffer( dsound, &desc_primary, &primary, NULL )!=DS_OK) return FALSE;
memset( &format, 0, sizeof(WAVEFORMATEX) );
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = 2;
format.nSamplesPerSec = 44100;
format.nAvgBytesPerSec = 44100 * 4;
format.nBlockAlign = 4;
format.wBitsPerSample = 16;
if( IDirectSoundBuffer_SetFormat( primary, &format )!= DS_OK) return FALSE;
memset( &desc_secondary, 0, sizeof(DSBUFFERDESC) );
desc_secondary.dwSize = sizeof(DSBUFFERDESC);
desc_secondary.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2;
desc_secondary.lpwfxFormat = &format;
desc_secondary.dwBufferBytes = 2*2*BUFFER_LEN;
if(IDirectSound_CreateSoundBuffer( dsound, &desc_secondary, &secondary, NULL )!=DS_OK) return FALSE;
InitializeCriticalSection(&critical);
return TRUE;
}
示例9: DirectSoundInit
int DirectSoundInit()
{
HRESULT hr;
HWND hWnd;
LoadDsound();
hr = pDirectSoundCreate(NULL, &lpDirectSound, NULL);
if( hr != DS_OK )
return 0;
hWnd = GetForegroundWindow();
// establecer el nivel de cooperacion
hr = IDirectSound_SetCooperativeLevel(lpDirectSound,hWnd, DSSCL_NORMAL );
if( hr != DS_OK)
return 0;
return 1;
}
示例10: DSInitialize
/*
* DirectSoundを初期化する
*/
BOOL DSInitialize(HWND hWnd)
{
HRESULT hRet;
uintptr_t t;
/* IDirectSoundのインスタンスを取得して初期化する */
hRet = CoCreateInstance(&CLSID_DirectSound,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IDirectSound,
(void **)&pDS);
if(hRet != S_OK || pDS == NULL)
return FALSE;
/* COMオブジェクトを初期化する */
IDirectSound_Initialize(pDS, NULL);
/* 協調レベルを設定する */
hRet = IDirectSound_SetCooperativeLevel(pDS, hWnd, DSSCL_PRIORITY);
if(hRet != DS_OK)
return FALSE;
/* プライマリバッファのフォーマットを設定する */
if(!CreatePrimaryBuffer())
return FALSE;
/* セカンダリバッファを作成する */
if(!CreateSecondaryBuffers())
return FALSE;
/* イベントスレッドへの終了通知用のイベントを作成する */
hQuitEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if(hQuitEvent == NULL)
return FALSE;
/* DirectSoundの再生位置通知を受け取るスレッドを開始する */
t = _beginthread(EventThread, 0, NULL);
if(t == (unsigned long)-1)
return FALSE;
hEventThread = (HANDLE)t;
return TRUE;
}
示例11: digi_init
/* Initialise audio devices. */
int digi_init()
{
HRESULT hr;
if (!digi_initialised && g_hWnd){
memset(&waveformat, 0, sizeof(waveformat));
waveformat.wFormatTag=WAVE_FORMAT_PCM;
waveformat.wBitsPerSample=8;
waveformat.nChannels = 1;
waveformat.nSamplesPerSec = 11025;
waveformat.nBlockAlign =
waveformat.nChannels * (waveformat.wBitsPerSample/8);
waveformat.nAvgBytesPerSec =
waveformat.nSamplesPerSec * waveformat.nBlockAlign;
if ((hr = DirectSoundCreate(NULL, &lpds, NULL)) != DS_OK)
return -1;
if ((hr = IDirectSound_SetCooperativeLevel(lpds, g_hWnd, DSSCL_PRIORITY)) //hWndMain
!= DS_OK)
{
IDirectSound_Release(lpds);
return -1;
}
memset(&dsbd, 0, sizeof(dsbd));
dsbd.dwSize = sizeof(dsbd);
dsbd.dwFlags = (DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME) | DSBCAPS_GETCURRENTPOSITION2;
dsbd.dwBufferBytes = 8192;
dsbd.dwReserved=0;
dsbd.lpwfxFormat = &waveformat;
digi_initialised = 1;
}
if (!digi_atexit_initialised){
atexit(digi_close);
digi_atexit_initialised=1;
}
return 0;
}
示例12: dsound_open
static int dsound_open (dsound *s)
{
HRESULT hr;
HWND hwnd;
hwnd = GetForegroundWindow ();
hr = IDirectSound_SetCooperativeLevel (
s->dsound,
hwnd,
DSSCL_PRIORITY
);
if (FAILED (hr)) {
dsound_logerr (hr, "Could not set cooperative level for window %p\n",
hwnd);
return -1;
}
return 0;
}
示例13: setupSoundPlay
//open the dsound interface.
static BOOL setupSoundPlay(VOID)
{
HWND hwnd;
HRESULT hr;
hwnd = frameGetWinHandle();
hr =DirectSoundCreate(NULL, &lpDirectSound, NULL); // create dsound object
if (hr != DS_OK)
{
DBPRINTF(("NETPLAY Failed to create dsound interface.\n"));
return (FALSE);
}
hr =IDirectSound_SetCooperativeLevel(lpDirectSound, hwnd, DSSCL_PRIORITY); // Set coop level
if (hr != DS_OK)
{
DBPRINTF(("NETPLAY Failed to create playback buffer..\n"));
return (FALSE);
}
IDirectSound_Compact(lpDirectSound); // compact things
return (TRUE);
}
示例14: DSoundOpenPlayback
static ALCenum DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
{
DSoundPlaybackData *data = NULL;
LPGUID guid = NULL;
HRESULT hr;
if(!PlaybackDeviceList)
{
hr = DirectSoundEnumerateA(DSoundEnumPlaybackDevices, NULL);
if(FAILED(hr))
ERR("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
}
if(!deviceName && NumPlaybackDevices > 0)
{
deviceName = PlaybackDeviceList[0].name;
guid = &PlaybackDeviceList[0].guid;
}
else
{
ALuint i;
for(i = 0;i < NumPlaybackDevices;i++)
{
if(strcmp(deviceName, PlaybackDeviceList[i].name) == 0)
{
guid = &PlaybackDeviceList[i].guid;
break;
}
}
if(i == NumPlaybackDevices)
return ALC_INVALID_VALUE;
}
//Initialise requested device
data = calloc(1, sizeof(DSoundPlaybackData));
if(!data)
return ALC_OUT_OF_MEMORY;
hr = DS_OK;
data->NotifyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
if(data->NotifyEvent == NULL)
hr = E_FAIL;
//DirectSound Init code
if(SUCCEEDED(hr))
hr = DirectSoundCreate(guid, &data->DS, NULL);
if(SUCCEEDED(hr))
hr = IDirectSound_SetCooperativeLevel(data->DS, GetForegroundWindow(), DSSCL_PRIORITY);
if(FAILED(hr))
{
if(data->DS)
IDirectSound_Release(data->DS);
if(data->NotifyEvent)
CloseHandle(data->NotifyEvent);
free(data);
ERR("Device init failed: 0x%08lx\n", hr);
return ALC_INVALID_VALUE;
}
device->DeviceName = strdup(deviceName);
device->ExtraData = data;
return ALC_NO_ERROR;
}
示例15: m1sdr_Init
INT16 m1sdr_Init(int sample_rate)
{
DSBUFFERDESC dsbuf;
WAVEFORMATEX format;
if (!s32SoundEnable) return(0);
nDSoundSamRate = sample_rate;
samples = NULL;
lpDS = NULL;
lpPDSB = NULL;
lpSecB = NULL;
// Calculate the Seg Length and Loop length
// (round to nearest sample)
nDSoundSegLen=(nDSoundSamRate*10+(nDSoundFps>>1))/nDSoundFps;
cbLoopLen=(nDSoundSegLen*nDSoundSegCount)<<2;
// create an IDirectSound COM object
if (DS_OK != DirectSoundCreate(NULL, &lpDS, NULL))
{
printf("Unable to create DirectSound object!\n");
return(0);
}
// set cooperative level where we need it
if (DS_OK != IDirectSound_SetCooperativeLevel(lpDS, GetForegroundWindow(), DSSCL_PRIORITY))
{
printf("Unable to set cooperative level!\n");
return(0);
}
// now create a primary sound buffer
memset(&format, 0, sizeof(format));
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = 2;
format.wBitsPerSample = 16;
format.nSamplesPerSec = nDSoundSamRate;
format.nBlockAlign = 4; // stereo 16-bit
format.cbSize = 0;
format.nAvgBytesPerSec=format.nSamplesPerSec*format.nBlockAlign;
memset(&dsbuf, 0, sizeof(dsbuf));
dsbuf.dwSize = sizeof(DSBUFFERDESC);
dsbuf.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbuf.dwBufferBytes = 0;
dsbuf.lpwfxFormat = NULL;
if (DS_OK != IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpPDSB, NULL))
{
printf("Unable to create primary buffer!");
return(0);
}
// and set it's format how we want
if (DS_OK != IDirectSoundBuffer_SetFormat(lpPDSB, &format))
{
printf("Unable to set primary buffer format!\n");
return(0);
}
// start the primary buffer playing now so we get
// minimal lag when we trigger our secondary buffer
IDirectSoundBuffer_Play(lpPDSB, 0, 0, DSBPLAY_LOOPING);
// that's done, now let's create our secondary buffer
memset(&dsbuf, 0, sizeof(DSBUFFERDESC));
dsbuf.dwSize = sizeof(DSBUFFERDESC);
// we'll take default controls for this one
dsbuf.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY;
dsbuf.dwBufferBytes = cbLoopLen;
dsbuf.lpwfxFormat = (LPWAVEFORMATEX)&format;
if (DS_OK != IDirectSound_CreateSoundBuffer(lpDS, &dsbuf, &lpSecB, NULL))
{
printf("Unable to create secondary buffer\n");
return(0);
}
// ok, cool, we're ready to go!
// blank out the entire sound buffer
{
LPVOID ptr; DWORD len;
IDirectSoundBuffer_Lock(lpSecB, 0, 0, &ptr, &len, NULL, NULL, DSBLOCK_ENTIREBUFFER);
ZeroMemory(ptr, len);
IDirectSoundBuffer_Unlock(lpSecB, ptr, len, 0, 0);
}
// allocate and zero our local buffer
samples = (INT16 *)malloc(nDSoundSegLen<<2);
ZeroMemory(samples, nDSoundSegLen<<2);
//.........这里部分代码省略.........