|
-
February 5th, 2007, 07:17 AM
#4
Re: memcpy error
I have opened the Call Stack and the green arrow points to this message: ">capturesound.exe!memcpy(unsigned char * dst=0x00000000, unsigned char * src=0x013b0028, unsigned long count=65000) Line 188 Asm"
I do not know how to debug this kind of error. Is this because of the allocation of the memory for the destination "buf"? If yes, how can I make a memory space for that. Can anyone help...
here is my code:
[source]
//-----------------------------------------------------------------------------
// Name: RecordCapturedData()
// Desc: Copies data from the capture buffer to the output buffer
//-----------------------------------------------------------------------------
HRESULT RecordCapturedData()
{
HRESULT hr;
VOID* pbCaptureData ; //= NULL;
DWORD dwCaptureLength;
VOID* pbCaptureData2 ;//= NULL;
DWORD dwCaptureLength2;
DWORD dwDataWrote;
DWORD dwReadPos;
DWORD dwCapturePos;
LONG lLockSize;
void* buf;
if( NULL == g_pDSBCapture )
return S_FALSE;
if( FAILED( hr = g_pDSBCapture->GetCurrentPosition( &dwCapturePos, &dwReadPos ) ) )
return DXTRACE_ERR_MSGBOX( TEXT("GetCurrentPosition"), hr );
lLockSize = dwReadPos - g_dwNextCaptureOffset;
if( lLockSize < 0 )
lLockSize += g_dwCaptureBufferSize;
// Block align lock size so that we are always write on a boundary
lLockSize -= (lLockSize % g_dwNotifySize);
if( lLockSize == 0 )
return S_FALSE;
// Lock the capture buffer down
if( FAILED( hr = g_pDSBCapture->Lock( g_dwNextCaptureOffset, lLockSize,
&pbCaptureData, &dwCaptureLength,
&pbCaptureData2, &dwCaptureLength2, 0L ) ) )
return DXTRACE_ERR_MSGBOX( TEXT("Lock"), hr );
if(pbCaptureData) memcpy(buf,pbCaptureData,dwCaptureLength);
if(pbCaptureData2) memcpy((char*)buf+dwCaptureLength,pbCaptureData2,dwCaptureLength2);
g_writefile = WriteFile(g_hCreateFile,
pbCaptureData,
dwCaptureLength,
&dwDataWrote,
NULL);
// Move the capture offset along
g_dwNextCaptureOffset += dwCaptureLength;
g_dwNextCaptureOffset %= g_dwCaptureBufferSize; // Circular buffer
g_writefile = WriteFile(g_hCreateFile,
pbCaptureData2,
dwCaptureLength2,
&dwDataWrote,
NULL);
// Move the capture offset along
g_dwNextCaptureOffset += dwCaptureLength2;
g_dwNextCaptureOffset %= g_dwCaptureBufferSize; // Circular buffer
// Unlock the capture buffer
g_pDSBCapture->Unlock( pbCaptureData, dwCaptureLength,
pbCaptureData2, dwCaptureLength2 );
return S_OK;
}
[/source]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|