Пример #1
0
void NewBuildTab::OnBuildEnded(clCommandEvent& e)
{
    e.Skip();
    CL_DEBUG("Build Ended!");
    m_buildInProgress = false;

    DoProcessOutput(true, false);

    std::vector<LEditor*> editors;
    clMainFrame::Get()->GetMainBook()->GetAllEditors(editors, MainBook::kGetAll_Default);
    for(size_t i = 0; i < editors.size(); i++) {
        MarkEditor(editors.at(i));
    }

    // Add a summary line
    wxString problemcount =
        wxString::Format(wxT("%d %s, %d %s"), m_errorCount, _("errors"), m_warnCount, _("warnings"));
    wxString term = problemcount;
    long elapsed = m_sw.Time() / 1000;
    if(elapsed > 10) {
        long sec = elapsed % 60;
        long hours = elapsed / 3600;
        long minutes = (elapsed % 3600) / 60;
        term << wxString::Format(wxT(", %s: %02ld:%02ld:%02ld %s"), _("total time"), hours, minutes, sec, _("seconds"));
    }

    m_output = term;
    DoProcessOutput(true, true);

    if(m_buildInterrupted) {
        wxString InterruptedMsg;
        InterruptedMsg << _("(Build Cancelled)") << wxT("\n\n");
        m_output = InterruptedMsg;
        DoProcessOutput(true, false);
    }

    // Hide / Show the build tab according to the settings
    DoToggleWindow();

    // make it invalid
    m_curError = m_errorsAndWarningsList.begin();
    CL_DEBUG("Posting wxEVT_BUILD_ENDED event");

    // notify the plugins that the build has ended
    clBuildEvent buildEvent(wxEVT_BUILD_ENDED);
    buildEvent.SetErrorCount(m_errorCount);
    buildEvent.SetWarningCount(m_warnCount);
    EventNotifier::Get()->AddPendingEvent(buildEvent);
}
Пример #2
0
STDMETHODIMP CDelay::Process(ULONG ulSize, BYTE *pData, REFERENCE_TIME refTimeStart, DWORD dwFlags)
{
    if (dwFlags &= ~DMO_INPLACE_ZERO)
        return E_INVALIDARG;

    if (!pData) 
    {
        return E_POINTER;
    }


	ATLTRACE2(atlTraceGeneral, 3, "Process: %d bytes. Time stamp: %f\n", 
		ulSize, RefTime2Double(refTimeStart));



    LockIt lock(this);
    
    if (!InputTypeSet(0) || !OutputTypeSet(0)) 
    {
        return DMO_E_TYPE_NOT_SET;
    }
    
    //  Make sure all streams have media types set and resources are allocated
    HRESULT hr = AllocateStreamingResources();
    
	if (SUCCEEDED(hr))
		hr = DoProcessOutput(pData, pData, ulSize / m_pWave->nBlockAlign);

	return hr;

    // If this DMO supported an effect tail, it would return S_FALSE until 
    // the tail was processed. See IMediaObjectInPlace::Process documentation.
}
void DecoderMF::DecoderThread()
{
	while (m_decoderThreadRunning)
	{
		bool haveMoreInput = false;
		IBMDStreamingH264NALPacket* inputNal = NULL;

		EnterCriticalSection(&m_criticalSection);

			// If we've got data in the queue, grab it
			if ( !m_nalQueue.empty())
			{
				inputNal = m_nalQueue.front();
				m_nalQueue.pop_front();

				// And update haveMoreInput so we don't sleep if there's more
				// data to process
				haveMoreInput = ! m_nalQueue.empty();
			}

		LeaveCriticalSection(&m_criticalSection);

		if (inputNal != NULL)
		{
			// Process the input NAL
			if (! DoProcessInputNAL(inputNal))
			{
				OutputDebugString(_T("ERROR: failed to process input NAL\n"));
			}

			// Release it:
			inputNal->Release();
		}

		// Now process any output that may have been generated. (once we've
		// processed all input)
		if (! haveMoreInput)
		{
			if (! DoProcessOutput())
			{
				OutputDebugString(_T("ERROR: failed to process output from MF decoder\n"));
			}
		}

		if (! haveMoreInput)
			WaitForSingleObject(m_decoderThreadEvent, INFINITE);
	}

	return;
}
// Process the incomming NAL from the queue: wraps it up into a
// IMFMediaSample, sends it to the decoder.
//
// Thread context: decoder thread
bool DecoderMF::DoProcessInputNAL(IBMDStreamingH264NALPacket* nalPacket)
{
	bool				ret = false;
	HRESULT				hr;
	IMFMediaBuffer*		newBuffer = NULL;
	BYTE*				newBufferPtr;
	void*				nalPacketPtr;
	//
	IMFSample*			newSample = NULL;
	ULONGLONG			nalPresentationTime;
	const BYTE			nalPrefix[] = {0, 0, 0, 1};

	// Get a pointer to the NAL data
	hr = nalPacket->GetBytes(&nalPacketPtr);
	if (FAILED(hr))
		goto bail;

	// Create the MF media buffer (+ 4 bytes for the NAL Prefix (0x00 0x00 0x00 0x01)
	// which MF requires.
	hr = MFCreateMemoryBuffer(nalPacket->GetPayloadSize()+4, &newBuffer);
	if (FAILED(hr))
		goto bail;

	// Lock the MF media buffer
	hr = newBuffer->Lock(&newBufferPtr, NULL, NULL);
	if (FAILED(hr))
		goto bail;

	// Copy the prefix and the data
	memcpy(newBufferPtr, nalPrefix, 4);
	memcpy(newBufferPtr+4, nalPacketPtr, nalPacket->GetPayloadSize());

	// Unlock the MF media buffer
	hr = newBuffer->Unlock();
	if (FAILED(hr))
		goto bail;

	// Update the current length of the MF media buffer
	hr = newBuffer->SetCurrentLength(nalPacket->GetPayloadSize()+4);
	if (FAILED(hr))
		goto bail;

	// We now have a IMFMediaBuffer with the contents of the NAL
	// packet. We now construct a IMFSample with the buffer
	hr = MFCreateSample(&newSample);
	if (FAILED(hr))
		goto bail;

	hr = newSample->AddBuffer(newBuffer);
	if (FAILED(hr))
		goto bail;

	// Get the presentation (display) time in 100-nanosecond units
	// TODO: this is pretty meaningless without setting the start time.
	hr = nalPacket->GetDisplayTime(1000 * 1000 * 10, &nalPresentationTime);
	if (FAILED(hr))
		goto bail;

	// Set presentation time on the sample
	hr = newSample->SetSampleTime(nalPresentationTime);
	if (FAILED(hr))
		goto bail;

	// Now parse it to the decoder
	for (;;)
	{
		hr = m_h264Decoder->ProcessInput(0, newSample, 0);
		if (hr == S_OK)
			break;
		if (hr != MF_E_NOTACCEPTING || DoProcessOutput() == false)
			goto bail;
	}

	ret = true;

bail:
	if (newBuffer != NULL)
		newBuffer->Release();

	if (newSample != NULL)
		newSample->Release();

	return ret;
}
Пример #5
0
void NewBuildTab::OnBuildAddLine(clCommandEvent& e)
{
    e.Skip(); // Allways call skip..
    m_output << e.GetString();
    DoProcessOutput(false, false);
}
Пример #6
0
void NewBuildTab::AppendLine(const wxString& text)
{
    m_output << text;
    DoProcessOutput(false, false);
}
Пример #7
0
HRESULT CDelay::InternalProcessOutput(DWORD dwFlags, DWORD cOutputBufferCount,
                                           DMO_OUTPUT_DATA_BUFFER *pOutputBuffers,
                                           DWORD *pdwStatus)
{
    BYTE    *pbData;
    DWORD   cbData;
    DWORD   cbOutputLength;
    DWORD   cbBytesProcessed;

    CComPtr<IMediaBuffer> pOutputBuffer = pOutputBuffers[0].pBuffer;

    if (!m_pBuffer || !pOutputBuffer)
    {
        return S_FALSE;  // Did not produce output
    }


    // Get the size of our output buffer
    HRESULT hr = pOutputBuffer->GetBufferAndLength(&pbData, &cbData);
    
    hr = pOutputBuffer->GetMaxLength(&cbOutputLength);
    if (FAILED(hr))
    {
        return hr;
    }
    
    // Skip past any valid data in the output buffer
    pbData += cbData;
    cbOutputLength -= cbData;

    if (cbOutputLength < m_pWave->nBlockAlign)
    {
        return E_FAIL;
    }
    
    // Calculate how many quanta we can process
    bool    bComplete = false;

    if (m_cbInputLength > cbOutputLength)
    {
        cbBytesProcessed = cbOutputLength;
    }
    else
    {
        cbBytesProcessed = m_cbInputLength;
        bComplete = true;
    }

    DWORD dwQuanta = cbBytesProcessed / m_pWave->nBlockAlign;

    // The actual data we write may be less than the available buffer length 
    // due to the block alignment.
    cbBytesProcessed = dwQuanta * m_pWave->nBlockAlign;
    
    hr = DoProcessOutput(pbData, m_pbInputData, dwQuanta);
    if (FAILED(hr))
    {
        return hr;
    }
    
    hr = pOutputBuffer->SetLength(cbBytesProcessed + cbData);

	ATLTRACE2(atlTraceGeneral, 3, "Process Output: %d bytes.\n", cbBytesProcessed);

    if (m_bValidTime)
    {
        pOutputBuffers[0].dwStatus |= DMO_OUTPUT_DATA_BUFFERF_TIME;
        pOutputBuffers[0].rtTimestamp = m_rtTimestamp;
        
        // Etimate how far along we are...
        pOutputBuffers[0].dwStatus |= DMO_OUTPUT_DATA_BUFFERF_TIMELENGTH;
        pOutputBuffers[0].rtTimelength = (cbBytesProcessed / m_pWave->nAvgBytesPerSec) * UNITS;

		ATLTRACE2(atlTraceGeneral, 3, "\tTimestamp: %f/%f\n", cbBytesProcessed,
				RefTime2Double(pOutputBuffers[0].rtTimestamp), 
				RefTime2Double(pOutputBuffers[0].rtTimelength));

    }

    if (bComplete)
    {
        m_pBuffer = NULL;   // Release input buffer

		ATLTRACE2(atlTraceGeneral, 3, "\tProcessOutput Complete\n");
	}
    else 
    {
        pOutputBuffers[0].dwStatus |= DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE;
        m_cbInputLength -= cbBytesProcessed;
        m_pbInputData += cbBytesProcessed;
        m_rtTimestamp += pOutputBuffers[0].rtTimelength;

		ATLTRACE2(atlTraceGeneral, 3, "\tBytes remaining:\n", m_cbInputLength);
    }

    return S_OK;
}