本文整理汇总了C++中FillBuffer函数的典型用法代码示例。如果您正苦于以下问题:C++ FillBuffer函数的具体用法?C++ FillBuffer怎么用?C++ FillBuffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FillBuffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: while
PRUint8
FCGXStream::RecvByte()
{
// See if the current block is exhausted.
while (mRecvBytesLeftInBlock == 0) {
if (!RecvNextBlock(PR_TRUE))
return 0;
}
// Next, see if we need to receive more bytes from the socket.
if (mRecvIn == mRecvOut) {
mRecvIn = 0;
FillBuffer();
if (mFD == INVALID_SOCKET)
return 0;
}
mRecvBytesLeftInBlock--;
g_recv.LogContents(mRecvBuf + mRecvOut, 1);
return mRecvBuf[mRecvOut++];
}
开发者ID:aptana,项目名称:Jaxer,代码行数:21,代码来源:FCGXStream.cpp
示例2: DirectSoundDrv_PCM_BeginPlayback
int DirectSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize,
int NumDivisions, void ( *CallBackFunc )( void ) )
{
HRESULT err;
if (!Initialised) {
ErrorCode = DSErr_Uninitialised;
return DSErr_Error;
}
DirectSoundDrv_PCM_StopPlayback();
MixBuffer = BufferStart;
MixBufferSize = BufferSize;
MixBufferCount = NumDivisions;
MixBufferCurrent = 0;
MixBufferUsed = 0;
MixCallBack = CallBackFunc;
// prime the buffer
FillBuffer(0);
mixThread = CreateThread(NULL, 0, fillDataThread, 0, 0, 0);
if (!mixThread) {
ErrorCode = DSErr_CreateThread;
return DSErr_Error;
}
SetThreadPriority(mixThread, THREAD_PRIORITY_HIGHEST);
err = IDirectSoundBuffer_Play(lpdsbsec, 0, 0, DSBPLAY_LOOPING);
if (FAILED( err )) {
ErrorCode = DSErr_PlaySecondary;
return DSErr_Error;
}
Playing = 1;
return DSErr_Ok;
}
开发者ID:DanielGibson,项目名称:jfaudiolib,代码行数:40,代码来源:driver_directsound.c
示例3: file
/* Given: DataFile A text file stream already opened for input.
FileName The name of this text file (as a char array string).
Task: To copy data from this file stream into sorted files (runs).
Return: DataFile The modified file stream is trivially modified by reading from it.
In the function name the number of runs is returned.
The sorted runs themselves are created and stored under the file names:
ExtSortTemp.0, ExtSortTemp.1, etc.
*/
int MakeSortedRuns(fstream & DataFile, PathType FileName)
{
fstream OutFile;
StringType Word, Extension;
PathType OutFileName;
int NumWords, k, NumFiles = 0;
BufType Buffer;
bool MoreData;
// Repeatedly fill one buffer and quicksort it, writing the buffer out to a temp file.
DataFile.getline(Word, MaxString);
if (DataFile.fail())
MoreData = false;
else
MoreData = true;
while (MoreData)
{
// Fill one buffer.
NumWords = FillBuffer(DataFile, Buffer, MoreData, Word);
QuickSort(Buffer, 0, NumWords - 1);
// Construct the temp file name.
strcpy(OutFileName, "ExtSortTemp.");
_itoa(NumFiles, Extension, 10); // Convert the int in NumFiles to a char array string.
strcat(OutFileName, Extension);
OutFile.open(OutFileName, ios::out);
if (OutFile.fail())
Error("Could not open the file named ", OutFileName);
for (k = 0; k < NumWords; k++)
OutFile << Buffer[k] << endl;
OutFile.close();
NumFiles++;
}
return NumFiles;
}
开发者ID:monish001,项目名称:CPP-Programs,代码行数:48,代码来源:extsort.cpp
示例4: BC_Example_Bridge
int BC_Example_Bridge(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
int err = -EFAULT;
int command = _IOC_NR(cmd);
BC_Example_ioctl_package sBridge;
if (copy_from_user(&sBridge, (void *)arg, sizeof(sBridge)) != 0)
{
return err;
}
switch(command)
{
case _IOC_NR(BC_Example_ioctl_fill_buffer):
{
if(FillBuffer(sBridge.inputparam) == -1)
{
return err;
}
break;
}
case _IOC_NR(BC_Example_ioctl_get_buffer_count):
{
if(GetBufferCount(&sBridge.outputparam) == -1)
{
return err;
}
break;
}
default:
return err;
}
if (copy_to_user((void *)arg, &sBridge, sizeof(sBridge)) != 0)
{
return err;
}
return 0;
}
开发者ID:andreimironenko,项目名称:graphics-sdk,代码行数:40,代码来源:bufferclass_example_linux.c
示例5: HR
HRESULT D3D9RenderImpl::Display(BYTE* pYplane, BYTE* pVplane, BYTE* pUplane)
{
if(!pYplane)
{
return E_POINTER;
}
if(m_format == D3DFMT_NV12 && !pVplane)
{
return E_POINTER;
}
if(m_format == D3DFMT_YV12 && (!pVplane || !pUplane))
{
return E_POINTER;
}
HR(CheckDevice());
HR(FillBuffer(pYplane, pVplane, pUplane));
HR(CreateScene());
return Present();
}
开发者ID:RajibTheKing,项目名称:DesktopClient,代码行数:22,代码来源:D3D9RenderImpl.cpp
示例6: ov_info
bool CWinGlkOGGSound::Play(int iRepeat, int iVolume, bool PauseState)
{
m_pReadPtr = m_pData;
if (m_pReadPtr == NULL)
return false;
// Open the stream
ov_callbacks VorbisCBs;
VorbisCBs.read_func = VorbisRead;
VorbisCBs.close_func = VorbisClose;
VorbisCBs.seek_func = VorbisSeek;
VorbisCBs.tell_func = VorbisTell;
if (ov_open_callbacks(this,&m_Stream,NULL,0,VorbisCBs) < 0)
return false;
m_StreamOpen = true;
vorbis_info* Info = ov_info(&m_Stream,-1);
// Create a buffer
if (CreateBuffer(Info->channels,Info->rate,16) == false)
return false;
// Set the duration of the sample
if (iRepeat > 0)
m_Duration = (DWORD)ceil(1000.0 * iRepeat * ov_time_total(&m_Stream,-1));
else
m_Duration = -1;
// Fill the buffer with sample data
m_iRepeat = (iRepeat < 0) ? -1 : iRepeat - 1;
if (FillBuffer(GetBufferSize()) == false)
return false;
// Set the volume for the buffer
SetVolume(iVolume);
// Start the buffer playing
return PlayBuffer(PauseState);
}
开发者ID:DavidKinder,项目名称:Windows-Glk,代码行数:38,代码来源:GlkSoundOGG.cpp
示例7: Play
bool DART::Play ()
{
Stopped = WaitStreamEnd = false;
BytesPlayed = 0;
int buffcount;
for (buffcount = 0; buffcount < BufferCount; buffcount++)
if (!FillBuffer (&MixBuffers [buffcount]))
break;
if (buffcount == 0)
Stopped = WaitStreamEnd = true;
else
{
APIRET rc = MixSetupParms.pmixWrite (MixSetupParms.ulMixHandle,
&MixBuffers [0], buffcount);
if (rc)
{
mciGetErrorString (rc, (PSZ) ErrorCode, sizeof (ErrorCode));
return FALSE;
}
}
return TRUE;
}
开发者ID:OS2World,项目名称:MM-SOUND-DevAudio,代码行数:23,代码来源:libDART.cpp
示例8: cObjectLock
int CAudioRenderer::OutputAudio(BYTE* pData, UINT nDataByteSize)
{
CAutoLock cObjectLock(this);
if (GetState() & STATE_WAITFORRESOURCES) {
memset(pData, 0, nDataByteSize);
return S_OK;
}
//Log("nDataByteSize = %d\n", nDataByteSize);
if (!(GetState() & STATE_EXECUTE)) {
memset(pData, 0, nDataByteSize);
//Log("audio 1\n");
return E_FAIL;
}
if (m_vecInObjs[0]->IsEOS() && m_PcmPool.GetSize() < nDataByteSize) {
SetEOS();
memset(pData, 0, nDataByteSize);
//Log("audio 2\n");
return E_FAIL;
}
FillBuffer(pData, nDataByteSize);
while (!m_pRefClock->IsStarted()) {
m_ASync.Wait(10000);
if (m_bFlush || m_bClose || m_bInterrupt) break;
}
if (m_bInterrupt) {
memset(pData, 0, nDataByteSize);
}
//Log("audio 3\n");
return S_OK;
}
开发者ID:bigbugbb,项目名称:video-player-infrastructure,代码行数:37,代码来源:AudioRenderer.cpp
示例9: GetBufferSceMp3
int GetBufferSceMp3(short* buf,int length,float amp,int channel)
{
int byteLength = length<<2,i=0;
if (streamsSceMp3[channel].paused || !streamsSceMp3[channel].initialized)
{
memset(buf,0,byteLength);
return PSPAALIB_WARNING_PAUSED_BUFFER_REQUESTED;
}
while(streamsSceMp3[channel].bufSize<byteLength)
{
if(sceMp3CheckStreamDataNeeded(streamsSceMp3[channel].handle))
{
FillBuffer(channel);
}
short* decodeBuf;
int bytesDecoded=sceMp3Decode(streamsSceMp3[channel].handle,&decodeBuf);
if (bytesDecoded <= 0) break;
streamsSceMp3[channel].buf=(u8*)realloc(streamsSceMp3[channel].buf,streamsSceMp3[channel].bufSize+bytesDecoded);
memcpy(streamsSceMp3[channel].buf+streamsSceMp3[channel].bufSize,decodeBuf,bytesDecoded);
streamsSceMp3[channel].bufSize+=bytesDecoded;
}
unsigned char byte1, byte2;
int how_many = (streamsSceMp3[channel].bufSize > byteLength ? byteLength : streamsSceMp3[channel].bufSize);
for (i=0;i<2*length;i++)
{
byte1 = (2*i >= how_many) ? 0 : streamsSceMp3[channel].buf[2*i];
byte2 = (2*i+1 >= how_many) ? 0 : streamsSceMp3[channel].buf[2*i+1];
buf[i]=((short)(byte1 | byte2<<8))*amp;
}
streamsSceMp3[channel].bufSize-=how_many;
memmove(streamsSceMp3[channel].buf,streamsSceMp3[channel].buf+how_many,streamsSceMp3[channel].bufSize);
return PSPAALIB_SUCCESS;
}
开发者ID:mariodon,项目名称:psp-taikoclone,代码行数:36,代码来源:pspaalibscemp3.c
示例10: fillDataThread
static DWORD WINAPI fillDataThread(LPVOID lpParameter)
{
DWORD waitret, waitret2;
HANDLE handles[] = { handles[0] = notifyPositions[0].hEventNotify,
handles[1] = notifyPositions[1].hEventNotify,
handles[2] = notifyPositions[2].hEventNotify };
UNREFERENCED_PARAMETER(lpParameter);
do {
waitret = WaitForMultipleObjects(3, handles, FALSE, INFINITE);
switch (waitret) {
case WAIT_OBJECT_0:
case WAIT_OBJECT_0+1:
waitret2 = WaitForSingleObject(mutex, INFINITE);
if (waitret2 == WAIT_OBJECT_0) {
FillBuffer(WAIT_OBJECT_0 + 1 - waitret);
ReleaseMutex(mutex);
} else {
if (MV_Printf)
MV_Printf( "DirectSound fillDataThread: wfso err %d\n", (int32_t) waitret2);
}
break;
case WAIT_OBJECT_0+2:
// initprintf( "DirectSound fillDataThread: exiting\n");
ExitThread(0);
break;
default:
if (MV_Printf)
MV_Printf( "DirectSound fillDataThread: wfmo err %d\n", (int32_t) waitret);
break;
}
} while (1);
return 0;
}
开发者ID:sbrown345,项目名称:edukejs,代码行数:36,代码来源:driver_directsound.c
示例11: Peek
/**
* Consume characters until you find the terminal char
*
* @update gess 3/25/98
* @param aString receives new data from stream
* @param addTerminal tells us whether to append terminal to aString
* @return error code
*/
nsresult nsScanner::ReadWhitespace(nsScannerSharedSubstring& aString,
PRInt32& aNewlinesSkipped,
PRBool& aHaveCR) {
aHaveCR = PR_FALSE;
if (!mSlidingBuffer) {
return kEOF;
}
PRUnichar theChar = 0;
nsresult result = Peek(theChar);
if (NS_FAILED(result)) {
return result;
}
nsScannerIterator origin, current, end;
PRBool done = PR_FALSE;
origin = mCurrentPosition;
current = origin;
end = mEndPosition;
PRBool haveCR = PR_FALSE;
while(!done && current != end) {
switch(theChar) {
case '\n':
case '\r':
{
++aNewlinesSkipped;
PRUnichar thePrevChar = theChar;
theChar = (++current != end) ? *current : '\0';
if ((thePrevChar == '\r' && theChar == '\n') ||
(thePrevChar == '\n' && theChar == '\r')) {
theChar = (++current != end) ? *current : '\0'; // CRLF == LFCR => LF
haveCR = PR_TRUE;
} else if (thePrevChar == '\r') {
// Lone CR becomes CRLF; callers should know to remove extra CRs
AppendUnicodeTo(origin, current, aString);
aString.writable().Append(PRUnichar('\n'));
origin = current;
haveCR = PR_TRUE;
}
}
break;
case ' ' :
case '\t':
theChar = (++current != end) ? *current : '\0';
break;
default:
done = PR_TRUE;
AppendUnicodeTo(origin, current, aString);
break;
}
}
SetPosition(current);
if (current == end) {
AppendUnicodeTo(origin, current, aString);
result = FillBuffer();
}
aHaveCR = haveCR;
return result;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:75,代码来源:nsScanner.cpp
示例12: LVExtractFilenameWithoutExtension
/// parses input stream
bool LVRtfParser::Parse()
{
//m_conv_table = GetCharsetByte2UnicodeTable( L"cp1251" );
bool errorFlag = false;
m_callback->OnStart(this);
// make fb2 document structure
m_callback->OnTagOpen( NULL, L"?xml" );
m_callback->OnAttribute( NULL, L"version", L"1.0" );
m_callback->OnAttribute( NULL, L"encoding", L"utf-8" );
//m_callback->OnEncoding( GetEncodingName().c_str(), GetCharsetTable( ) );
m_callback->OnTagBody();
m_callback->OnTagClose( NULL, L"?xml" );
m_callback->OnTagOpenNoAttr( NULL, L"FictionBook" );
// DESCRIPTION
m_callback->OnTagOpenNoAttr( NULL, L"description" );
m_callback->OnTagOpenNoAttr( NULL, L"title-info" );
//
lString16 bookTitle = LVExtractFilenameWithoutExtension( getFileName() ); //m_stream->GetName();
m_callback->OnTagOpenNoAttr( NULL, L"book-title" );
if ( !bookTitle.empty() )
m_callback->OnText( bookTitle.c_str(), bookTitle.length(), 0 );
//queue.DetectBookDescription( m_callback );
m_callback->OnTagOpenNoAttr( NULL, L"title-info" );
m_callback->OnTagClose( NULL, L"description" );
// BODY
m_callback->OnTagOpenNoAttr( NULL, L"body" );
//m_callback->OnTagOpen( NULL, L"section" );
// process text
//queue.DoTextImport( m_callback );
//m_callback->OnTagClose( NULL, L"section" );
txtbuf = new lChar16[ MAX_TXT_SIZE+1 ];
txtpos = 0;
txtfstart = 0;
char cwname[33];
while ( !Eof() && !errorFlag && !m_stopped ) {
// load next portion of data if necessary
if ( m_buf_len - m_buf_pos < MIN_BUF_DATA_SIZE ) {
if ( !FillBuffer( MIN_BUF_DATA_SIZE*2 ) ) {
errorFlag = true;
break;
}
}
int len = (int)m_buf_len - (int)m_buf_pos;
// check end of file
if ( len <=0 )
break; //EOF
const lUInt8 * p = m_buf + m_buf_pos;
lUInt8 ch = *p++;
if ( ch=='{' ) {
OnBraceOpen();
m_buf_pos++;
continue;
} else if ( ch=='}' ) {
OnBraceClose();
m_buf_pos++;
continue;
}
lUInt8 ch2 = *p;
if ( ch=='\\' && *p!='\'' ) {
// control
bool asteriskFlag = false;
if ( ch2=='*' ) {
ch = *(++p);
ch2 = *(++p);
asteriskFlag = true;
}
if ( (ch2>='A' && ch2<='Z') || (ch2>='a' && ch2<='z') ) {
// control word
int cwi = 0;
do {
cwname[cwi++] = ch2;
ch2 = *++p;
} while ( ( (ch2>='A' && ch2<='Z') || (ch2>='a' && ch2<='z') ) && cwi<32 );
cwname[cwi] = 0;
int param = PARAM_VALUE_NONE;
if ( ch2==' ' ) {
p++;
} else {
if ( ch2 == '-' ) {
p++;
param = 0;
for ( ;; ) {
ch2 = *++p;
if ( ch2<'0' || ch2>'9' )
break;
param = param * 10 + (ch2-'0');
}
param = -param;
} else if ( ch2>='0' && ch2<='9' ) {
param = 0;
while ( ch2>='0' && ch2<='9' ) {
param = param * 10 + (ch2-'0');
ch2 = *++p;
}
}
if ( *p == ' ' )
//.........这里部分代码省略.........
开发者ID:dxwts,项目名称:coolreader3,代码行数:101,代码来源:rtfimp.cpp
示例13: SysRead
size_t SysRead( b_file *io, char *b, size_t len )
//===============================================
{
size_t bytes_read;
size_t amt;
size_t offs_in_b;
size_t max_valid;
if( io->attrs & BUFFERED ) {
// determine the maximum valid position in the buffer
max_valid = io->read_len;
if( max_valid < io->high_water ) {
max_valid = io->high_water;
}
// if we're beyond that position then we must fill the buffer
if( io->b_curs >= max_valid ) {
if( FillBuffer( io ) < 0 )
return( READ_ERROR );
max_valid = io->read_len;
}
amt = max_valid - io->b_curs;
if( amt > len ) {
amt = len;
}
memcpy( b, &io->buffer[io->b_curs], amt );
offs_in_b = amt;
io->b_curs += amt;
len -= amt;
if( len ) {
// flush the buffer
if( FlushBuffer( io ) < 0 )
return( READ_ERROR );
if( len > io->buff_size ) {
// read a multiple of io->buff_size bytes
amt = len - len % io->buff_size;
bytes_read = readbytes( io, b + offs_in_b, amt );
if( bytes_read == READ_ERROR )
return( READ_ERROR );
offs_in_b += bytes_read;
if( bytes_read < amt )
return( offs_in_b );
len -= amt;
}
if( len ) {
// first fill the buffer
bytes_read = readbytes( io, io->buffer, io->buff_size );
if( bytes_read == READ_ERROR )
return( READ_ERROR );
io->attrs |= READ_AHEAD;
io->read_len = bytes_read;
// then grab our bytes from it
if( len > bytes_read ) {
len = bytes_read;
}
memcpy( b + offs_in_b, io->buffer, len );
io->b_curs = len;
offs_in_b += len;
}
}
return( offs_in_b );
} else {
return( readbytes( io, b, len ) );
}
}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:64,代码来源:posget.c
示例14: GetTextRec
static size_t GetTextRec( b_file *io, char *b, size_t len )
//=========================================================
// Get a record from a TEXT file.
{
char ch;
size_t read;
char rs[2];
if( io->attrs & SEEK ) { // direct access
if( SysRead( io, b, len ) == READ_ERROR )
return( 0 );
if( SysRead( io, rs, sizeof( char ) ) == READ_ERROR )
return( 0 );
if( rs[0] == LF )
return( len );
#if ! defined( __UNIX__ )
if( rs[0] == CR ) {
if( SysRead( io, &rs[1], sizeof( char ) ) == READ_ERROR ) {
return( 0 );
}
if( rs[1] == LF )
return( len );
if( ( io->attrs & CARRIAGE_CONTROL ) && ( rs[1] == FF ) ) {
return( len );
}
}
#endif
FSetErr( IO_BAD_RECORD, io );
return( 0 );
} else if( io->attrs & BUFFERED ) {
char *ptr;
char *stop;
bool seen_cr;
bool trunc;
size_t max_valid;
// determine maximum valid position in the buffer
max_valid = io->read_len;
if( max_valid < io->high_water ) {
max_valid = io->high_water;
}
stop = io->buffer + max_valid;
ptr = io->buffer + io->b_curs;
read = 0;
seen_cr = false;
trunc = false;
for( ;; ) {
if( ptr >= stop ) {
io->b_curs = ptr - io->buffer;
if( FillBuffer( io ) < 0 ) {
// we have to do this so that io->b_curs is set properly
// on end of file
ptr = io->buffer + io->b_curs;
if( read > 0 && io->stat == IO_EOF ) {
IOOk( io );
}
break;
}
stop = io->buffer + io->read_len;
ptr = io->buffer + io->b_curs;
}
ch = *ptr;
++ptr;
if( ch == LF )
break;
if( !seen_cr ) {
if( ch == CTRL_Z ) {
--ptr; // give back char so we don't read past EOF
if( read == 0 )
FSetEof( io );
break;
}
if( ch == CR ) {
seen_cr = true;
} else if( read < len ) {
b[read] = ch;
++read;
} else {
trunc = true;
}
} else {
if( ch == FF && (io->attrs & CARRIAGE_CONTROL) )
break;
--ptr; // give back the char
seen_cr = false;
if( read < len ) {
b[read] = CR;
++read;
} else {
trunc = true;
}
}
}
io->b_curs = ptr - io->buffer;
if( trunc ) {
FSetTrunc( io );
}
return( read );
} else { // device (CON)
read = 0;
//.........这里部分代码省略.........
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:101,代码来源:posget.c
示例15: LFA_Seek
void PSIR_FileWriter::ParseFileResources ( LFA_FileRef fileRef, XMP_Uns32 length )
{
bool ok;
this->DeleteExistingInfo();
this->fileParsed = true;
if ( length == 0 ) return;
// Parse the image resource block.
IOBuffer ioBuf;
ioBuf.filePos = LFA_Seek ( fileRef, 0, SEEK_CUR );
XMP_Int64 psirOrigin = ioBuf.filePos; // Need this to determine the resource data offsets.
XMP_Int64 fileEnd = ioBuf.filePos + length;
std::string rsrcPName;
while ( (ioBuf.filePos + (ioBuf.ptr - ioBuf.data)) < fileEnd ) {
ok = CheckFileSpace ( fileRef, &ioBuf, 12 ); // The minimal image resource takes 12 bytes.
if ( ! ok ) break; // Bad image resource. Throw instead?
XMP_Int64 thisRsrcPos = ioBuf.filePos + (ioBuf.ptr - ioBuf.data);
XMP_Uns32 type = GetUns32BE(ioBuf.ptr);
XMP_Uns16 id = GetUns16BE(ioBuf.ptr+4);
ioBuf.ptr += 6; // Advance to the resource name.
XMP_Uns16 nameLen = ioBuf.ptr[0]; // ! The length for the Pascal string.
XMP_Uns16 paddedLen = (nameLen + 2) & 0xFFFE; // ! Round up to an even total. Yes, +2!
ok = CheckFileSpace ( fileRef, &ioBuf, paddedLen+4 ); // Get the name text and the data length.
if ( ! ok ) break; // Bad image resource. Throw instead?
if ( nameLen > 0 ) rsrcPName.assign ( (char*)(ioBuf.ptr), paddedLen ); // ! Include the length byte and pad.
ioBuf.ptr += paddedLen; // Move to the data length.
XMP_Uns32 dataLen = GetUns32BE(ioBuf.ptr);
XMP_Uns32 dataTotal = ((dataLen + 1) & 0xFFFFFFFEUL); // Round up to an even total.
ioBuf.ptr += 4; // Advance to the resource data.
XMP_Int64 thisDataPos = ioBuf.filePos + (ioBuf.ptr - ioBuf.data);
XMP_Int64 nextRsrcPos = thisDataPos + dataTotal;
if ( type != k8BIM ) {
XMP_Uns32 fullRsrcLen = (XMP_Uns32) (nextRsrcPos - thisRsrcPos);
this->otherRsrcs.push_back ( OtherRsrcInfo ( (XMP_Uns32)thisRsrcPos, fullRsrcLen ) );
MoveToOffset ( fileRef, nextRsrcPos, &ioBuf );
continue;
}
InternalRsrcMap::value_type mapValue ( id, InternalRsrcInfo ( id, dataLen, kIsFileBased ) );
InternalRsrcMap::iterator newRsrc = this->imgRsrcs.insert ( this->imgRsrcs.end(), mapValue );
InternalRsrcInfo* rsrcPtr = &newRsrc->second;
rsrcPtr->origOffset = (XMP_Uns32)thisDataPos;
if ( nameLen > 0 ) {
rsrcPtr->rsrcName = (XMP_Uns8*) malloc ( paddedLen );
if ( rsrcPtr->rsrcName == 0 ) XMP_Throw ( "Out of memory", kXMPErr_NoMemory );
memcpy ( (void*)rsrcPtr->rsrcName, rsrcPName.c_str(), paddedLen ); // AUDIT: Safe, allocated enough bytes above.
}
if ( ! IsMetadataImgRsrc ( id ) ) {
MoveToOffset ( fileRef, nextRsrcPos, &ioBuf );
continue;
}
rsrcPtr->dataPtr = malloc ( dataLen ); // ! Allocate after the IsMetadataImgRsrc check.
if ( rsrcPtr->dataPtr == 0 ) XMP_Throw ( "Out of memory", kXMPErr_NoMemory );
if ( dataTotal <= kIOBufferSize ) {
// The image resource data fits within the I/O buffer.
ok = CheckFileSpace ( fileRef, &ioBuf, dataTotal );
if ( ! ok ) break; // Bad image resource. Throw instead?
memcpy ( (void*)rsrcPtr->dataPtr, ioBuf.ptr, dataLen ); // AUDIT: Safe, malloc'ed dataLen bytes above.
ioBuf.ptr += dataTotal; // ! Add the rounded length.
} else {
// The image resource data is bigger than the I/O buffer.
LFA_Seek ( fileRef, (ioBuf.filePos + (ioBuf.ptr - ioBuf.data)), SEEK_SET );
LFA_Read ( fileRef, (void*)rsrcPtr->dataPtr, dataLen );
FillBuffer ( fileRef, nextRsrcPos, &ioBuf );
}
}
#if 0
{
printf ( "\nPSIR_FileWriter::ParseFileResources, count = %d\n", this->imgRsrcs.size() );
InternalRsrcMap::iterator irPos = this->imgRsrcs.begin();
InternalRsrcMap::iterator irEnd = this->imgRsrcs.end();
for ( ; irPos != irEnd; ++irPos ) {
InternalRsrcInfo& thisRsrc = irPos->second;
printf ( " #%d, dataLen %d, origOffset %d (0x%X)%s\n",
thisRsrc.id, thisRsrc.dataLen, thisRsrc.origOffset, thisRsrc.origOffset,
(thisRsrc.changed ? ", changed" : "") );
}
}
#endif
//.........这里部分代码省略.........
开发者ID:JanX2,项目名称:exempi,代码行数:101,代码来源:PSIR_FileWriter.cpp
示例16: OnThreadStartPlay
// the loop executed while running
HRESULT FCapturePin::DoBufferProcessingLoop(void)
{
Command com;
OnThreadStartPlay();
int32 LastFrame = -1;
do
{
while (!CheckRequest(&com))
{
// Wait for the next frame from the game thread
if ( !GCaptureSyncEvent->Wait(1000) )
{
FPlatformProcess::Sleep( 0.01f );
continue; // Reevaluate request
}
IMediaSample *pSample;
int32 FrameNumber = FAVIWriter::GetInstance()->GetFrameNumber();
if (FrameNumber > LastFrame)
{
UE_LOG(LogMovieCapture, Log, TEXT(" FrameNumber > LastFrame = %d > %d"), FrameNumber, LastFrame);
HRESULT hr = GetDeliveryBuffer(&pSample,NULL,NULL,0);
if (FAILED(hr))
{
if (pSample)
{
pSample->Release();
}
}
else
{
LastFrame = FrameNumber;
hr = FillBuffer(pSample);
if (hr == S_OK)
{
hr = Deliver(pSample);
pSample->Release();
// downstream filter returns S_FALSE if it wants us to
// stop or an error if it's reporting an error.
if(hr != S_OK)
{
UE_LOG(LogMovieCapture, Log, TEXT("Deliver() returned %08x; stopping"), hr);
return S_OK;
}
}
}
}
// Allow the game thread read more data
GCaptureSyncEvent->Trigger();
}
// For all commands sent to us there must be a Reply call!
if (com == CMD_RUN || com == CMD_PAUSE)
{
Reply(NOERROR);
}
else if (com != CMD_STOP)
{
Reply((uint32) E_UNEXPECTED);
}
} while (com != CMD_STOP);
return S_FALSE;
}
开发者ID:Foreven,项目名称:Unreal4-1,代码行数:68,代码来源:CapturePin.cpp
示例17: Microphone
void Microphone( void *pvParameters )
{
long lRetVal = -1;
#ifdef MULTICAST
//Wait for Network Connection
while((!IS_IP_ACQUIRED(g_ulStatus)))
{
}
#endif //MULTICAST
while(1)
{
while(g_ucMicStartFlag || g_loopback)
{
int iBufferFilled = 0;
iBufferFilled = GetBufferSize(pRecordBuffer);
if(iBufferFilled >= (2*PACKET_SIZE))
{
if(!g_loopback)
{
#ifndef MULTICAST
lRetVal = sendto(g_UdpSock.iSockDesc, \
(char*)(pRecordBuffer->pucReadPtr),PACKET_SIZE,\
0,(struct sockaddr*)&(g_UdpSock.Client),\
sizeof(g_UdpSock.Client));
if(lRetVal < 0)
{
UART_PRINT("Unable to send data\n\r");
LOOP_FOREVER();
}
#else //MULTICAST
lRetVal = SendMulticastPacket();
if(lRetVal < 0)
{
UART_PRINT("Unable to send data\n\r");
LOOP_FOREVER();
}
#endif //MULTICAST
}
else
{
lRetVal = FillBuffer(pPlayBuffer,\
(unsigned char*)(pRecordBuffer->pucReadPtr), \
PACKET_SIZE);
if(lRetVal < 0)
{
UART_PRINT("Unable to fill buffer\n\r");
}
g_iReceiveCount++;
}
UpdateReadPtr(pRecordBuffer, PACKET_SIZE);
g_iSentCount++;
}
}
MAP_UtilsDelay(1000);
}
}
开发者ID:moyanming,项目名称:CC3200SDK_1.2.0,代码行数:62,代码来源:microphone.c
示例18: ApplyBSDiffPatchMem
int ApplyBSDiffPatchMem(const unsigned char* old_data, ssize_t old_size,
const Value* patch, ssize_t patch_offset,
unsigned char** new_data, ssize_t* new_size) {
// Patch data format:
// 0 8 "BSDIFF40"
// 8 8 X
// 16 8 Y
// 24 8 sizeof(newfile)
// 32 X bzip2(control block)
// 32+X Y bzip2(diff block)
// 32+X+Y ??? bzip2(extra block)
// with control block a set of triples (x,y,z) meaning "add x bytes
// from oldfile to x bytes from the diff block; copy y bytes from the
// extra block; seek forwards in oldfile by z bytes".
unsigned char* header = (unsigned char*) patch->data + patch_offset;
if (memcmp(header, "BSDIFF40", 8) != 0) {
printf("corrupt bsdiff patch file header (magic number)\n");
return 1;
}
ssize_t ctrl_len, data_len;
ctrl_len = offtin(header+8);
data_len = offtin(header+16);
*new_size = offtin(header+24);
if (ctrl_len < 0 || data_len < 0 || *new_size < 0) {
printf("corrupt patch file header (data lengths)\n");
return 1;
}
int bzerr;
bz_stream cstream;
cstream.next_in = patch->data + patch_offset + 32;
cstream.avail_in = ctrl_len;
cstream.bzalloc = NULL;
cstream.bzfree = NULL;
cstream.opaque = NULL;
if ((bzerr = BZ2_bzDecompressInit(&cstream, 0, 0)) != BZ_OK) {
printf("failed to bzinit control stream (%d)\n", bzerr);
}
bz_stream dstream;
dstream.next_in = patch->data + patch_offset + 32 + ctrl_len;
dstream.avail_in = data_len;
dstream.bzalloc = NULL;
dstream.bzfree = NULL;
dstream.opaque = NULL;
if ((bzerr = BZ2_bzDecompressInit(&dstream, 0, 0)) != BZ_OK) {
printf("failed to bzinit diff stream (%d)\n", bzerr);
}
bz_stream estream;
estream.next_in = patch->data + patch_offset + 32 + ctrl_len + data_len;
estream.avail_in = patch->size - (patch_offset + 32 + ctrl_len + data_len);
estream.bzalloc = NULL;
estream.bzfree = NULL;
estream.opaque = NULL;
if ((bzerr = BZ2_bzDecompressInit(&estream, 0, 0)) != BZ_OK) {
printf("failed to bzinit extra stream (%d)\n", bzerr);
}
*new_data = malloc(*new_size);
if (*new_data == NULL) {
printf("failed to allocate %ld bytes of memory for output file\n",
(long)*new_size);
return 1;
}
off_t oldpos = 0, newpos = 0;
off_t ctrl[3];
off_t len_read;
int i;
unsigned char buf[24];
while (newpos < *new_size) {
// Read control data
if (FillBuffer(buf, 24, &cstream) != 0) {
printf("error while reading control stream\n");
return 1;
}
ctrl[0] = offtin(buf);
ctrl[1] = offtin(buf+8);
ctrl[2] = offtin(buf+16);
if (ctrl[0] < 0 || ctrl[1] < 0) {
printf("corrupt patch (negative byte counts)\n");
return 1;
}
// Sanity check
if (newpos + ctrl[0] > *new_size) {
printf("corrupt patch (new file overrun)\n");
return 1;
}
// Read diff string
if (FillBuffer(*new_data + newpos, ctrl[0], &dstream) != 0) {
printf("error while reading diff stream\n");
return 1;
//.........这里部分代码省略.........
开发者ID:APAR1992,项目名称:cwm_recovery_dual_language-1,代码行数:101,代码来源:bspatch.c
示例19: FillBuffer
inline unsigned long LowFirstBitReader::PeekBits(unsigned int length)
{
bool result = FillBuffer(length);
assert(result);
return m_buffer & (((unsigned long)1 << length) - 1);
}
开发者ID:007pig,项目名称:BitcoinArmory,代码行数:6,代码来源:zinflate.cpp
示例20: main
int main()
{
/************************************
* INITIALIZATIONS
************************************/
// Set up Camera VDMA
VDMAInit(FrameBuffer);
// Set up Compositor
unsigned int threshold = 0x0CCC0FFF;
CompositorInit(FrameBuffer, DrawBuffer, DisplayBuffer, threshold);
// Initialize Buffers
FillBuffer(FrameBuffer,0x00ff0000); //black
FillBuffer(DrawBuffer,0x0); //black
FillBuffer(DisplayBuffer,0x0); //black
// Turn on Display
Display(DisplayBuffer);
/************************************
* MAIN LOOP
************************************/
while(1){
// Capture a Frame
// -We are guaranteed a single frame because Microblaze is faster than
// 30Hz, so as long as we don't sleep to early, we are guaranteed
// VDMA will write a single frame and stop, decreasing the sleep
// value more will not make a difference, may cause no frame to be written
// -If there is a compositor/VMDA race condition, use VDMAStopAndWait()
VDMAStart();
sleep(500000);
VDMAStop();
// Run Compositor
// -Super slow, need to accelerate
CompositorRun();
// LED Detection & Draw on Drawing Buffer
// -Currently this appears to give very large unchanging values
//unsigned int x = CompositorGetXPos();
//unsigned int y = CompositorGetYPos();
// find the white blobs
Vector blobList;
vector_init(&blobList);
// search region: 80 pix box at the center
OnePass(&blobList, (char*) FrameBuffer, 640/2, 480/2, 240);
// draw the found blobs
int i, avg_x, avg_y, radius;
struct Blob blob;
for (i = 0; i < blobList.size; i ++){
blob = vector_get(&blobList, i);
avg_x = blob.total_x/blob.count;
avg_y = blob.total_y/blob.count;
radius = sqrt(blob.count)/2;
//DrawSqure(avg_x, avg_y, radius, 2, (char*) DrawBuffer, 15, 15, 15);
FillColor(avg_x-radius, avg_y-radius, avg_x+radius, avg_y+radius, (char*) DrawBuffer, 0, 0, 15);
}
}
}
开发者ID:alan-y-w,项目名称:Capstone2015,代码行数:69,代码来源:main.c
注:本文中的FillBuffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论