这篇教程C++ IDirectSoundBuffer_Unlock函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中IDirectSoundBuffer_Unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ IDirectSoundBuffer_Unlock函数的具体用法?C++ IDirectSoundBuffer_Unlock怎么用?C++ IDirectSoundBuffer_Unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了IDirectSoundBuffer_Unlock函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: SndSys_UnlockRenderBuffer/*====================SndSys_UnlockRenderBufferRelease the exclusive lock on "snd_renderbuffer"====================*/void SndSys_UnlockRenderBuffer (void){#ifdef SUPPORTDIRECTX if (pDSBuf) IDirectSoundBuffer_Unlock(pDSBuf, dsound_pbuf, dsound_dwSize, dsound_pbuf2, dsound_dwSize2);#endif}
开发者ID:kasymovga,项目名称:DarkPlacesRM,代码行数:14,
示例2: DSW_ZeroEmptySpaceHRESULT DSW_ZeroEmptySpace( DSoundWrapper *dsw ){ HRESULT hr; LPBYTE lpbuf1 = NULL; LPBYTE lpbuf2 = NULL; DWORD dwsize1 = 0; DWORD dwsize2 = 0; long bytesEmpty; hr = DSW_QueryOutputSpace( dsw, &bytesEmpty ); // updates dsw_FramesPlayed if (hr != DS_OK) return hr; if( bytesEmpty == 0 ) return DS_OK; // Lock free space in the DS hr = IDirectSoundBuffer_Lock( dsw->dsw_OutputBuffer, dsw->dsw_WriteOffset, bytesEmpty, (void **) &lpbuf1, &dwsize1, (void **) &lpbuf2, &dwsize2, 0); if (hr == DS_OK) { // Copy the buffer into the DS ZeroMemory(lpbuf1, dwsize1); if(lpbuf2 != NULL) { ZeroMemory(lpbuf2, dwsize2); } // Update our buffer offset and unlock sound buffer dsw->dsw_WriteOffset = (dsw->dsw_WriteOffset + dwsize1 + dwsize2) % dsw->dsw_OutputSize; IDirectSoundBuffer_Unlock( dsw->dsw_OutputBuffer, lpbuf1, dwsize1, lpbuf2, dwsize2); dsw->dsw_FramesWritten += bytesEmpty / dsw->dsw_BytesPerFrame; } return hr;}
开发者ID:andreipaga,项目名称:audacity,代码行数:29,
示例3: DS_Updatestatic void DS_Update(void){ LPVOID block; DWORD bBytes; /* Do first update in DS_Update() to be consistent with other non threaded drivers. */ if (do_update && pSoundBuffer) { do_update = 0; if (IDirectSoundBuffer_Lock(pSoundBuffer, 0, fragsize, &block, &bBytes, NULL, NULL, 0) == DSERR_BUFFERLOST) { IDirectSoundBuffer_Restore (pSoundBuffer); IDirectSoundBuffer_Lock (pSoundBuffer, 0, fragsize, &block, &bBytes, NULL, NULL, 0); } if (Player_Paused_internal()) { VC_SilenceBytes ((SBYTE *)block, (ULONG)bBytes); } else { VC_WriteBytes ((SBYTE *)block, (ULONG)bBytes); } IDirectSoundBuffer_Unlock (pSoundBuffer, block, bBytes, NULL, 0); IDirectSoundBuffer_SetCurrentPosition(pSoundBuffer, 0); IDirectSoundBuffer_Play(pSoundBuffer, 0, 0, DSBPLAY_LOOPING); threadInUse=1; ResumeThread (updateBufferHandle); }}
开发者ID:OS2World,项目名称:LIB-SDL-2014,代码行数:31,
示例4: AppWriteDataToBufferstatic BOOL AppWriteDataToBuffer(LPDIRECTSOUNDBUFFER lpDsb, // The buffer. DWORD dwOffset, // Our own write cursor. LPBYTE lpbSoundData, // Start of our data. DWORD dwSoundBytes) // Size of block to copy.{ LPVOID lpvPtr1; DWORD dwBytes1; LPVOID lpvPtr2; DWORD dwBytes2; HRESULT hr; // Obtain memory address of write block. This will be in two parts // if the block wraps around. hr = IDirectSoundBuffer_Lock( lpDsb, dwOffset, dwSoundBytes, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); // If the buffer was lost, restore and retry lock. if (DSERR_BUFFERLOST == hr) { IDirectSoundBuffer_Restore(lpDsb); hr = IDirectSoundBuffer_Lock( lpDsb, dwOffset, dwSoundBytes, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); } if SUCCEEDED(hr) { pj_memcpy(lpvPtr1, lpbSoundData, dwBytes1); if (NULL != lpvPtr2) pj_memcpy(lpvPtr2, lpbSoundData+dwBytes1, dwBytes2); hr = IDirectSoundBuffer_Unlock(lpDsb, lpvPtr1, dwBytes1, lpvPtr2, dwBytes2); if SUCCEEDED(hr) return TRUE; } return FALSE; }
开发者ID:deveck,项目名称:Deveck.TAM,代码行数:35,
示例5: DSW_WriteBlockHRESULT DSW_WriteBlock( DSoundWrapper *dsw, char *buf, long numBytes ){ HRESULT hr; LPBYTE lpbuf1 = NULL; LPBYTE lpbuf2 = NULL; DWORD dwsize1 = 0; DWORD dwsize2 = 0; // Lock free space in the DS hr = IDirectSoundBuffer_Lock( dsw->dsw_OutputBuffer, dsw->dsw_WriteOffset, numBytes, (void **) &lpbuf1, &dwsize1, (void **) &lpbuf2, &dwsize2, 0); if (hr == DS_OK) { // Copy the buffer into the DS CopyMemory(lpbuf1, buf, dwsize1); if(lpbuf2 != NULL) { CopyMemory(lpbuf2, buf+dwsize1, dwsize2); } // Update our buffer offset and unlock sound buffer dsw->dsw_WriteOffset = (dsw->dsw_WriteOffset + dwsize1 + dwsize2) % dsw->dsw_OutputSize; IDirectSoundBuffer_Unlock( dsw->dsw_OutputBuffer, lpbuf1, dwsize1, lpbuf2, dwsize2); dsw->dsw_FramesWritten += numBytes / dsw->dsw_BytesPerFrame; } return hr;}
开发者ID:andreipaga,项目名称:audacity,代码行数:25,
示例6: dx_clearstatic void dx_clear(void){LPVOID lpvPtr1;DWORD dwBytes1;LPVOID lpvPtr2;DWORD dwBytes2;HRESULT result; result = IDirectSoundBuffer_Lock(buffer, 0, buffer_size, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); if (result == DSERR_BUFFERLOST) { IDirectSoundBuffer_Restore(buffer); } else { if (is16bit) { memset(lpvPtr1, 0, dwBytes1); if (lpvPtr2) memset(lpvPtr2, 0, dwBytes2); } else { memset(lpvPtr1, 0x80, dwBytes1); if (lpvPtr2) memset(lpvPtr2, 0x80, dwBytes2); } result = IDirectSoundBuffer_Unlock(buffer, lpvPtr1, dwBytes1, lpvPtr2, dwBytes2); }}
开发者ID:twinaphex,项目名称:vice-next,代码行数:25,
示例7: m1sdr_TimeCheckvoid m1sdr_TimeCheck(void){ int nPlaySeg=0, nFollowingSeg=0; DWORD nPlay=0, nWrite=0; int nRet=0; if (!lpDS) return; // We should do nothing until nPlay has left nDSoundNextSeg IDirectSoundBuffer_GetCurrentPosition(lpSecB, &nPlay, &nWrite); nPlaySeg=nPlay/(nDSoundSegLen<<2); if (nPlaySeg>nDSoundSegCount-1) nPlaySeg=nDSoundSegCount-1; if (nPlaySeg<0) nPlaySeg=0; // important to ensure nPlaySeg clipped for below if (nDSoundNextSeg == nPlaySeg) { Sleep(200); // Don't need to do anything for a bit goto End; } // work out which seg we will fill next nFollowingSeg = nDSoundNextSeg; WRAP_INC(nFollowingSeg) while (nDSoundNextSeg != nPlaySeg) { void *pData=NULL,*pData2=NULL; DWORD cbLen=0,cbLen2=0; // fill nNextSeg // Lock the relevant seg of the loop buffer nRet = IDirectSoundBuffer_Lock(lpSecB, nDSoundNextSeg*(nDSoundSegLen<<2), nDSoundSegLen<<2, &pData, &cbLen, &pData2, &cbLen2, 0); if (nRet>=0 && pData!=NULL) { // Locked the seg okay - write the sound we calculated last time memcpy(pData, samples, nDSoundSegLen<<2); } // Unlock (2nd 0 is because we wrote nothing to second part) if (nRet>=0) IDirectSoundBuffer_Unlock(lpSecB, pData, cbLen, pData2, 0); // generate more samples if (m1sdr_Callback) { m1sdr_Callback(nDSoundSegLen, samples); playtime++; } else { memset(samples, 0, nDSoundSegLen*4); } nDSoundNextSeg = nFollowingSeg; WRAP_INC(nFollowingSeg) }End: return;}
开发者ID:Kinglions,项目名称:modizer,代码行数:60,
示例8: DX5_PlayAudiostatic void DX5_PlayAudio(_THIS){ /* Unlock the buffer, allowing it to play */ if ( locked_buf ) { IDirectSoundBuffer_Unlock(mixbuf, locked_buf, mixlen, NULL, 0); }}
开发者ID:bohwaz,项目名称:ozex,代码行数:8,
示例9: DSSoundFeedVoiceDatavoid DSSoundFeedVoiceData(unsigned char* pSound,long lBytes){ LPVOID lpvPtr1, lpvPtr2; unsigned long dwBytes1,dwBytes2; unsigned long *lpSS, *lpSD; unsigned long dw,cplay,cwrite; HRESULT hr; unsigned long status; IDirectSoundBuffer_GetStatus(lpDSBSECONDARY1,&status); if (status & DSBSTATUS_BUFFERLOST) { if (IDirectSoundBuffer_Restore(lpDSBSECONDARY1) != DS_OK) return; IDirectSoundBuffer_Play(lpDSBSECONDARY1,0,0,DSBPLAY_LOOPING); } IDirectSoundBuffer_GetCurrentPosition(lpDSBSECONDARY1,&cplay,&cwrite); if(LastWrite == 0xffffffff) LastWrite=cwrite; hr = IDirectSoundBuffer_Lock(lpDSBSECONDARY1,LastWrite,lBytes, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); if (hr != DS_OK) { LastWrite=0xffffffff; return; } lpSS = (unsigned long *)pSound; lpSD = (unsigned long *)lpvPtr1; dw = dwBytes1 >> 2; while(dw) { *lpSD++=*lpSS++; dw--; } if (lpvPtr2) { lpSD = (unsigned long *)lpvPtr2; dw = dwBytes2 >> 2; while(dw) { *lpSD++ = *lpSS++; dw--; } } IDirectSoundBuffer_Unlock(lpDSBSECONDARY1,lpvPtr1,dwBytes1,lpvPtr2,dwBytes2); LastWrite += lBytes; if(LastWrite >= SOUNDSIZE) LastWrite -= SOUNDSIZE; LastPlay = cplay;}
开发者ID:madnessw,项目名称:thesnow,代码行数:56,
示例10: write_buffer/**/brief fill sound buffer/param data pointer to the sound data to copy/param len length of the data to copy in bytes/return number of copyed bytes*/static int write_buffer(struct ao *ao, unsigned char *data, int len){ struct priv *p = ao->priv; HRESULT res; LPVOID lpvPtr1; DWORD dwBytes1; LPVOID lpvPtr2; DWORD dwBytes2; p->underrun_check = 0; // Lock the buffer res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); // If the buffer was lost, restore and retry lock. if (DSERR_BUFFERLOST == res) { IDirectSoundBuffer_Restore(p->hdsbuf); res = IDirectSoundBuffer_Lock(p->hdsbuf, p->write_offset, len, &lpvPtr1, &dwBytes1, &lpvPtr2, &dwBytes2, 0); } if (SUCCEEDED(res)) { if (!AF_FORMAT_IS_AC3(ao->format)) { memcpy(lpvPtr1, data, dwBytes1); if (lpvPtr2 != NULL) memcpy(lpvPtr2, (char *)data + dwBytes1, dwBytes2); p->write_offset += dwBytes1 + dwBytes2; if (p->write_offset >= p->buffer_size) p->write_offset = dwBytes2; } else { // Write to pointers without reordering. memcpy(lpvPtr1, data, dwBytes1); if (NULL != lpvPtr2) memcpy(lpvPtr2, data + dwBytes1, dwBytes2); p->write_offset += dwBytes1 + dwBytes2; if (p->write_offset >= p->buffer_size) p->write_offset = dwBytes2; } // Release the data back to DirectSound. res = IDirectSoundBuffer_Unlock(p->hdsbuf, lpvPtr1, dwBytes1, lpvPtr2, dwBytes2); if (SUCCEEDED(res)) { // Success. DWORD status; IDirectSoundBuffer_GetStatus(p->hdsbuf, &status); if (!(status & DSBSTATUS_PLAYING)) res = IDirectSoundBuffer_Play(p->hdsbuf, 0, 0, DSBPLAY_LOOPING); return dwBytes1 + dwBytes2; } } // Lock, Unlock, or Restore failed. return 0;}
开发者ID:CrimsonVoid,项目名称:mpv,代码行数:62,
示例11: DSOUND_PlayDevicestatic voidDSOUND_PlayDevice(_THIS){ /* Unlock the buffer, allowing it to play */ if (this->hidden->locked_buf) { IDirectSoundBuffer_Unlock(this->hidden->mixbuf, this->hidden->locked_buf, this->spec.size, NULL, 0); }}
开发者ID:0-wiz-0,项目名称:mame,代码行数:10,
示例12: dsound_clear_bufferstatic void dsound_clear_buffer(dsound_t *ds){ IDirectSoundBuffer_SetCurrentPosition(ds->dsb, 0); void *ptr; DWORD size; if (IDirectSoundBuffer_Lock(ds->dsb, 0, 0, &ptr, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER) == DS_OK) { memset(ptr, 0, size); IDirectSoundBuffer_Unlock(ds->dsb, ptr, size, NULL, 0); }}
开发者ID:jonakino,项目名称:RetroArch,代码行数:12,
示例13: clear_buffersstatic void clear_buffers(ds_t *ds){ ds->writering = ds->rings - 1; DWORD size; void *output; if (IDirectSoundBuffer_Lock(ds->dsb, 0, 0, &output, &size, 0, 0, DSBLOCK_ENTIREBUFFER) == DS_OK) { memset(output, 0, size); IDirectSoundBuffer_Unlock(ds->dsb, output, size, 0, 0); }}
开发者ID:susan23,项目名称:RSound,代码行数:12,
示例14: DSOUND_UpdatePlaybackint DSOUND_UpdatePlayback(soundplay_t *sp, int samplechunks, char *buffer){ int ret; dsplay_t *dsp = (dsplay_t*)sp; char *sbuf; int sbufsize; int writable; int remaining = samplechunks; if (!samplechunks) return 0; IDirectSoundBuffer_GetCurrentPosition(dsp->dsbuf, &dsp->readpos, NULL); dsp->readpos /= dsp->sampbytes; while (ret = IDirectSoundBuffer_Lock(dsp->dsbuf, 0, dsp->buffersize*dsp->sampbytes, (void**)&sbuf, &sbufsize, NULL, NULL, 0)) { if (!FAILED(ret)) break; if (ret == DSERR_BUFFERLOST) printf("Buffer lost/n"); else break;// if (FAILED(IDirectSoundBuffer_Resore(dsp->dsbuf)))// return 0; } //memset(sbuf, 0, sbufsize); writable = remaining; if (writable > sbufsize/dsp->sampbytes - dsp->writepos) writable = sbufsize/dsp->sampbytes - dsp->writepos; memcpy(sbuf+dsp->writepos*dsp->sampbytes, buffer, writable*dsp->sampbytes); remaining -= writable; buffer += writable*dsp->sampbytes; dsp->writepos += writable; dsp->writepos %= dsp->buffersize; if (samplechunks > 0) { writable = remaining; if (writable > dsp->readpos) writable = dsp->readpos; memcpy(sbuf, buffer, writable*dsp->sampbytes); remaining -= writable; dsp->writepos += writable; dsp->writepos %= dsp->buffersize; } IDirectSoundBuffer_Unlock(dsp->dsbuf, sbuf, sbufsize, NULL, 0); printf("%i %i/n", 100*dsp->readpos / dsp->buffersize, 100*dsp->writepos / dsp->buffersize); return samplechunks - remaining;}
开发者ID:ProfessorKaos64,项目名称:ftequake,代码行数:52,
示例15: DSoundRender_SendSampleDatastatic HRESULT DSoundRender_SendSampleData(DSoundRenderImpl* This, REFERENCE_TIME tStart, REFERENCE_TIME tStop, const BYTE *data, DWORD size){ HRESULT hr; while (size && This->renderer.filter.state != State_Stopped) { DWORD writepos, skip = 0, free, size1, size2, ret; BYTE *buf1, *buf2; if (This->renderer.filter.state == State_Running) hr = DSoundRender_GetWritePos(This, &writepos, tStart, &free, &skip); else hr = S_FALSE; if (hr != S_OK) { This->in_loop = 1; LeaveCriticalSection(&This->renderer.csRenderLock); ret = WaitForSingleObject(This->blocked, 10); EnterCriticalSection(&This->renderer.csRenderLock); This->in_loop = 0; if (This->renderer.pInputPin->flushing || This->renderer.filter.state == State_Stopped) { return This->renderer.filter.state == State_Paused ? S_OK : VFW_E_WRONG_STATE; } if (ret != WAIT_TIMEOUT) ERR("%x/n", ret); continue; } tStart = -1; if (skip) FIXME("Sample dropped %u of %u bytes/n", skip, size); if (skip >= size) return S_OK; data += skip; size -= skip; hr = IDirectSoundBuffer_Lock(This->dsbuffer, writepos, min(free, size), (void**)&buf1, &size1, (void**)&buf2, &size2, 0); if (hr != DS_OK) { ERR("Unable to lock sound buffer! (%x)/n", hr); break; } memcpy(buf1, data, size1); if (size2) memcpy(buf2, data+size1, size2); IDirectSoundBuffer_Unlock(This->dsbuffer, buf1, size1, buf2, size2); This->writepos = (writepos + size1 + size2) % This->buf_size; TRACE("Wrote %u bytes at %u, next at %u - (%u/%u)/n", size1+size2, writepos, This->writepos, free, size); data += size1 + size2; size -= size1 + size2; } return S_OK;}
开发者ID:reactos,项目名称:reactos,代码行数:52,
示例16: RawWritestatic int RawWrite(void *data, uint32_t len){// uint32_t cw; //printf("Pre: %d/n",SexyALI_DSound_RawCanWrite(device)); //fflush(stdout); CheckDStatus(); /* In this block, we write as much data as we can, then we write the rest of it in >=1ms chunks. */ while(len) { VOID *LockPtr[2]={0,0}; DWORD LockLen[2]={0,0}; int32_t curlen; while(!(curlen=RawCanWrite())) { Sleep(1); } if(curlen>len) curlen=len; if(DS_OK == IDirectSoundBuffer_Lock(ppbufw,ToWritePos,curlen,&LockPtr[0],&LockLen[0],&LockPtr[1],&LockLen[1],0)) { } if(LockPtr[1] != 0 && LockPtr[1] != LockPtr[0]) { memcpy(LockPtr[0],data,LockLen[0]); memcpy(LockPtr[1],data+LockLen[0],len-LockLen[0]); } else if(LockPtr[0]) { memcpy(LockPtr[0],data,curlen); } IDirectSoundBuffer_Unlock(ppbufw,LockPtr[0],LockLen[0],LockPtr[1],LockLen[1]); ToWritePos=(ToWritePos+curlen)%DSBufferSize; len-=curlen; data = (void *)((uint8_t *)data + curlen); if(len) Sleep(1); } // end while(len) loop return(1);}
开发者ID:ficoos,项目名称:fceu-next,代码行数:49,
示例17: SB_Poll/* SB_Poll performs DMA transfers and fills the Direct Sound Buffer */static DWORD CALLBACK SB_Poll( void *dummy ){ HRESULT result; LPBYTE lpbuf1 = NULL; LPBYTE lpbuf2 = NULL; DWORD dwsize1 = 0; DWORD dwsize2 = 0; DWORD dwbyteswritten1 = 0; DWORD dwbyteswritten2 = 0; int size; /* FIXME: this loop must be improved */ while(!end_sound_loop) { Sleep(10); if (dma_enable) { size = DMA_Transfer(SB_DMA,min(DMATRFSIZE,SamplesCount),dma_buffer); } else continue; result = IDirectSoundBuffer_Lock(lpdsbuf,buf_off,size,(LPVOID *)&lpbuf1,&dwsize1,(LPVOID *)&lpbuf2,&dwsize2,0); if (result != DS_OK) { ERR("Unable to lock sound buffer !/n"); continue; } dwbyteswritten1 = min(size,dwsize1); memcpy(lpbuf1,dma_buffer,dwbyteswritten1); if (size>dwsize1) { dwbyteswritten2 = min(size - dwbyteswritten1,dwsize2); memcpy(lpbuf2,dma_buffer+dwbyteswritten1,dwbyteswritten2); } buf_off = (buf_off + dwbyteswritten1 + dwbyteswritten2) % DSBUFLEN; result = IDirectSoundBuffer_Unlock(lpdsbuf,lpbuf1,dwbyteswritten1,lpbuf2,dwbyteswritten2); if (result!=DS_OK) ERR("Unable to unlock sound buffer !/n"); SamplesCount -= size; if (!SamplesCount) { DOSVM_QueueEvent(SB_IRQ,SB_IRQ_PRI,NULL,NULL); dma_enable = 0; } } return 0;}
开发者ID:Dimillian,项目名称:wine,代码行数:48,
示例18: updateBufferProcstatic DWORD WINAPI updateBufferProc(LPVOID lpParameter){ LPVOID pBlock1 = NULL, pBlock2 = NULL; DWORD soundBufferCurrentPosition, blockBytes1, blockBytes2; DWORD start; while (threadInUse) { if (WaitForSingleObject(notifyUpdateHandle,INFINITE)==WAIT_OBJECT_0) { if (!threadInUse) break; IDirectSoundBuffer_GetCurrentPosition (pSoundBuffer,&soundBufferCurrentPosition,NULL); if (soundBufferCurrentPosition < fragsize) start = fragsize; else start = 0; if (IDirectSoundBuffer_Lock (pSoundBuffer,start,fragsize,&pBlock1,&blockBytes1, &pBlock2,&blockBytes2,0)==DSERR_BUFFERLOST) { IDirectSoundBuffer_Restore(pSoundBuffer); IDirectSoundBuffer_Lock (pSoundBuffer,start,fragsize,&pBlock1,&blockBytes1, &pBlock2,&blockBytes2,0); } MUTEX_LOCK(vars); if (Player_Paused_internal()) { VC_SilenceBytes((SBYTE*)pBlock1,(ULONG)blockBytes1); if (pBlock2) VC_SilenceBytes((SBYTE*)pBlock2,(ULONG)blockBytes2); } else { VC_WriteBytes((SBYTE*)pBlock1,(ULONG)blockBytes1); if (pBlock2) VC_WriteBytes((SBYTE*)pBlock2,(ULONG)blockBytes2); } MUTEX_UNLOCK(vars); IDirectSoundBuffer_Unlock (pSoundBuffer,pBlock1,blockBytes1,pBlock2,blockBytes2); } } return 0;}
开发者ID:OS2World,项目名称:LIB-SDL-2014,代码行数:46,
示例19: FillDSBuferint FillDSBufer(LPDIRECTSOUNDBUFFER pDSB,void* buffer, int ndata){ LPVOID pMem1, pMem2; DWORD dwSize1, dwSize2; if (SUCCEEDED(IDirectSoundBuffer_Lock(pDSB, 0, ndata, &pMem1, &dwSize1, &pMem2, &dwSize2, 0))) { CopyMemory(pMem1, buffer, dwSize1); if ( 0 != dwSize2 ) CopyMemory(pMem2, ((unsigned char*)buffer)+dwSize1, dwSize2); IDirectSoundBuffer_Unlock(pDSB, pMem1, dwSize1, pMem2, dwSize2); return 1; } return 0;}
开发者ID:javisantana,项目名称:cubyshot,代码行数:18,
示例20: DSOUND_LockBufferDWORD *DSOUND_LockBuffer(qboolean lockit){ int reps; static DWORD dwSize; static DWORD dwSize2; static DWORD *pbuf1; static DWORD *pbuf2; HRESULT hresult; if (!pDSBuf) return NULL; if (lockit) { reps = 0; while ((hresult = IDirectSoundBuffer_Lock (pDSBuf, 0, gSndBufSize, (LPVOID *) & pbuf1, &dwSize, (LPVOID *) & pbuf2, &dwSize2,0)) != DS_OK) { if (hresult != DSERR_BUFFERLOST) { Con_Printf ("S_TransferStereo16: DS::Lock Sound Buffer Failed/n"); S_Shutdown (); S_Startup (); return NULL; } if (++reps > 10000) { Con_Printf ("S_TransferStereo16: DS: couldn't restore buffer/n"); S_Shutdown (); S_Startup (); return NULL; } } } else { IDirectSoundBuffer_Unlock (pDSBuf, pbuf1, dwSize, NULL, 0); pbuf1=NULL; pbuf2=NULL; dwSize=0; dwSize2=0; } return(pbuf1);}
开发者ID:luaman,项目名称:qforge-newtree,代码行数:44,
示例21: FillBufferstatic void FillBuffer(int32_t bufnum){ HRESULT err; LPVOID ptr, ptr2; DWORD remaining, remaining2; int32_t retries = 1; //initprintf( "DirectSound FillBuffer: filling %d/n", bufnum); do { err = IDirectSoundBuffer_Lock(lpdsbsec, notifyPositions[bufnum].dwOffset, notifyPositions[1].dwOffset, &ptr, &remaining, &ptr2, &remaining2, 0); if (FAILED(err)) { if (err == DSERR_BUFFERLOST) { err = IDirectSoundBuffer_Restore(lpdsbsec); if (FAILED(err)) { return; } if (retries-- > 0) { continue; } } if (MV_Printf) MV_Printf("DirectSound FillBuffer: err %x/n", (uint32_t) err); return; } break; } while (1); if (ptr) { FillBufferPortion((char *) ptr, remaining); } if (ptr2) { FillBufferPortion((char *) ptr2, remaining2); } IDirectSoundBuffer_Unlock(lpdsbsec, ptr, remaining, ptr2, remaining2);}
开发者ID:sbrown345,项目名称:edukejs,代码行数:43,
示例22: m1sdr_PlayStopvoid m1sdr_PlayStop(void){ DSBUFFERDESC dsbuf; WAVEFORMATEX format; waveLogStop(); IDirectSoundBuffer_Stop(lpSecB); // this is a bit cheezity-hacky IDirectSoundBuffer_Release(lpSecB); 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(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; } // zero out the 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); }}
开发者ID:dreiss,项目名称:M1-Android,代码行数:42,
示例23: DSoundRender_InputPin_EndFlushstatic HRESULT WINAPI DSoundRender_InputPin_EndFlush(IPin * iface){ BaseInputPin *This = (BaseInputPin *)iface; DSoundRenderImpl *pFilter = (DSoundRenderImpl *)This->pin.pinInfo.pFilter; HRESULT hr; TRACE("/n"); EnterCriticalSection(This->pin.pCritSec); if (pFilter->in_loop) { ResetEvent(pFilter->state_change); LeaveCriticalSection(This->pin.pCritSec); WaitForSingleObject(pFilter->state_change, -1); EnterCriticalSection(This->pin.pCritSec); } if (pFilter->filter.state != State_Stopped) ResetEvent(pFilter->blocked); if (pFilter->dsbuffer) { LPBYTE buffer; DWORD size; IDirectSoundBuffer_Stop(pFilter->dsbuffer); /* Force a reset */ IDirectSoundBuffer_SetCurrentPosition(pFilter->dsbuffer, 0); pFilter->write_pos = pFilter->last_play_pos = 0; ++pFilter->play_loops; pFilter->write_loops = pFilter->play_loops; IDirectSoundBuffer_Lock(pFilter->dsbuffer, 0, 0, (LPVOID *)&buffer, &size, NULL, NULL, DSBLOCK_ENTIREBUFFER); memset(buffer, 0, size); IDirectSoundBuffer_Unlock(pFilter->dsbuffer, buffer, size, NULL, 0); } hr = BaseInputPinImpl_EndFlush(iface); LeaveCriticalSection(This->pin.pCritSec); MediaSeekingPassThru_ResetMediaTime(pFilter->seekthru_unk); return hr;}
开发者ID:r6144,项目名称:wine,代码行数:40,
示例24: DSFillSoundBufferBOOL DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD cbWaveSize){ if (pDSB && pbWaveData && cbWaveSize) { LPVOID pMem1, pMem2; DWORD dwSize1, dwSize2; if (SUCCEEDED(IDirectSoundBuffer_Lock(pDSB, 0, cbWaveSize, &pMem1, &dwSize1, &pMem2, &dwSize2, 0))) { CopyMemory(pMem1, pbWaveData, dwSize1); if ( 0 != dwSize2 ) CopyMemory(pMem2, pbWaveData+dwSize1, dwSize2); IDirectSoundBuffer_Unlock(pDSB, pMem1, dwSize1, pMem2, dwSize2); return TRUE; } } return FALSE;}
开发者ID:ForsakenW,项目名称:forsaken,代码行数:22,
示例25: CreateSecondary/* This function tries to create a secondary audio buffer, and returns the number of audio chunks available in the created buffer. This is for playback devices, not capture.*/static intCreateSecondary(_THIS, const DWORD bufsize, WAVEFORMATEX *wfmt){ LPDIRECTSOUND sndObj = this->hidden->sound; LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf; HRESULT result = DS_OK; DSBUFFERDESC format; LPVOID pvAudioPtr1, pvAudioPtr2; DWORD dwAudioBytes1, dwAudioBytes2; /* Try to create the secondary buffer */ SDL_zero(format); format.dwSize = sizeof(format); format.dwFlags = DSBCAPS_GETCURRENTPOSITION2; format.dwFlags |= DSBCAPS_GLOBALFOCUS; format.dwBufferBytes = bufsize; format.lpwfxFormat = wfmt; result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL); if (result != DS_OK) { return SetDSerror("DirectSound CreateSoundBuffer", result); } IDirectSoundBuffer_SetFormat(*sndbuf, wfmt); /* Silence the initial audio buffer */ result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes, (LPVOID *) & pvAudioPtr1, &dwAudioBytes1, (LPVOID *) & pvAudioPtr2, &dwAudioBytes2, DSBLOCK_ENTIREBUFFER); if (result == DS_OK) { SDL_memset(pvAudioPtr1, this->spec.silence, dwAudioBytes1); IDirectSoundBuffer_Unlock(*sndbuf, (LPVOID) pvAudioPtr1, dwAudioBytes1, (LPVOID) pvAudioPtr2, dwAudioBytes2); } /* We're ready to go */ return 0;}
开发者ID:0-wiz-0,项目名称:mame,代码行数:42,
示例26: copy_sample_datastatic void copy_sample_data(INT16 *data, int bytes_to_copy){ void *buffer1, *buffer2; DWORD length1, length2; HRESULT result; int cur_bytes; // attempt to lock the stream buffer result = IDirectSoundBuffer_Lock(stream_buffer, stream_buffer_in, bytes_to_copy, &buffer1, &length1, &buffer2, &length2, 0); // if we failed, assume it was an underflow (i.e., if (result != DS_OK) { buffer_underflows++; return; } // adjust the input pointer stream_buffer_in = (stream_buffer_in + bytes_to_copy) % stream_buffer_size; // copy the first chunk cur_bytes = (bytes_to_copy > length1) ? length1 : bytes_to_copy; memcpy(buffer1, data, cur_bytes); // adjust for the number of bytes bytes_to_copy -= cur_bytes; data = (INT16 *)((UINT8 *)data + cur_bytes); // copy the second chunk if (bytes_to_copy != 0) { cur_bytes = (bytes_to_copy > length2) ? length2 : bytes_to_copy; memcpy(buffer2, data, cur_bytes); } // unlock result = IDirectSoundBuffer_Unlock(stream_buffer, buffer1, length1, buffer2, length2);}
开发者ID:DarrenBranford,项目名称:MAME4iOS,代码行数:38,
注:本文中的IDirectSoundBuffer_Unlock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ IDirectSound_CreateSoundBuffer函数代码示例 C++ IDirectSoundBuffer_Stop函数代码示例 |