|
IDirectSoundBuffer8: ock
HRESULT Lock(
DWORD dwOffset,
DWORD dwBytes,
LPVOID * ppvAudioPtr1,
LPDWORD pdwAudioBytes1,
LPVOID * ppvAudioPtr2,
LPDWORD pdwAudioBytes2,
DWORD dwFlags
);
dwOffset
Offset, in bytes, from the start of the buffer to the point where the lock begins. This parameter is ignored if DSBLOCK_FROMWRITECURSOR is specified in the dwFlags parameter.
dwBytes
Size, in bytes, of the portion of the buffer to lock. The buffer is conceptually circular, so this number can exceed the number of bytes between dwOffset and the end of the buffer.
1 2 3 4
|。。。|。。。|。。。|。。。|
假设上面是将一个整的buffer分成四个小buffer块,每播放完一个buffer块,就读入一个新的音频数据块填入这个buffer块中。
若某时刻,在播放完2这个buffer块后,进行buffer 2的数据更新。这时:
//IDirectSound8 *g_pDS; // DirectSound component
//IDirectSoundBuffer8 *g_pDSBuffer; // Sound Buffer object
//IDirectSoundNotify8 *g_pDSNotify; // Notification object
//DWORD subBuffer=....//小buffer块的字节数
//DWORD Size=...//整个大buffer的字节数
pDSBuffer->Lock(subBuffer*1, Size,
(void**)& tr1, &Size1,
(void**)&Ptr2, &Size2, 0);
Ptr1,Ptr2,Size1,Size1将分别返还什么?
Ptr1,Ptr2分别指向什么位置? |
|