本文整理汇总了C++中LPDIRECTSOUNDBUFFER::GetStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTSOUNDBUFFER::GetStatus方法的具体用法?C++ LPDIRECTSOUNDBUFFER::GetStatus怎么用?C++ LPDIRECTSOUNDBUFFER::GetStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECTSOUNDBUFFER
的用法示例。
在下文中一共展示了LPDIRECTSOUNDBUFFER::GetStatus方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DS_Refresh
//===========================================================================
// DS_Refresh
//===========================================================================
void DS_Refresh(sfxbuffer_t *buf)
{
LPDIRECTSOUNDBUFFER sound = DSBuf(buf);
DWORD status;
if(sound)
{
// Has the buffer finished playing?
sound->GetStatus(&status);
if(!(status & DSBSTATUS_PLAYING)
&& buf->flags & SFXBF_PLAYING)
{
// It has stopped playing.
buf->flags &= ~SFXBF_PLAYING;
}
}
}
示例2: SNDDMA_BeginPainting
/*
==============
SNDDMA_BeginPainting
Makes sure dma.buffer is valid
===============
*/
void SNDDMA_BeginPainting( void ) {
int reps;
DWORD dwSize2;
DWORD *pbuf, *pbuf2;
HRESULT hresult;
DWORD dwStatus;
if ( !pDSBuf ) {
return;
}
// if the buffer was lost or stopped, restore it and/or restart it
if ( pDSBuf->GetStatus (&dwStatus) != DS_OK ) {
Com_Printf ("Couldn't get sound buffer status\n");
}
if (dwStatus & DSBSTATUS_BUFFERLOST)
pDSBuf->Restore ();
if (!(dwStatus & DSBSTATUS_PLAYING))
pDSBuf->Play(0, 0, DSBPLAY_LOOPING);
// lock the dsound buffer
reps = 0;
dma.buffer = NULL;
while ((hresult = pDSBuf->Lock(0, gSndBufSize, (void **)&pbuf, &locksize,
(void **)&pbuf2, &dwSize2, 0)) != DS_OK)
{
if (hresult != DSERR_BUFFERLOST)
{
Com_Printf( "SNDDMA_BeginPainting: Lock failed with error '%s'\n", DSoundError( hresult ) );
S_Shutdown ();
return;
}
else
{
pDSBuf->Restore( );
}
if (++reps > 2)
return;
}
dma.buffer = (unsigned char *)pbuf;
}
示例3: PlaySoundLoop
// Sound wiederholt abspielen (Letzter Paramter: true = starten, false = stoppen)
void PlaySoundLoop(LPDIRECTSOUNDBUFFER lpDSB, int pan, int vol, BOOL bStartStop)
{
DWORD ret;
lpDSB->GetStatus(&ret);
if( (lpDSB) && (bStartStop) )
{
if(ret != DSBSTATUS_LOOPING)
{
lpDSB->SetPan(pan);
lpDSB->SetVolume(vol);
lpDSB->Play(0,0,DSBPLAY_LOOPING);
}
}
else if(lpDSB)
lpDSB->Stop();
}
示例4:
/*
===============
idAudioBufferWIN32::IsSoundPlaying
Desc: Checks to see if a buffer is playing and returns true if it
===============
*/
bool idAudioBufferWIN32::IsSoundPlaying( )
{
if( m_apDSBuffer == NULL )
{
return false;
}
if( m_apDSBuffer )
{
ulong dwStatus = 0;
m_apDSBuffer->GetStatus( &dwStatus );
if ( dwStatus & DSBSTATUS_PLAYING )
{
return true;
}
}
return false;
}
示例5: return
// ////////////////////////////////////////////////////////////////////
//
// ////////////////////////////////////////////////////////////////////
bool DirectSound8AudioBuffer::VIsPlaying()
{
if(!g_audioPtr || !g_audioPtr->VActive()) {
GF_LOG_TRACE_ERR("DirectSound8AudioBuffer::VIsPlaying()", "The sound system is not active");
return (false);
}
DWORD dwStatus = 0;
LPDIRECTSOUNDBUFFER pDSB = static_cast<LPDIRECTSOUNDBUFFER>(VGet());
if(!pDSB) {
GF_LOG_TRACE_ERR("DirectSound8AudioBuffer::VIsPlaying()", "Failed to cast the buffer to a DirectSound buffer");
return (false);
}
pDSB->GetStatus(&dwStatus);
bool bIsPlaying = ((dwStatus & DSBSTATUS_PLAYING) != 0);
return (bIsPlaying);
}
示例6: DXTRACE_ERR
/*
===============
idAudioBufferWIN32::RestoreBuffer
Desc: Restores the lost buffer. *pbWasRestored returns true if the buffer was
restored. It can also NULL if the information is not needed.
===============
*/
int idAudioBufferWIN32::RestoreBuffer(LPDIRECTSOUNDBUFFER pDSB, bool *pbWasRestored)
{
int hr;
if (pDSB == NULL) {
return -1;
}
if (pbWasRestored) {
*pbWasRestored = false;
}
ulong dwStatus;
if (FAILED(hr = pDSB->GetStatus(&dwStatus))) {
return DXTRACE_ERR(TEXT("GetStatus"), hr);
}
if (dwStatus & DSBSTATUS_BUFFERLOST) {
// Since the app could have just been activated, then
// DirectSound may not be giving us control yet, so
// the restoring the buffer may fail.
// If it does, sleep until DirectSound gives us control.
do {
hr = pDSB->Restore();
if (hr == DSERR_BUFFERLOST) {
Sleep(10);
}
hr = pDSB->Restore();
} while (hr);
if (pbWasRestored != NULL) {
*pbWasRestored = true;
}
return S_OK;
} else {
return S_FALSE;
}
}
示例7: StreamGetPosition
size_t StreamGetPosition(V3XA_STREAM handle)
{
ULONG lpStatus;
HRESULT hr;
DS_stream *pHandle = g_pDSStreams + handle;
LPDIRECTSOUNDBUFFER pDS;
if( handle<0)
return -1;
pDS = g_pDSHandles[pHandle->channel].pbuffer;
if (!pDS)
return -1;
hr = pDS->GetStatus(&lpStatus);
if (hr==DS_OK)
{
if (lpStatus & DSBSTATUS_PLAYING)
{
return pHandle->m_nTotalBytes;
}
}
return -1;
}
示例8: RestoreBuffer
//-----------------------------------------------------------------------------
// Name: CSound::RestoreBuffer()
// Desc: Restores the lost buffer. *pbWasRestored returns TRUE if the buffer was
// restored. It can also NULL if the information is not needed.
//-----------------------------------------------------------------------------
HRESULT CSound::RestoreBuffer( LPDIRECTSOUNDBUFFER pDSB, BOOL* pbWasRestored )
{
HRESULT hr;
if( pDSB == NULL )
return CO_E_NOTINITIALIZED;
if( pbWasRestored )
*pbWasRestored = FALSE;
DWORD dwStatus;
if( FAILED( hr = pDSB->GetStatus( &dwStatus ) ) )
return DXTRACE_ERR( TEXT("GetStatus"), hr );
if( dwStatus & DSBSTATUS_BUFFERLOST )
{
// Since the app could have just been activated, then
// DirectSound may not be giving us control yet, so
// the restoring the buffer may fail.
// If it does, sleep until DirectSound gives us control.
do
{
hr = pDSB->Restore();
if( hr == DSERR_BUFFERLOST )
Sleep( 10 );
}
while( ( hr = pDSB->Restore() ) == DSERR_BUFFERLOST );
if( pbWasRestored != NULL )
*pbWasRestored = TRUE;
return S_OK;
}
else
{
return S_FALSE;
}
}
示例9: get_free_buffer
LPDIRECTSOUND3DBUFFER zz_sound::get_free_buffer ()
{
LPDIRECTSOUND3DBUFFER pDS3DB;
LPDIRECTSOUNDBUFFER pDSB;
DWORD dwStatus = 0;
for( DWORD i=0; i< this->num_buffers; i++ )
{
pDSB = pSound->GetBuffer(i);
if( pDSB )
{
dwStatus = 0;
pDSB->GetStatus( &dwStatus );
if ( ( dwStatus & DSBSTATUS_PLAYING ) == 0 ) {
if (FAILED(pSound->Get3DBufferInterface( i, &pDS3DB ))) {
ZZ_LOG("sound: get_free_buffer() failed. Get3DBufferInterface() failed.\n");
return NULL;
}
return pDS3DB;
}
}
}
return NULL;
}
示例10: write
void DirectSound::write(u16 * finalWave, int length)
{
if(!pDirectSound) return;
HRESULT hr;
DWORD status = 0;
DWORD play = 0;
LPVOID lpvPtr1;
DWORD dwBytes1 = 0;
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
if( !speedup && throttle && !gba_joybus_active) {
hr = dsbSecondary->GetStatus(&status);
if( status & DSBSTATUS_PLAYING ) {
if( !soundPaused ) {
while( true ) {
dsbSecondary->GetCurrentPosition(&play, NULL);
int BufferLeft = ((soundNextPosition <= play) ?
play - soundNextPosition :
soundBufferTotalLen - soundNextPosition + play);
if(BufferLeft > soundBufferLen)
{
if (BufferLeft > soundBufferTotalLen - (soundBufferLen * 3))
soundBufferLow = true;
break;
}
soundBufferLow = false;
if(dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}
}
}
}/* else {
// TODO: remove?
setsoundPaused(true);
}*/
}
// Obtain memory address of write block.
// This will be in two parts if the block wraps around.
if( DSERR_BUFFERLOST == ( hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0 ) ) ) {
// If DSERR_BUFFERLOST is returned, restore and retry lock.
dsbSecondary->Restore();
hr = dsbSecondary->Lock(
soundNextPosition,
soundBufferLen,
&lpvPtr1,
&dwBytes1,
&lpvPtr2,
&dwBytes2,
0 );
}
soundNextPosition += soundBufferLen;
soundNextPosition = soundNextPosition % soundBufferTotalLen;
if( SUCCEEDED( hr ) ) {
// Write to pointers.
CopyMemory( lpvPtr1, finalWave, dwBytes1 );
if ( lpvPtr2 ) {
CopyMemory( lpvPtr2, finalWave + dwBytes1, dwBytes2 );
}
// Release the data back to DirectSound.
hr = dsbSecondary->Unlock( lpvPtr1, dwBytes1, lpvPtr2, dwBytes2 );
} else {
systemMessage( 0, _T("dsbSecondary->Lock() failed: %08x"), hr );
return;
}
}
示例11: SNDDMA_BeginPainting
void SNDDMA_BeginPainting (void)
{
int reps;
DWORD dwSize2;
DWORD *pbuf, *pbuf2;
HRESULT hresult;
DWORD dwStatus;
// if the buffer was lost or stopped, restore it and/or restart it
//if (!s_primary->value)
//{
if (!pDSBuf)
return;
#ifdef QDSNDCOMPILERHACK
if (pDSBuf->lpVtbl->GetStatus (pDSBuf, &dwStatus) != DS_OK)
#else
if (pDSBuf->GetStatus (&dwStatus) != DS_OK)
#endif
Com_Printf ("Couldn't get sound buffer status\n");
if (dwStatus & DSBSTATUS_BUFFERLOST)
#ifdef QDSNDCOMPILERHACK
pDSBuf->lpVtbl->Restore (pDSBuf);
#else
pDSBuf->Restore ();
#endif
if (!(dwStatus & DSBSTATUS_PLAYING))
#ifdef QDSNDCOMPILERHACK
pDSBuf->lpVtbl->Play(pDSBuf, 0, 0, DSBPLAY_LOOPING);
#else
pDSBuf->Play(0, 0, DSBPLAY_LOOPING);
#endif
/*}
else
{
if (!pDSPBuf)
return;
if (pDSPBuf->lpVtbl->GetStatus (pDSPBuf, &dwStatus) != DS_OK)
Com_Printf ("Couldn't get sound buffer status\n");
if (dwStatus & DSBSTATUS_BUFFERLOST)
pDSPBuf->lpVtbl->Restore (pDSPBuf);
if (!(dwStatus & DSBSTATUS_PLAYING))
pDSPBuf->lpVtbl->Play(pDSPBuf, 0, 0, DSBPLAY_LOOPING);
}*/
// lock the dsound buffer
reps = 0;
dma.buffer = NULL;
//if (!s_primary->value)
//{
#ifdef QDSNDCOMPILERHACK
while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &pbuf, &locksize,
&pbuf2, &dwSize2, 0)) != DS_OK)
#else
while ((hresult = pDSBuf->Lock(0, gSndBufSize, &pbuf, &locksize,
&pbuf2, &dwSize2, 0)) != DS_OK)
#endif
{
if (hresult != DSERR_BUFFERLOST)
{
Com_Printf( "S_TransferStereo16: Lock failed with error '%s'\n", DSoundError( hresult ) );
S_Shutdown ();
return;
}
else
{
#ifdef QDSNDCOMPILERHACK
pDSBuf->lpVtbl->Restore(pDSBuf);
#else
pDSBuf->Restore();
#endif
}
if (++reps > 2)
return;
}
/*}
else
{
while ((hresult = pDSPBuf->lpVtbl->Lock(pDSPBuf, 0, gSndBufSize, &pbuf, &locksize,
&pbuf2, &dwSize2, 0)) != DS_OK)
{
if (hresult != DSERR_BUFFERLOST)
{
Com_Printf( "S_TransferStereo16: Lock failed with error '%s'\n", DSoundError( hresult ) );
S_Shutdown ();
return;
}
else
{
pDSPBuf->lpVtbl->Restore(pDSPBuf);
}
if (++reps > 2)
//.........这里部分代码省略.........
示例12: write
void DirectSound::write()
{
int len = soundBufferLen;
LPVOID lpvPtr1;
DWORD dwBytes1;
LPVOID lpvPtr2;
DWORD dwBytes2;
if(!pDirectSound)
return;
if(theApp.soundRecording) {
if(dsbSecondary) {
if(theApp.soundRecorder == NULL) {
theApp.soundRecorder = new WavWriter;
WAVEFORMATEX format;
dsbSecondary->GetFormat(&format, sizeof(format), NULL);
if(theApp.soundRecorder->Open(theApp.soundRecordName))
theApp.soundRecorder->SetFormat(&format);
}
}
if(theApp.soundRecorder) {
theApp.soundRecorder->AddSound((u8 *)soundFinalWave, len);
}
}
if(theApp.aviRecording) {
if(theApp.aviRecorder) {
if(dsbSecondary) {
if(!theApp.aviRecorder->IsSoundAdded()) {
WAVEFORMATEX format;
dsbSecondary->GetFormat(&format, sizeof(format), NULL);
theApp.aviRecorder->SetSoundFormat(&format);
}
}
theApp.aviRecorder->AddSound((const char *)soundFinalWave, len);
}
}
HRESULT hr;
if(!speedup && synchronize && !theApp.throttle) {
DWORD status=0;
hr = dsbSecondary->GetStatus(&status);
if(status && DSBSTATUS_PLAYING) {
if(!soundPaused) {
DWORD play;
while(true) {
dsbSecondary->GetCurrentPosition(&play, NULL);
if(play < soundNextPosition ||
play > soundNextPosition+soundBufferLen) {
break;
}
if(dsbEvent) {
WaitForSingleObject(dsbEvent, 50);
}
}
}
} else {
soundPaused = 1;
}
}
// Obtain memory address of write block. This will be in two parts
// if the block wraps around.
hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen, &lpvPtr1,
&dwBytes1, &lpvPtr2, &dwBytes2,
0);
// If DSERR_BUFFERLOST is returned, restore and retry lock.
if (DSERR_BUFFERLOST == hr) {
dsbSecondary->Restore();
hr = dsbSecondary->Lock(soundNextPosition, soundBufferLen,&lpvPtr1,
&dwBytes1, &lpvPtr2, &dwBytes2,
0);
}
soundNextPosition += soundBufferLen;
soundNextPosition = soundNextPosition % soundBufferTotalLen;
if SUCCEEDED(hr) {
// Write to pointers.
CopyMemory(lpvPtr1, soundFinalWave, dwBytes1);
if (NULL != lpvPtr2) {
CopyMemory(lpvPtr2, soundFinalWave+dwBytes1, dwBytes2);
}
// Release the data back to DirectSound.
hr = dsbSecondary->Unlock(lpvPtr1, dwBytes1, lpvPtr2,
dwBytes2);
}
}
示例13: ChannelGetFree
/*------------------------------------------------------------------------
*
* PROTOTYPE : int ChannelGetFree(V3XA_HANDLE *sam)
*
* DESCRIPTION : Find a channel with the sample handle.
*
*/
int ChannelGetFree(V3XA_HANDLE *sam)
{
int i;
int prefSecure =-1;
int prefSamready =-1;
int prefSamStoppedMatch =-1;
int prefSamPriority =-1;
int newChannel =-1;
DS_handle *p;
if (!(V3XA.State & 1))
return -1;
for (i = 0, p = g_pDSHandles;i<RLX.Audio.ChannelToMix-1;i++, p++)
{
ULONG lpStatus;
LPDIRECTSOUNDBUFFER pDS = p->pbuffer;
if ((p->flags&DSH_RESERVED)==0) // n'y pense MEME PAS!
{
if (!pDS)
{
if ((prefSecure<0)&&(p->sample==NULL)) prefSecure = i;
if (i) prefSamready = i;
}
else
{
if ((sam)&&(pDS->GetStatus(&lpStatus) == DS_OK))
{
if (!(lpStatus & DSBSTATUS_PLAYING))
{
if (i) prefSamready = i;
if ((p->sample==sam))
{
prefSamStoppedMatch=i;
}
}
else
{
if (p->sample)
{
if (sam->priority>=p->sample->priority) prefSamPriority=i;
}
}
}
else
{
if (!p->sample)
{
if ((prefSecure<0)&&(p->sample==NULL)) prefSecure = i;
}
}
}
}
}
if (prefSamStoppedMatch>=0) newChannel = prefSamStoppedMatch;
else
if (prefSamready>=0) newChannel = prefSamready;
else
if (prefSamPriority>=0) newChannel = prefSamPriority;
else
if (prefSecure>=0) newChannel = prefSecure;
return newChannel>=32 ? -1 : newChannel;
}
示例14: DSS_RegisterHandle
/*------------------------------------------------------------------------
*
* PROTOTYPE : static int DSS_RegisterHandle(V3XA_HANDLE *sam, int channel)
*
* DESCRIPTION : Register a sample with a give channel.
*
*/
static int DSS_RegisterHandle(V3XA_HANDLE *sam, int channel)
{
ULONG lpStatus;
HRESULT hr;
DS_handle *hnd = g_pDSHandles + channel;
LPDIRECTSOUNDBUFFER pDS = hnd->pbuffer;
DWORD mode = 0;
// If there something in this channel ?
if (pDS)
{
// Try to load in the same channel
if ((g_pDSHandles[channel].sample==sam)&&(!(sam->sampleFormat&V3XA_FMTVOLATILE)))
{
hr = pDS->GetStatus(&lpStatus);
if (hr==DS_OK)
{
if (lpStatus & DSBSTATUS_PLAYING)
{
hr = pDS->Stop();
}
if (lpStatus & DSBSTATUS_BUFFERLOST)
{
if (DS_UploadSample( sam->sampleID, 0, (void*)sam->sample, sam->length))
{
return TRUE;
}
else
{
DS_Unregister3D(channel);
return FALSE;
}
}
}
return TRUE;
}
}
// Destroy channel if already exists
DSS_KillChannel(channel);
// Create format
if ( sam->sampleFormat & V3XA_FMT3D)
{
mode = DSBCAPS_CTRL3D | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLVOLUME;
}
else
{
mode = DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLVOLUME | DSBCAPS_GETCURRENTPOSITION2;
}
// FIXME : Hack
if ((RLX.Audio.Config & RLXAUDIO_UseHwMixer)&& (DriverGetMemory()>sam->length))
mode |= DSBCAPS_STATIC;
// Create a sound buffer.
sam->sampleID = DS_AllocBuffer(
sam->length,
sam->samplingRate,
sam->sampleFormat & V3XA_FMT16BIT ? 16 : 8,
sam->sampleFormat & V3XA_FMTSTEREO ? 2 : 1,
(uint16_t)channel,
mode
);
// Load the data.
if ((sam->sampleID == 0)||(!DS_UploadSample( (uint16_t)channel, 0, (void*)sam->sample, sam->length)))
{
sam->sampleID = 0;
return FALSE;
}
// Register it to 3D if necessary.
DS_Register3D(sam, g_pDSHandles + channel, 0);
return TRUE;
}