コード例 #1
0
ファイル: cycle.c プロジェクト: 0xheart0/vlc
static int Send(sout_stream_t *stream, sout_stream_id_sys_t *id,
                block_t *block)
{
    sout_stream_sys_t *sys = stream->p_sys;

    for (block_t *next = block->p_next; block != NULL; block = next)
    {
        block->p_next = NULL;

        /* FIXME: deal with key frames properly */
        while (sys->clock(block) >= sys->next->offset)
        {
            DelStream(stream);
            AddStream(stream, sys->next->chain);

            sys->next->offset += sys->period;
            sys->next = sys->next->next;
            if (sys->next == NULL)
                sys->next = sys->start;
        }

        if (sys->stream != NULL)
            sout_StreamIdSend(sys->stream, id->id, block);
        else
            block_Release(block);
    }
    return VLC_SUCCESS;
}
コード例 #2
0
ファイル: graphic.c プロジェクト: mingpen/OpenNT
/*** delarg - deletes current selected area
*
* Purpose:
*   <graphic> and <quote> delete previously selected text. Here we do it
*
* Input:
*   pArg    pointer to current ARG structure
*
* Output:
*   None
*
* Notes:
*
*************************************************************************/
void
delarg (
    ARG * pArg
    )
{
    fl      fl;

    switch (pArg->argType) {

	case STREAMARG:
	    DelStream (pFileHead,
		       pArg->arg.streamarg.xStart, pArg->arg.streamarg.yStart,
		       pArg->arg.streamarg.xEnd,   pArg->arg.streamarg.yEnd   );
	    fl.col = pArg->arg.streamarg.xStart;
	    fl.lin = pArg->arg.streamarg.yStart;
            break;

	case LINEARG:
	    DelLine (TRUE, pFileHead,
		     pArg->arg.linearg.yStart, pArg->arg.linearg.yEnd);
	    fl.col = 0;
	    fl.lin = pArg->arg.linearg.yStart;
            break;

	case BOXARG:
	    DelBox (pFileHead,
		       pArg->arg.boxarg.xLeft,  pArg->arg.boxarg.yTop,
		       pArg->arg.boxarg.xRight, pArg->arg.boxarg.yBottom);
	    fl.col = pArg->arg.boxarg.xLeft;
	    fl.lin = pArg->arg.boxarg.yTop;
	    break;

	default:
	    return;
    }
    cursorfl(fl);
}
コード例 #3
0
ファイル: cdelete.c プロジェクト: mingpen/OpenNT
/*** DoCDelete - perform character deletion
*
*  Delete the character at the current cursor location
*
* Input:
*  fEmacs	- EMACs type delete flag
*
* Output:
*  Returns TRUE on deletion
*
*************************************************************************/
flagType
DoCDelete (
    flagType fEmacs
    ) {

    fl      fl;                             /* file loc to position at      */
    int     x;
    char    *p;
    linebuf tempbuf;
    struct lineAttr rgla[sizeof(linebuf)];
    flagType fColor;

    fl.col = XCUR(pInsCur);
    fl.lin = YCUR(pInsCur);
    /*
     * xCursor is zero. If yCursor is also zero (top of file), we can't move
     * back, so nothing to delete. Otherwise, move to end of previous line, and
     * if emacs & insert mode, join the lines.
     */
    if (fl.col == 0) {
        if (fl.lin == 0) {
            return FALSE;
        } else {
            fl.lin--;
            fl.col = LineLength (fl.lin, pFileHead);
            if (fInsert && fEmacs) {
                DelStream (pFileHead, fl.col, fl.lin, 0, fl.lin + 1);
            }
        }
    } else {
        /*
         * column is non-zero, so back it up one.
         */
        GetLine (fl.lin, tempbuf, pFileHead);
        x = cbLog (tempbuf);
        fl.col = DecCol (fl.col, tempbuf);
        /*
         * we're in the middle of a line. If in insert mode, back up the cursor, and
         * delete the character there.
         */
        if (fInsert) {
            DelBox (pFileHead, fl.col, fl.lin, fl.col, fl.lin);
        } else {
            /*
             * we're in the middle of a line, but not insert mode. Get the text of the
             * line & pointer to character.
             */
            p = pLog (tempbuf, fl.col, TRUE);
            /*
             * If emacs, and we're actually IN text, then replace the character with a
             * space.
             */
            if (fEmacs) {
                if (fl.col+1 <= x && *p != ' ') {
                    *p = ' ';
                    // SetColor (pFileHead, fl.lin, fl.col, 1, fgColor);
                    PutLine (fl.lin, tempbuf, pFileHead);
                }
            }
            /*
             * if we're beyond the end of the line, just position to the end of the line.
             */
            else if (fl.col+1 > x) {
                fl.col = x;
            }
            /*
             * if the first non-blank character is PAST the current position, then just
             * position at the begining of the line.
             */
            else if ((colPhys (tempbuf, whiteskip (tempbuf)) > fl.col)) {
                fl.col = 0;
            }
            /*
             * finaly, when all else fails, back up, and replace the character under the
             * cursor with a space.
             */
            else if (*p != ' ') {
                *pLog (tempbuf,fl.col,TRUE) = ' ';
                if (fColor = GetColor (fl.lin, rgla, pFileHead)) {
                    ShiftColor (rgla, fl.col, -1);
                    ColorToLog (rgla, buf);
                }
                PutLine (fl.lin, tempbuf, pFileHead);
                if (fColor) {
                    PutColor (fl.lin, rgla, pFileHead);
                }
            }
        }
    }
    cursorfl (fl);

    return TRUE;
}
コード例 #4
0
void CKEventThread::ThreadProcMain(void)
{
	if( Init() )
	{
		while( !m_bWantStop )
		{
			// Figure out how long we can remain in poll/WFMO, possibly forever
			waittimer_t nTimeout = INFTIM;
			if( m_nTimers )
			{
				assert( m_ppTimers[1] );
				nTimeout = m_ppTimers[1]->GetTimeout() - CKTimer::CurrentTime();
				if( nTimeout < 0 || nTimeout > 0x7FFFFFFF ) nTimeout = 0; // Wrap - it's late
			}

#ifdef _UNIX
			int rc = poll( m_pWaitObjs, m_nSocks, nTimeout );
			if( rc < 0 )
			{
				dbgout( "poll() failed: error = %i (%s)", errno, strerror(errno) );
				break;
			}
#endif
#ifdef _WIN32
			DWORD rc = ::WaitForMultipleObjects( m_nSocks, m_pWaitObjs, FALSE, nTimeout );
			if( rc == WAIT_FAILED )
			{
				dbgout( "WFMO failed: error = %u", ::GetLastError() );
				break;
			}
			rc = (rc == WAIT_TIMEOUT) ? 0 : 1;
#endif

			if( rc == 0 && m_nTimers )
			{
				assert( m_nTimers && m_nTimerAlloc >= 2 && m_ppTimers[1] );
				CKTimer* pTimer = m_ppTimers[1];
				if( pTimer->GetMode() == CKTimer::Repeating )
				{
					pTimer->m_next += pTimer->m_interval;
				}
				else
				{
					pTimer->m_mode = CKTimer::Disabled;
					m_ppTimers[1] = m_ppTimers[m_nTimers--];
				}
				Heapify( CKTimer::CurrentTime(), 1 );
				pTimer->GetResponse()->OnTimer();
			}
			if( rc > 0 )
			{
				UINT n;
				for( n = 0; n < m_nSocks; n++ )
				{
					assert( WAITOBJ_IS_VALID( m_pWaitObjs[n] ) && NULL != m_ppSocks[n] );

					int err = SOCKERR_NONE;
					waitevents_t wevt;
					CKSocket* pSock = m_ppSocks[n];

#ifdef _UNIX
					wevt = m_pWaitObjs[n].revents;
					if( (wevt & (POLLIN|POLLERR)) && (pSock->m_uSelectFlags & SF_ACCEPT) == SF_ACCEPT )
					{
						wevt = XPOLLACC;
					}
					if( (wevt & (POLLOUT|POLLERR)) && (pSock->m_uSelectFlags & SF_CONNECT) == SF_CONNECT )
					{
						socklen_t errlen = sizeof(err);
#if defined(_SOLARIS) && (_SOLARIS < 58)
						getsockopt( pSock->GetHandle(), SOL_SOCKET, SO_ERROR, (char*)&err, &errlen );
#else
						getsockopt( pSock->GetHandle(), SOL_SOCKET, SO_ERROR, &err, &errlen );
#endif
						wevt = XPOLLCNX;
					}
					if( (wevt & POLLERR) )
					{
						wevt = pSock->m_uSelectFlags;
					}
#endif
#ifdef _WIN32
					::WSAEnumNetworkEvents( pSock->GetHandle(), m_pWaitObjs[n], &wevt );
					if( wevt.lNetworkEvents & FD_CONNECT )
					{
						err = wevt.iErrorCode[FD_CONNECT_BIT];
					}
					if( wevt.lNetworkEvents & FD_CLOSE )
					{
						wevt.lNetworkEvents = FD_READ;
						DelStream( pSock );
						pSock->GetNotify()->OnClosed();
					}
#endif
					if( WAIT_EVENT_READ( wevt ) )
					{
						pSock->GetNotify()->OnReadReady();
					}
					else if( WAIT_EVENT_WRITE( wevt ) )
					{
						pSock->GetNotify()->OnWriteReady();
					}
					else if( WAIT_EVENT_ACCEPT( wevt ) )
					{
						CKListenSocket* pListen = (CKListenSocket*)pSock;
						sockaddr_in sa;
						socklen_t salen = sizeof(sa);
						sockobj_t sock = accept( pListen->GetHandle(), (sockaddr*)&sa, &salen );
						if( INVALID_SOCKET != sock )
						{
#ifdef _WIN32
							// Cancel selections (they are inherited in Win32)
							::WSAEventSelect( sock, 0, 0 );
#endif
							CKTcpSocket* pNew = new CKTcpSocket();
							pNew->m_sock = sock;
							pListen->m_pAcceptNotify->OnConnection( pNew );
						}
					}
					else if( WAIT_EVENT_CONNECT( wevt ) )
					{
						pSock->GetNotify()->OnConnectDone( err );
					}
					else if( WAIT_EVENT_EXCEPT( wevt ) )
					{
						pSock->GetNotify()->OnExceptReady();
					}
				}
			}
		}
	}
	Exit();
}