• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IDirectSoundBuffer_Unlock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IDirectSoundBuffer_Unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ IDirectSoundBuffer_Unlock函数的具体用法?C++ IDirectSoundBuffer_Unlock怎么用?C++ IDirectSoundBuffer_Unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IDirectSoundBuffer_Unlock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SndSys_UnlockRenderBuffer

/*
====================
SndSys_UnlockRenderBuffer

Release 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,代码来源:snd_win.c


示例2: DSW_ZeroEmptySpace

HRESULT 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,代码来源:dsound_wrapper.c


示例3: DS_Update

static 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,代码来源:drv_ds.c


示例4: AppWriteDataToBuffer

static 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,代码来源:dsound.c


示例5: DSW_WriteBlock

HRESULT 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,代码来源:dsound_wrapper.c


示例6: dx_clear

static 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,代码来源:sounddx.c


示例7: m1sdr_TimeCheck

void 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,代码来源:dsnd.c


示例8: DX5_PlayAudio

static 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,代码来源:SDL_dx5audio.c


示例9: DSSoundFeedVoiceData

void 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,代码来源:dsound51.cpp


示例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,代码来源:ao_dsound.c


示例11: DSOUND_PlayDevice

static void
DSOUND_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,代码来源:SDL_directsound.c


示例12: dsound_clear_buffer

static 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,代码来源:dsound.c


示例13: clear_buffers

static 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,代码来源:dsound.c


示例14: DSOUND_UpdatePlayback

int 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,代码来源:sp_dsound.c


示例15: DSoundRender_SendSampleData

static 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,代码来源:dsoundrender.c


示例16: RawWrite

static 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,代码来源:sound.c


示例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,代码来源:soundblaster.c


示例18: updateBufferProc

static 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,代码来源:drv_ds.c


示例19: FillDSBufer

int 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,代码来源:sound.c


示例20: DSOUND_LockBuffer

DWORD *
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,代码来源:snd_win.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IDirectSound_CreateSoundBuffer函数代码示例发布时间:2022-05-30
下一篇:
C++ IDirectSoundBuffer_Stop函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap