コード例 #1
0
ファイル: CDemuxOutputPin.cpp プロジェクト: John-He-928/krkrz
//----------------------------------------------------------------------------
//! @brief	  	サンプルをダウンストリームへ送り続ける処理
//! @return		エラーコード
//----------------------------------------------------------------------------
HRESULT CDemuxOutputPin::DoBufferProcessingLoop(void)
{
	Command com;
	HRESULT	hr;
	OnThreadStartPlay();
	do {
		while( !CheckRequest(&com) ) {
			// Virtual function user will override.
			IMediaSample *pSample;
			hr = RetrieveBuffer(&pSample);
			if( hr == S_OK ) {
				hr = Deliver(pSample);
				pSample->Release();
				if(hr != S_OK)
				{
					DbgLog((LOG_TRACE, 2, TEXT("Deliver() returned %08x; stopping"), hr));
					return S_OK;
				}
			} else if (hr == S_FALSE) {
				// derived class wants us to stop pushing data
				DeliverEndOfStream();
				return S_OK;
			} else {
				// derived class encountered an error
				DbgLog((LOG_ERROR, 1, TEXT("Error %08lX from FillBuffer!!!"), hr));
				DeliverEndOfStream();
				m_pFilter->NotifyEvent(EC_ERRORABORT, hr, 0);
				return hr;
			}
		}
		if( com == CMD_RUN || com == CMD_PAUSE ) {
			Reply(NOERROR);
		} else if( com != CMD_STOP ) {
			Reply((DWORD) E_UNEXPECTED);
			DbgLog((LOG_ERROR, 1, TEXT("Unexpected command!!!")));
		}
	} while( com != CMD_STOP );

	return S_FALSE;
}
コード例 #2
0
ファイル: text_box.cpp プロジェクト: yeKcim/warmux
Widget * TextBox::ClickUp(const Point2i & mousePosition,
                          uint button)
{
  NeedRedrawing();

  if (button == SDL_BUTTON_MIDDLE) {
    std::string new_txt = GetText();
    bool        used    = RetrieveBuffer(new_txt, cursor_pos);

    if (new_txt != GetText())
      BasicSetText(new_txt);
    return used ? this : NULL;
  } else if (button == SDL_BUTTON_LEFT) {
    const std::string      cur_txt = GetText();
    const Font*            font    = Font::GetInstance(GetFontSize(), GetFontStyle());
    std::string            txt     = "";
    std::string::size_type pos     = 0;

    cursor_pos = 0;
    while (pos <= cur_txt.size() &&
           this->position.x + font->GetWidth(txt) < mousePosition.x+2) {
      cursor_pos = pos;
      while ((cur_txt[pos++] & 0xc0) == 0x80
             && pos < cur_txt.size()) { } // eat all UTF-8 characters
      txt = cur_txt.substr(0, pos);
    }

    Label::Draw(mousePosition);
    DrawCursor(position, cursor_pos);

    return this;
  }

  // Om nom nom
  return this;
}