Example #1
0
void
StencilMapCanvas::Begin()
{
  if (!buffer_drawn) {
    ClearBuffer();
    buffer_drawn = true;
  }
}
bool CFile::Truncate() {
	if (m_iFD != -1 && ftruncate(m_iFD, 0) == 0) {
		ClearBuffer();
		return true;
	}

	return false;
}
bool CFile::Seek(off_t uPos) {
	if (m_iFD != -1 && lseek(m_iFD, uPos, SEEK_SET) == uPos) {
		ClearBuffer();
		return true;
	}

	return false;
}
Example #4
0
void
MapDrawHelper::BufferRenderStart()
{
    if (!buffer_drawn) {
        ClearBuffer();
        buffer_drawn = true;
    }
}
Example #5
0
	void TGBufferCanvas::Enable()
	{
		glEnable(GL_DEPTH_TEST);
 		BindFrameBuffer(m_frameBuffer);
 		glPushAttrib(GL_VIEWPORT_BIT | GL_ENABLE_BIT);
 		ClearBuffer();
		GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT ,GL_COLOR_ATTACHMENT3_EXT};
    	glDrawBuffers(4, buffers);
	}
Example #6
0
SERIALISATION_INLINE void StreamWriter::Close()
{
    ClearBuffer();

    if (mFileStream.is_open())
    {
        mFileStream.close();
    }
}
Example #7
0
CloHttpCurl::~CloHttpCurl(void)
{
	StopTransfer();
	ClearBuffer();
	ClearParam();

	delete m_pAssoc;
	m_pAssoc = NULL;
}
Example #8
0
 ////////////////////////////////////////////////
 //
 // CStatEvents::CStatEvents
 //
 //
 //
 ////////////////////////////////////////////////
 CStatEvents::CStatEvents ( void )
     : m_bEnabled ( false )
     , m_ItemBuffer ( 0 )
     , m_BufferPos ( 0 )
     , m_BufferPosMax ( 0 )
     , m_BufferPosMaxUsing ( 0 )
 {
     ClearBuffer ( true );
 }
Example #9
0
/*******************************************************************************
 BiquadFilterInit */
BiquadFilter*
BiquadFilterInit(const float *bCoeff, const float *aCoeff)
{

    // Allocate Memory
    BiquadFilter* filter = (BiquadFilter*)malloc(sizeof(BiquadFilter));

    if (filter)
    {
        // Initialize Buffers
        CopyBuffer(filter->b, bCoeff, 3);
        CopyBuffer(filter->a, aCoeff, 2);

        ClearBuffer(filter->x, 2);
        ClearBuffer(filter->y, 2);
        ClearBuffer(filter->w, 2);
    }
    return filter;
}
Example #10
0
void CBuffer::Copy(CBuffer& buffer)
{
	int nReSize = buffer.GetMemSize();   //2048               2048
	int nSize = buffer.GetBufferLen();   //1025               0     1025
	ClearBuffer();
	if (ReAllocateBuffer(nReSize) == -1)
		return;
	CopyMemory(m_pBase,buffer.GetBuffer(),buffer.GetBufferLen());
	m_pPtr = m_pBase + nSize;
}
Example #11
0
void CFile::Close() {
	if (m_iFD >= 0) {
		if (close(m_iFD) < 0) {
			DEBUG("CFile::Close(): close() failed with ["
					<< strerror(errno) << "]");
		}
	}
	m_iFD = -1;
	ClearBuffer();
}
Example #12
0
HRESULT CMpcAudioRenderer::CreateDSBuffer()
{
	if (! m_pWaveFileFormat) return E_POINTER;

	HRESULT					hr				= S_OK;
	LPDIRECTSOUNDBUFFER		pDSBPrimary		= NULL;
	DSBUFFERDESC			dsbd;
	DSBUFFERDESC			cDSBufferDesc;
	DSBCAPS					bufferCaps;
	DWORD					dwDSBufSize		= m_pWaveFileFormat->nAvgBytesPerSec * 4;

	ZeroMemory(&bufferCaps, sizeof(bufferCaps));
	ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));

	dsbd.dwSize        = sizeof(DSBUFFERDESC);
	dsbd.dwFlags       = DSBCAPS_PRIMARYBUFFER;
	dsbd.dwBufferBytes = 0;
	dsbd.lpwfxFormat   = NULL;
	if (SUCCEEDED (hr = m_pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL )))
	{
		hr = pDSBPrimary->SetFormat(m_pWaveFileFormat);
		ATLASSERT(SUCCEEDED(hr));
		SAFE_RELEASE (pDSBPrimary);
	}


	SAFE_RELEASE (m_pDSBuffer);
	cDSBufferDesc.dwSize			= sizeof (DSBUFFERDESC);
	cDSBufferDesc.dwFlags			= DSBCAPS_GLOBALFOCUS			| 
									  DSBCAPS_GETCURRENTPOSITION2	| 
									  DSBCAPS_CTRLVOLUME 			|
									  DSBCAPS_CTRLPAN				|
									  DSBCAPS_CTRLFREQUENCY; 
	cDSBufferDesc.dwBufferBytes		= dwDSBufSize; 
	cDSBufferDesc.dwReserved		= 0; 
	cDSBufferDesc.lpwfxFormat		= m_pWaveFileFormat; 
   	cDSBufferDesc.guid3DAlgorithm	= GUID_NULL; 

	hr = m_pDS->CreateSoundBuffer (&cDSBufferDesc,  &m_pDSBuffer, NULL);

	m_nDSBufSize = 0;
	if (SUCCEEDED(hr))
	{
		bufferCaps.dwSize = sizeof(bufferCaps);
		hr = m_pDSBuffer->GetCaps(&bufferCaps);
	}
	if (SUCCEEDED (hr))
	{
		m_nDSBufSize = bufferCaps.dwBufferBytes;
		hr = ClearBuffer();
		m_pDSBuffer->SetFrequency ((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
	}

	return hr;
}
Example #13
0
 void ReadTagName(char c)
 {
     if (IsWhitespace(c))
     {
         if (buffer == "a")
             state = State::ReadTag;
         else if (buffer == "!--")
             state = State::SkipComment;
         else
             state = State::SkipTag;
         ClearBuffer();
     }
     else if (c == '>')
     {
         state = State::Default;
         ClearBuffer();
     }
     else
         StoreToLower(c);
 }
Example #14
0
void NoFile::Close()
{
    if (m_fd >= 0) {
        if (close(m_fd) < 0) {
            m_hadError = true;
            NO_DEBUG("NoFile::Close(): close() failed with [" << strerror(errno) << "]");
        }
    }
    m_fd = -1;
    ClearBuffer();
}
Example #15
0
bool Mouse::SetCoopLevel(HWND hWnd)
{
	HRESULT result = _dDevice->SetCooperativeLevel(hWnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
	if (FAILED(result))
	{
		SaveReleaseDevice();
		return false;
	}
	ClearBuffer();
	return true;
}
Example #16
0
////////////////////////////////////////////////////////////////////////////////
// 
// FUNCTION:	Copy
// 
// DESCRIPTION:	Copy from one buffer object to another...
// 
// RETURNS:	
// 
// NOTES:	
// 
// MODIFICATIONS:
// 
// Name				Date		Version		Comments
// N T ALMOND       270400		1.0			Origin
// 
////////////////////////////////////////////////////////////////////////////////
void CBuffer::Copy(CBuffer& buffer)
{
	int nReSize = buffer.GetMemSize();
	int nSize = buffer.GetBufferLen();
	ClearBuffer();
	ReAllocateBuffer(nReSize);

	m_pPtr = m_pBase + nSize;

	CopyMemory(m_pBase,buffer.GetBuffer(),buffer.GetBufferLen());
}
Example #17
0
bool CFile::Seek(off_t uPos) {
	/* This sets errno in case m_iFD == -1 */
	errno = EBADF;

	if (m_iFD != -1 && lseek(m_iFD, uPos, SEEK_SET) == uPos) {
		ClearBuffer();
		return true;
	}
	m_bHadError = true;

	return false;
}
Example #18
0
/**************************************************************************************
 * Function:    AllocateBuffers
 *
 * Description: allocate all the memory needed for the RA8 decoder
 *
 * Inputs:      none
 *
 * Outputs:     none
 *
 * Return:      pointer to Gecko2Info structure, set to all 0's
 **************************************************************************************/
Gecko2Info *AllocateBuffers(void)
{
	Gecko2Info *gi;

	/* create new Gecko2Info structure */
	gi = (Gecko2Info *)malloc(sizeof(Gecko2Info));
	if (!gi)
		return 0;
	ClearBuffer(gi, sizeof(Gecko2Info));	

	return gi;
}
Example #19
0
 void SkipAttribute(char c)
 {
     if (c == '"')
     {
         if (buffer == "\"")
         {
             state = State::ReadTag;
             ClearBuffer();
         }
         else
             Store(c);
     }
 }
Example #20
0
 void ReadTag(char c)
 {
     if (c == '=')
     {
         if (buffer == "href")
             state = State::ReadAttribute;
         else
             state = State::SkipAttribute;
         ClearBuffer();
     }
     else if (!IsWhitespace(c))
         StoreToLower(c);
 }
Example #21
0
TEST(DSPSingle, TestStrideCopy)
{
    float out[10];
    float in1[5] = {1.,2.,3.,4.,5.};
    float in2[10] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
    float ex1[10] = {1., 0., 2., 0., 3., 0., 4., 0., 5., 0.};
    float ex2[5] = {1., 3., 5., 7., 9.};
    
    ClearBuffer(out, 10);
    CopyBufferStride(out, 2, in1, 1, 5);
    for (unsigned i = 0; i < 10; ++i)
    {
        ASSERT_FLOAT_EQ(ex1[i], out[i]);
    }
    
    ClearBuffer(out, 10);
    CopyBufferStride(out, 1, in2, 2, 5);
    for (unsigned i = 0; i < 5; ++i)
    {
        ASSERT_FLOAT_EQ(ex2[i], out[i]);
    }
}
Example #22
0
void FramebufferManagerCommon::Init() {
	const std::string gameId = g_paramSFO.GetValueString("DISC_ID");
	// This applies a hack to Dangan Ronpa, its demo, and its sequel.
	// The game draws solid colors to a small framebuffer, and then reads this directly in VRAM.
	// We force this framebuffer to 1x and force download it automatically.
	hackForce04154000Download_ = gameId == "NPJH50631" || gameId == "NPJH50372" || gameId == "NPJH90164" || gameId == "NPJH50515";

	// And an initial clear. We don't clear per frame as the games are supposed to handle that
	// by themselves.
	ClearBuffer();

	BeginFrame();
}
Example #23
0
TEST(DSPSingle, TestClearBuffer)
{
    float out[10];
    for (unsigned i = 0; i < 10; ++i)
    {
        out[i] = i;
    }
    ClearBuffer(out, 10);
    for (unsigned i = 0; i < 10; ++i)
    {
        ASSERT_FLOAT_EQ(0.0, out[i]);
    }
}
Example #24
0
bool CFile::Truncate() {
	/* This sets errno in case m_iFD == -1 */
	errno = EBADF;

	if (m_iFD != -1 && ftruncate(m_iFD, 0) == 0) {
		ClearBuffer();
		return true;
	}

	m_bHadError = true;

	return false;
}
Example #25
0
File: Tape.c Project: eriser/FxDSP
/*******************************************************************************
 Set Speed */
Error_t
TapeSetSpeed(Tape* tape, TapeSpeed speed)
{
    
    if (tape)
    {
        // Set speed
        tape->speed = speed;
        
        // Update saturation curve
        PolySaturatorSetN(tape->polysat, calculate_n(tape->saturation, speed));
        
        // Clear old flutter/wow modulation waveform
        ClearBuffer(tape->flutter_mod, tape->flutter_mod_length); // Yes, clear the old length...
        
        // Calculate new modulation waveform length...
        tape->flutter_mod_length = (unsigned)(tape->sample_rate / \
                                              (0.80 * powf(2.0, (float)speed)));
        
        // Generate flutter/wow modulation waveform
        float temp_buffer[tape->flutter_mod_length];
        for (unsigned comp = 0; comp < N_FLUTTER_COMPONENTS; ++comp)
        {
            float phase_step = (2.0 * M_PI * comp * powf(2.0, (float)speed)) / tape->sample_rate;
            ClearBuffer(temp_buffer, tape->flutter_mod_length);
            for (unsigned i = 0; i < tape->flutter_mod_length; ++i)
            {
                temp_buffer[i] = sinf(i * phase_step) / N_FLUTTER_COMPONENTS;
            }
            VectorVectorAdd(tape->flutter_mod, tape->flutter_mod,
                            temp_buffer, tape->flutter_mod_length);
        }
        return NOERR;;
    }
    else
    {
        return NULL_PTR_ERROR;
    }
}
Example #26
0
bool NoFile::Seek(off_t pos)
{
    /* This sets errno in case m_iFD == -1 */
    errno = EBADF;

    if (m_fd != -1 && lseek(m_fd, pos, SEEK_SET) == pos) {
        ClearBuffer();
        return true;
    }
    m_hadError = true;

    return false;
}
Example #27
0
STDMETHODIMP CMpcAudioRenderer::Run(REFERENCE_TIME tStart)
{
    HRESULT		hr;

    if (m_State == State_Running) {
        return NOERROR;
    }

    if (m_useWASAPI) {
        hr=CheckAudioClient(m_pWaveFileFormat);
        if (FAILED(hr)) {
            TRACE(_T("CMpcAudioRenderer::Run Error on check audio client\n"));
            return hr;
        }
        // Rather start the client at the last moment when the buffer is fed
        /*hr = pAudioClient->Start();
        if (FAILED (hr))
        {
        TRACE(_T("CMpcAudioRenderer::Run Start error"));
        return hr;
        }*/
    } else {
        if (m_pDSBuffer &&
                m_pPosition &&
                m_pWaveFileFormat &&
                SUCCEEDED(m_pPosition->GetRate(&m_dRate))) {
            if (m_dRate < 1.0) {
                hr = m_pDSBuffer->SetFrequency ((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
                if (FAILED (hr)) {
                    return hr;
                }
            } else {
                hr = m_pDSBuffer->SetFrequency ((long)m_pWaveFileFormat->nSamplesPerSec);
                m_pSoundTouch->setRateChange((float)(m_dRate-1.0)*100);

                if (m_bMuteFastForward) {
                    if (m_dRate == 1.0) {
                        m_pDSBuffer->SetVolume(m_lVolume);
                    } else {
                        m_pDSBuffer->SetVolume(DSBVOLUME_MIN);
                    }
                }
            }
        }

        ClearBuffer();
    }
    hr = CBaseRenderer::Run(tStart);

    return hr;
}
Example #28
0
void CChan::SendBuffer(CClient* pClient) {
	if (m_pNetwork && m_pNetwork->IsUserAttached()) {
		// in the event that pClient is NULL, need to send this to all clients for the user
		// I'm presuming here that pClient is listed inside vClients thus vClients at this
		// point can't be empty.
		//
		// This loop has to be cycled twice to maintain the existing behavior which is
		// 1. OnChanBufferStarting
		// 2. OnChanBufferPlayLine
		// 3. ClearBuffer() if not keeping the buffer
		// 4. OnChanBufferEnding
		//
		// With the exception of ClearBuffer(), this needs to happen per client, and
		// if pClient is not NULL, the loops break after the first iteration.
		//
		// Rework this if you like ...
		if (!m_Buffer.IsEmpty()) {
			const vector<CClient*> & vClients = m_pNetwork->GetClients();
			for (size_t uClient = 0; uClient < vClients.size(); ++uClient) {
				CClient * pUseClient = (pClient ? pClient : vClients[uClient]);

				bool bSkipStatusMsg = false;
				NETWORKMODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true);

				if (!bSkipStatusMsg) {
					m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Buffer Playback...", pUseClient);
				}

				unsigned int uSize = m_Buffer.Size();
				for (unsigned int uIdx = 0; uIdx < uSize; uIdx++) {
					CString sLine = m_Buffer.GetLine(uIdx, *pUseClient);
					NETWORKMODULECALL(OnChanBufferPlayLine(*this, *pUseClient, sLine), m_pNetwork->GetUser(), m_pNetwork, NULL, continue);
					m_pNetwork->PutUser(sLine, pUseClient);
				}

				bSkipStatusMsg = false;
				NETWORKMODULECALL(OnChanBufferEnding(*this, *pUseClient), m_pNetwork->GetUser(), m_pNetwork, NULL, bSkipStatusMsg = true);
				if (!bSkipStatusMsg) {
					m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() + " :Playback Complete.", pUseClient);
				}

				if (pClient)
					break;
			}

			if (!KeepBuffer()) {
 				ClearBuffer();
			}
		}
	}
}
Example #29
0
/**************************************************************************************
 * Function:    AllocateBuffers
 *
 * Description: allocate all the memory needed for the MP3 decoder
 *
 * Inputs:      none
 *
 * Outputs:     none
 *
 * Return:      pointer to MP3DecInfo structure (initialized with pointers to all 
 *                the internal buffers needed for decoding, all other members of 
 *                MP3DecInfo structure set to 0)
 *
 * Notes:       if one or more mallocs fail, function frees any buffers already
 *                allocated before returning
 **************************************************************************************/
MP3DecInfo *AllocateBuffers(void)
{
	MP3DecInfo *mp3DecInfo;
	FrameHeader *fh;
	SideInfo *si;
	ScaleFactorInfo *sfi;
	HuffmanInfo *hi;
	DequantInfo *di;
	IMDCTInfo *mi;
	SubbandInfo *sbi;

	mp3DecInfo = (MP3DecInfo *)malloc(sizeof(MP3DecInfo));
	if (!mp3DecInfo)
		return 0;
	ClearBuffer(mp3DecInfo, sizeof(MP3DecInfo));
	
	fh =  (FrameHeader *)     malloc(sizeof(FrameHeader));
	si =  (SideInfo *)        malloc(sizeof(SideInfo));
	sfi = (ScaleFactorInfo *) malloc(sizeof(ScaleFactorInfo));
	hi =  (HuffmanInfo *)     malloc(sizeof(HuffmanInfo));
	di =  (DequantInfo *)     malloc(sizeof(DequantInfo));
	mi =  (IMDCTInfo *)       malloc(sizeof(IMDCTInfo));
	sbi = (SubbandInfo *)     malloc(sizeof(SubbandInfo));

	mp3DecInfo->FrameHeaderPS =     (void *)fh;
	mp3DecInfo->SideInfoPS =        (void *)si;
	mp3DecInfo->ScaleFactorInfoPS = (void *)sfi;
	mp3DecInfo->HuffmanInfoPS =     (void *)hi;
	mp3DecInfo->DequantInfoPS =     (void *)di;
	mp3DecInfo->IMDCTInfoPS =       (void *)mi;
	mp3DecInfo->SubbandInfoPS =     (void *)sbi;

	if (!fh || !si || !sfi || !hi || !di || !mi || !sbi) {
		FreeBuffers(mp3DecInfo);	/* safe to call - only frees memory that was successfully allocated */
		return 0;
	}

	/* important to do this - DSP primitives assume a bunch of state variables are 0 on first use */
	ClearBuffer(fh,  sizeof(FrameHeader));
	ClearBuffer(si,  sizeof(SideInfo));
	ClearBuffer(sfi, sizeof(ScaleFactorInfo));
	ClearBuffer(hi,  sizeof(HuffmanInfo));
	ClearBuffer(di,  sizeof(DequantInfo));
	ClearBuffer(mi,  sizeof(IMDCTInfo));
	ClearBuffer(sbi, sizeof(SubbandInfo));

	return mp3DecInfo;
}
Example #30
0
void crtaj_polje(tetris_data *data)
{
	int i, j;

	ClearBuffer(data);

	for(i = 0; i < VPOLJA+1; i++)
		for(j = 0; j < SPOLJA+1; j++)
			if(data->polje[i+1][j+1])
			{
				BitBlt(data->hdcBuffer, j*VELBLOKA, i*VELBLOKA, VELBLOKA, VELBLOKA, data->hdcFigure, data->polje[i+1][j+1]*VELBLOKA, VELBLOKA, SRCAND);
				BitBlt(data->hdcBuffer, j*VELBLOKA, i*VELBLOKA, VELBLOKA, VELBLOKA, data->hdcFigure, data->polje[i+1][j+1]*VELBLOKA, 0, SRCPAINT);
			}
}