• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LOGF函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LOGF函数的典型用法代码示例。如果您正苦于以下问题:C++ LOGF函数的具体用法?C++ LOGF怎么用?C++ LOGF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LOGF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: on_connect

void on_connect (uv_stream_t* server_handle, int status)
{
	CHECK (status, "connect");

	int r;

	assert ( (uv_tcp_t*) server_handle == &server);

	client_t* client = malloc (sizeof (client_t) );
	client->request_num = request_num;

	LOGF ("[ %5d ] new connection", request_num++);

	uv_tcp_init (uv_loop, &client->handle);
	http_parser_init (&client->parser, HTTP_REQUEST);

	client->parser.data = client;
	client->handle.data = client;

	r = uv_accept (server_handle, (uv_stream_t*) &client->handle);
	CHECK (r, "accept");

	uv_read_start ( (uv_stream_t*) &client->handle, on_alloc, on_read);
}
开发者ID:abenromdhane,项目名称:Recommender,代码行数:24,代码来源:webserver.c


示例2: VBoxMPMapVideoMemory

/* Called for IOCTL_VIDEO_MAP_VIDEO_MEMORY.
 * Maps FrameBuffer and video RAM to a caller's virtual adress space.
 */
BOOLEAN VBoxMPMapVideoMemory(PVBOXMP_DEVEXT pExt, PVIDEO_MEMORY pRequestedAddress,
                             PVIDEO_MEMORY_INFORMATION pMapInfo, PSTATUS_BLOCK pStatus)
{
    PHYSICAL_ADDRESS framebuffer;
    ULONG inIoSpace = 0;

    LOGF(("framebuffer offset %#x", pExt->ulFrameBufferOffset));

    framebuffer.QuadPart = VBoxCommonFromDeviceExt(pExt)->phVRAM.QuadPart + pExt->ulFrameBufferOffset;

    pMapInfo->VideoRamBase = pRequestedAddress->RequestedVirtualAddress;
    VBOXMPIOCTL_HIDE(pRequestedAddress);
    pMapInfo->VideoRamLength = pExt->pPrimary->u.primary.ulMaxFrameBufferSize;

    pStatus->Status = VideoPortMapMemory(pExt, framebuffer, &pMapInfo->VideoRamLength,
                                         &inIoSpace, &pMapInfo->VideoRamBase);

    if (NO_ERROR == pStatus->Status)
    {
        pMapInfo->FrameBufferBase = (PUCHAR)pMapInfo->VideoRamBase;
        pMapInfo->FrameBufferLength =
            VBoxMPXpdmCurrentVideoMode(pExt)->VisScreenHeight*
            VBoxMPXpdmCurrentVideoMode(pExt)->ScreenStride;

        pStatus->Information = sizeof(VIDEO_MEMORY_INFORMATION);

        /* Save the new framebuffer size */
        pExt->ulFrameBufferSize = pMapInfo->FrameBufferLength;
        HGSMIAreaInitialize(&pExt->areaDisplay, pMapInfo->FrameBufferBase,
                            pMapInfo->FrameBufferLength, pExt->ulFrameBufferOffset);
    }

    VBOXMPIOCTL_UNHIDE();
    LOGF_LEAVE();
    return NO_ERROR == pStatus->Status;
}
开发者ID:etiago,项目名称:vbox,代码行数:39,代码来源:VBoxMPIOCTL.cpp


示例3: repeat_1_cb

static void repeat_1_cb(uv_timer_t* handle, int status) {
  int r;

  ASSERT(handle == &repeat_1);
  ASSERT(status == 0);

  ASSERT(uv_timer_get_repeat((uv_timer_t*)handle) == 50);

  LOGF("repeat_1_cb called after %ld ms\n",
      (long int)(uv_now(uv_default_loop()) - start_time));

  repeat_1_cb_called++;

  r = uv_timer_again(&repeat_2);
  ASSERT(r == 0);

  if (uv_now(uv_default_loop()) >= start_time + 500) {
    uv_close((uv_handle_t*)handle, close_cb);
    /* We're not calling uv_timer_again on repeat_2 any more, so after this */
    /* timer_2_cb is expected. */
    repeat_2_cb_allowed = 1;
    return;
  }
}
开发者ID:4rejin,项目名称:node,代码行数:24,代码来源:test-timer-again.c


示例4: test_peer_does_not_have

void test_peer_does_not_have (void *context, void *peer_context, void *key_context, const sync_key_t *key){
  struct test_peer *state = (struct test_peer *)context;
  struct test_peer *peer = (struct test_peer *)peer_context;
  struct test_key *test_key = (struct test_key *)key_context;
  
  LOGF("%s - %s does not have %s that we need to send", 
    state->name, peer->name, alloca_sync_key(key));
  
  assert(sync_key_exists(state->state, key)==1);
  assert(sync_key_exists(peer->state, key)==0);
  assert(test_key->initial_peer);
  
  struct test_transfer *transfer = allocate(sizeof(struct test_transfer));
  transfer->src = state;
  transfer->dest = peer;
  transfer->key = test_key;
  transfer->delay_till = packets_sent + 10;
  if (transfer_tail){
    transfer_tail->next = transfer;
  }else{
    transfer_head = transfer;
  }
  transfer_tail = transfer;
}
开发者ID:lakeman,项目名称:sync,代码行数:24,代码来源:test_sync.c


示例5: getchar

/* Ugly tokenizer :3 */
char *token() {
	char c;
	c = getchar();
	while ((c != EOF) && (strchr(skip_chars, c) != NULL)) {
		c = getchar();
		if (c == '#') {
			while ((c != EOF) && (c != '\n'))
				c = getchar();
			LOGF("skip comment to EOL");
		}
	}
	if (c == EOF)
		return NULL;

	char buf[256], *cur = buf;
	while ((c != EOF) && (strchr(skip_chars, c) == NULL)) {
		*(cur++) = c;
		c = getchar();
	}
	*cur = 0;
	//LOGF("token=%s", buf);
	// you should care about freeing memory :3
	return strdup(buf);
}
开发者ID:lexszero,项目名称:jitsynth,代码行数:25,代码来源:util.c


示例6: seek_backwards

static spx_int64_t seek_backwards(spx_ogg_sync_state *oy, spx_ogg_page *og,
                                  spx_int64_t wantedpos)
{
    spx_int64_t crofs;
    spx_int64_t *curoffset=&crofs;
    *curoffset=ci->curpos;
    spx_int64_t begin=*curoffset;
    spx_int64_t end=begin;
    spx_int64_t ret;
    spx_int64_t offset=-1;
    spx_int64_t avgpagelen=-1;
    spx_int64_t lastgranule=-1;

    short time = -1;

    while (offset == -1) {

        begin -= SEEK_CHUNKSIZE;

        if (begin < 0) {
            if (time < 0) {
                begin = 0;
                time++;
            } else {
                LOGF("Can't seek that early:%lld\n",begin);
                return -3;  /* too early */
            }
        }

        *curoffset = begin;

        ci->seek_buffer(*curoffset);

        spx_ogg_sync_reset(oy);

        lastgranule = -1;

        while (*curoffset < end) {
            ret = get_next_page(oy,og,end-*curoffset);

            if (ret > 0) {
                if (lastgranule != -1) {
                    if (avgpagelen < 0)
                        avgpagelen = (spx_ogg_page_granulepos(og)-lastgranule);
                    else
                       avgpagelen=((spx_ogg_page_granulepos(og)-lastgranule)
                                   + avgpagelen) / 2;
                }

                lastgranule=spx_ogg_page_granulepos(og);

                if ((lastgranule - (avgpagelen/4)) < wantedpos &&
                    (lastgranule + avgpagelen + (avgpagelen/4)) > wantedpos) {

                    /*wanted offset found Yeay!*/

                    /*LOGF("GnPagefound:%d,%d,%d,%d\n",ret,
                           lastgranule,wantedpos,avgpagelen);*/

                    return ret;

                } else if (lastgranule > wantedpos) {  /*too late, seek more*/
                    if (offset != -1) {
                        LOGF("Toolate, returnanyway:%lld,%lld,%lld,%lld\n",
                             ret,lastgranule,wantedpos,avgpagelen);
                        return ret;
                    }
                    break;
                } else{ /*if (spx_ogg_page_granulepos(&og)<wantedpos)*/
                    /*too early*/
                    offset = ret;
                    continue;
                }
            } else if (ret == -3) 
                return(-3);
            else if (ret<=0)
                break;
            else if (*curoffset < end) {
                /*this should not be possible*/

                //LOGF("Seek:get_earlier_page:Offset:not_cached by granule:"\"%d,%d,%d,%d,%d\n",*curoffset,end,begin,wantedpos,curpos);

                offset=ret;
            }
        }
    }
    return -1;
}
开发者ID:lyzkov,项目名称:rockbox,代码行数:88,代码来源:speex.c


示例7: speex_seek_page_granule

static int speex_seek_page_granule(spx_int64_t pos, spx_int64_t curpos,
                                   spx_ogg_sync_state *oy,
                                   spx_int64_t headerssize)
{
    /* TODO: Someone may want to try to implement seek to packet, 
             instead of just to page (should be more accurate, not be any 
             faster) */

    spx_int64_t crofs;
    spx_int64_t *curbyteoffset = &crofs;
    *curbyteoffset = ci->curpos;
    spx_int64_t curoffset;
    curoffset = *curbyteoffset;
    spx_int64_t offset = 0;
    spx_ogg_page og = {0,0,0,0};
    spx_int64_t avgpagelen = -1;
    spx_int64_t lastgranule = -1;

    if(abs(pos-curpos)>10000 && headerssize>0 && curoffset-headerssize>10000) {
        /* if seeking for more that 10sec,
           headersize is known & more than 10kb is played,
           try to guess a place to seek from the number of
           bytes playe for this position, this works best when 
           the bitrate is relativly constant.
         */

        curoffset = (((*curbyteoffset-headerssize) * pos)/curpos)*98/100;
        if (curoffset < 0)
            curoffset=0;

        //spx_int64_t toffset=curoffset;

        ci->seek_buffer(curoffset);

        spx_ogg_sync_reset(oy);

        offset = get_next_page(oy,&og,-1);

        if (offset < 0) { /* could not find new page,use old offset */
            LOGF("Seek/guess/fault:%lld->-<-%d,%lld:%lld,%d,%ld,%d\n",
                 curpos,0,pos,offset,0,
                 ci->curpos,/*stream_length*/0);

            curoffset = *curbyteoffset;

            ci->seek_buffer(curoffset);

            spx_ogg_sync_reset(oy);
        } else {
            if (spx_ogg_page_granulepos(&og) == 0 && pos > 5000) {
                LOGF("SEEK/guess/fault:%lld->-<-%lld,%lld:%lld,%d,%ld,%d\n",
                     curpos,spx_ogg_page_granulepos(&og),pos,
                     offset,0,ci->curpos,/*stream_length*/0);

                curoffset = *curbyteoffset;

                ci->seek_buffer(curoffset);

                spx_ogg_sync_reset(oy);
            } else {
                curoffset = offset;
                curpos = spx_ogg_page_granulepos(&og);
            }
        }
    }

    /* which way do we want to seek? */

    if (curpos > pos) {  /* backwards */
        offset = seek_backwards(oy,&og,pos);

        if (offset > 0) {
            *curbyteoffset = curoffset;
            return 1;
        }
    } else {  /* forwards */

        while ( (offset = get_next_page(oy,&og,-1)) > 0) {
            if (lastgranule != -1) {
               if (avgpagelen < 0)
                   avgpagelen = (spx_ogg_page_granulepos(&og) - lastgranule);
               else
                   avgpagelen = ((spx_ogg_page_granulepos(&og) - lastgranule)
                                 + avgpagelen) / 2;
            }

            lastgranule = spx_ogg_page_granulepos(&og);

            if ( ((lastgranule - (avgpagelen/4)) < pos && ( lastgranule + 
                  avgpagelen + (avgpagelen / 4)) > pos) ||
                 lastgranule > pos) {

                /*wanted offset found Yeay!*/

                *curbyteoffset = offset;

                return offset;
            }
        }
    }
//.........这里部分代码省略.........
开发者ID:lyzkov,项目名称:rockbox,代码行数:101,代码来源:speex.c


示例8: LOGF

//------------------------------------------------------------------------
void TcpServer::listen() {
	if (espconn_accept(_conn) != ESPCONN_OK) {
		LOGF("ERR : espconn_accept");
	}
	espconn_regist_connectcb(_conn, connectCb);
}
开发者ID:vortex314,项目名称:ea_actor,代码行数:7,代码来源:Tcp.cpp


示例9: worker_start

struct worker *
worker_start(EV_P_ struct session *session)
{
    struct worker *w;
    pid_t pid;
    int stdin_fds [2] = {-1, -1};
    int stdout_fds[2] = {-1, -1};
    int stderr_fds[2] = {-1, -1};
    int msgin_fds [2] = {-1, -1};
    int msgout_fds[2] = {-1, -1};

#if WORKER_TIMINGS
    uint64_t _start = now_us();
#endif

    if ((w = calloc(1, sizeof(*w))) == NULL) {
        goto fail;
    }
    w->session = session;
    writeq_init(&w->stdin_writeq);
    writeq_init(&w->msgin_writeq);

    if (pipe(stdin_fds ) < 0 ||
        pipe(stdout_fds) < 0 ||
        pipe(stderr_fds) < 0 ||
        pipe(msgin_fds ) < 0 ||
        pipe(msgout_fds) < 0) {
        LOG_ERRNO("pipe()");
        goto fail;
    }
    maxfd_update(stdin_fds [0]);
    maxfd_update(stdin_fds [1]);
    maxfd_update(stdout_fds[0]);
    maxfd_update(stdout_fds[1]);
    maxfd_update(stderr_fds[0]);
    maxfd_update(stderr_fds[1]);
    maxfd_update(msgin_fds [0]);
    maxfd_update(msgin_fds [1]);
    maxfd_update(msgout_fds[0]);
    maxfd_update(msgout_fds[1]);


    pid = fork();
    if (pid < 0) {
        LOG_ERRNO("fork()");
        goto fail;
    }
    if (pid == 0) {
        /* child. */
        if (dup2(stdin_fds [0], 0) < 0 ||
            dup2(stdout_fds[1], 1) < 0 ||
            dup2(stderr_fds[1], 2) < 0 ||
            dup2(msgin_fds [0], 3) < 0 ||
            dup2(msgout_fds[1], 4) < 0) {
            exit(EXIT_FAILURE);
        }
        maxfd_closeall(5);
        pyenv_child_after_fork();
        exit(EXIT_SUCCESS);
    } else {
        /* parent. */
        close(stdin_fds [0]);
        close(stdout_fds[1]);
        close(stderr_fds[1]);
        close(msgin_fds [0]);
        close(msgout_fds[1]);

        set_fd_nonblocking(stdin_fds [1]);
        set_fd_nonblocking(stdout_fds[0]);
        set_fd_nonblocking(stderr_fds[0]);
        set_fd_nonblocking(msgin_fds [1]);
        set_fd_nonblocking(msgout_fds[0]);

        ev_child_init(&w->child_watcher, worker_exited_cb, pid, 0);
        ev_child_start(EV_A_ &w->child_watcher);

        ev_io_init(&w->stdin_w , worker_write_stdin_cb, stdin_fds [1],
                   EV_WRITE);
        ev_io_init(&w->stdout_w, worker_read_stdout_cb, stdout_fds[0],
                   EV_READ);
        ev_io_init(&w->stderr_w, worker_read_stderr_cb, stderr_fds[0],
                   EV_READ);
        ev_io_init(&w->msgin_w , worker_write_msgin_cb, msgin_fds [1],
                   EV_WRITE);
        ev_io_init(&w->msgout_w, worker_read_msgout_cb, msgout_fds[0],
                   EV_READ);
        ev_io_start(EV_A_ &w->stdout_w);
        ev_io_start(EV_A_ &w->stderr_w);
        ev_io_start(EV_A_ &w->msgout_w);

        LOGF(3, "=== %d: worker started, fds=[%d, %d, %d, %d, %d]\n",
             worker_pid(w), stdin_fds[1], stdout_fds[0], stderr_fds[0],
             msgin_fds[1], msgout_fds[0]);

        w->f_alive = true;
    }
#if WORKER_TIMINGS
    worker_start_time += now_us() - _start;
    worker_start_calls++;
#endif
//.........这里部分代码省略.........
开发者ID:acleone,项目名称:pyspawner,代码行数:101,代码来源:worker.c


示例10: Xgetsockname

/*!
** @brief Get the full DAG of the local socket.
**
** @param sockfd An Xsocket of type SOCK_STREAM
** @param dag A sockaddr to hold the returned DAG.
** @param len On input contans the size of the sockaddr,
**  on output contains sizeof(sockaddr_x).
**
** @returns 0 on success
** @returns -1 on failure with errno set
** @returns errno = EFAULT if dag is NULL
** @returns errno = EOPNOTSUPP if sockfd is not of type XSSOCK_STREAM
** @returns errno = ENOTCONN if sockfd is not in a connected state
**
*/
int Xgetsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
	int rc;
	int flags;
	char buf[MAXBUFLEN];

	if (!addr || !addrlen) {
		LOG("pointer is null!\n");
		errno = EFAULT;
		return -1;
	}

	if (*addrlen < sizeof(sockaddr_x)) {
		errno = EINVAL;
		return -1;
	}

	if (validateSocket(sockfd, XSOCK_STREAM, EOPNOTSUPP) < 0) {
		LOG("Xgetsockname is only valid with stream sockets.");
		return -1;
	}

	if (connState(sockfd) != CONNECTED) {
		LOGF("Socket %d is not connected", sockfd);
		errno = ENOTCONN;
		return -1;
	}

	xia::XSocketMsg xsm;
	xsm.set_type(xia::XGETSOCKNAME);

	flags = Xfcntl(sockfd, F_GETFL);
	fcntl(sockfd, F_SETFL, flags & ~O_NONBLOCK);

	// send the protobuf containing the user data to click
    if ((rc = click_send(sockfd, &xsm)) < 0) {
		LOGF("Error talking to Click: %s", strerror(errno));
		fcntl(sockfd, F_SETFL, flags);
		return -1;
	}

	// get the dag
	// FIXME: loop here till done or error
	if ((rc = click_reply(sockfd, xia::XGETSOCKNAME, buf, sizeof(buf))) < 0) {
		LOGF("Error retrieving status from Click: %s", strerror(errno));
		fcntl(sockfd, F_SETFL, flags);
		return -1;
	}

	fcntl(sockfd, F_SETFL, flags);

	xsm.Clear();
	xsm.ParseFromString(buf);

	if (xsm.type() != xia::XGETSOCKNAME) {
		LOGF("error: expected %d, got %d\n", xia::XGETPEERNAME, xsm.type());
		return -1;
	}

	xia::X_GetSockname_Msg *msg = xsm.mutable_x_getsockname();

	Graph g(msg->dag().c_str());

	g.fill_sockaddr((sockaddr_x*)addr);
	*addrlen = sizeof(sockaddr_x);

	return 0;
}
开发者ID:rogerhzh,项目名称:linphone_XIA,代码行数:83,代码来源:XgetDAGbyName.c


示例11: vrdpDrvStrokePath

void vrdpDrvStrokePath(SURFOBJ *pso, PATHOBJ *ppo, CLIPOBJ *pco, XFORMOBJ *pxo,
                       BRUSHOBJ  *pbo, POINTL *pptlBrushOrg, LINEATTRS *plineattrs, MIX mix)
{
    PVBOXDISPDEV pDev = (PVBOXDISPDEV)pso->dhpdev;

    /*
     * StrokePath operation is supported by RDP_ORDER_POLYGON/POLYLINE/ELLIPSE.
     */
    VRDPCLIPRECTS clipRects;
    int clipResult;
    RECTFX rcfxBounds;
    RECTL rclBoundsOrdered;

    LOGF(("pso = %p, ppo = %p, pco = %p, pxo = %p, pbo = %p, pptlBrushOrg = %p, plineattrs = %p, mix = 0x%08X",
           pso, ppo, pco, pxo, pbo, pptlBrushOrg, plineattrs, mix));
    LOGF(("ppo: fl = 0x%08X, cCurves = %d", ppo->fl, ppo->cCurves));

    PATHOBJ_vGetBounds(ppo, &rcfxBounds);

    rclBoundsOrdered.left   = FXTOLFLOOR(rcfxBounds.xLeft);
    rclBoundsOrdered.right  = FXTOLCEILING(rcfxBounds.xRight);
    rclBoundsOrdered.top    = FXTOLFLOOR(rcfxBounds.yTop);
    rclBoundsOrdered.bottom = FXTOLCEILING(rcfxBounds.yBottom);

    vrdpOrderRect(&rclBoundsOrdered);

    LOG(("ppo: bounds %x-%x, %x-%x, %d-%d %d-%d",
         rcfxBounds.xLeft, rcfxBounds.xRight, rcfxBounds.yTop, rcfxBounds.yBottom,
         rclBoundsOrdered.left, rclBoundsOrdered.right, rclBoundsOrdered.top, rclBoundsOrdered.bottom));

    clipResult = vrdpGetIntersectingClipRects(&clipRects, pso, &rclBoundsOrdered, pco, NULL);

    if (clipResult == VRDP_CLIP_NO_INTERSECTION)
    {
        /* Do nothing. The operation does not affect anything. */
        LOG(("VRDP_CLIP_NO_INTERSECTION!!!"));
        dumpPCO (&rclBoundsOrdered, pco);
    }
    else if (clipResult == VRDP_CLIP_TOO_MANY_RECTS)
    {
        /* A very complex clip. Better to emulate it. */
        LOG(("VRDP_CLIP_TOO_MANY_RECTS!!!"));
        dumpPCO (&rclBoundsOrdered, pco);

        vrdpReportDirtyRects(pDev, &clipRects);
    }
    else if (pbo->iSolidColor == 0xFFFFFFFF)
    {
        /* Not solid brushes are not supported. */
        vrdpReportDirtyRects(pDev, &clipRects);
    }
    else if (ppo->fl & PO_ELLIPSE)
    {
        if (VBoxVBVAOrderSupported(&pDev->vbvaCtx, VRDE_ORDER_ELLIPSE))
        {
            VRDEORDERELLIPSE order;

            order.pt1.x = (int16_t)FXTOLROUND(rcfxBounds.xLeft   + 4);
            order.pt1.y = (int16_t)FXTOLROUND(rcfxBounds.yTop    + 4);
            order.pt2.x = (int16_t)FXTOLROUND(rcfxBounds.xRight  - 4);
            order.pt2.y = (int16_t)FXTOLROUND(rcfxBounds.yBottom - 4);

            order.mix = (uint8_t)(mix & 0x1F);
            order.fillMode = 0;
            order.rgb = vrdpColor2RGB(pso, pbo->iSolidColor);

            vrdpReportOrderGeneric(pDev, &clipRects, &order, sizeof (order), VRDE_ORDER_ELLIPSE);
        }
        else
        {
            WARN(("ELLIPSE not supported"));
            vrdpReportDirtyRects (pDev, &clipRects);
        }
    }
    else if (   (ppo->fl & PO_BEZIERS) == 0
             && (plineattrs->fl & LA_GEOMETRIC) == 0
             && plineattrs->pstyle == NULL)
    {
        unsigned i;
        PATHDATA pd;
        BOOL bMore;
        VRDEORDERPOLYLINE order;
        VRDEORDERPOINT ptStart;
        VRDEORDERBOUNDS bounds;

        order.rgb = vrdpColor2RGB(pso, pbo->iSolidColor);
        order.mix = (uint8_t)(mix & 0x1F);

        PATHOBJ_vEnumStart(ppo);

        order.points.c = 0;

        do {
            POINTFIX *pptfx;
            VRDEORDERPOINT pt;

            bMore = PATHOBJ_bEnum (ppo, &pd);

            LOG(("pd: flags = 0x%08X, count = %d", pd.flags, pd.count));

//.........这里部分代码省略.........
开发者ID:carmark,项目名称:vbox,代码行数:101,代码来源:VBoxDispVRDP.cpp


示例12: ssbCopy

static BOOL ssbCopy(SSB *pSSB, SURFOBJ *pso, RECTL *prcl, BOOL bToScreen)
{
    BYTE *pSrc;
    BYTE *pDst;

    LONG lDeltaSrc;
    LONG lDeltaDst;

    ULONG cWidth;
    ULONG cHeight;

    int cbPixel = format2BytesPerPixel(pso);

    LOGF(("pSSB = %p, pso = %p, prcl = %p, bToScreen = %d", pSSB, pso, prcl, bToScreen));

    if (cbPixel == 0)
    {
        WARN(("unsupported pixel format!!!"));
        return FALSE;
    }

    cWidth  = prcl->right - prcl->left;
    cHeight = prcl->bottom - prcl->top;

    if (bToScreen)
    {
        if (pSSB->pBuffer == NULL)
        {
            WARN(("source buffer is NULL!!!"));
            return FALSE;
        }

        pSrc = pSSB->pBuffer;
        lDeltaSrc = cWidth * cbPixel;

        pDst = (BYTE *)pso->pvScan0 +
                       pso->lDelta * prcl->top +
                       cbPixel * prcl->left;
        lDeltaDst  = pso->lDelta;
    }
    else
    {
        if (pSSB->pBuffer != NULL)
        {
            WARN(("source buffer is not NULL!!!"));
            return FALSE;
        }

        pSSB->pBuffer = (BYTE *)EngAllocMem (0, cWidth * cHeight * cbPixel, MEM_ALLOC_TAG);

        if (pSSB->pBuffer == NULL)
        {
            WARN(("Failed to allocate buffer!!!"));
            return FALSE;
        }

        pDst = pSSB->pBuffer;
        lDeltaDst = cWidth * cbPixel;

        pSrc = (BYTE *)pso->pvScan0 +
                       pso->lDelta * prcl->top +
                       cbPixel * prcl->left;
        lDeltaSrc  = pso->lDelta;
    }

    LOG(("cHeight = %d, pDst = %p, pSrc = %p, lDeltaSrc = %d, lDeltaDst = %d",
         cHeight, pDst, pSrc, lDeltaSrc, lDeltaDst));

    while (cHeight--)
    {
        memcpy (pDst, pSrc, cWidth * cbPixel);

        pDst += lDeltaDst;
        pSrc += lDeltaSrc;
    }

    LOGF(("completed."));
    return TRUE;
}
开发者ID:CandyYao,项目名称:VirtualBox-OSE,代码行数:79,代码来源:VBoxDispDrawCmd.cpp


示例13: codec_run

/* this is called for each file to process */
enum codec_status codec_run(void)
{
    size_t n;
    demux_res_t demux_res;
    stream_t input_stream;
    uint32_t samplesdone;
    uint32_t elapsedtime = 0;
    int samplesdecoded;
    unsigned int i;
    unsigned char* buffer;
    alac_file alac;
    intptr_t param;

    /* Clean and initialize decoder structures */
    memset(&demux_res , 0, sizeof(demux_res));
    if (codec_init()) {
        LOGF("ALAC: Error initialising codec\n");
        return CODEC_ERROR;
    }

    ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency);
    codec_set_replaygain(ci->id3);

    ci->seek_buffer(0);

    stream_create(&input_stream,ci);

    /* Read from ci->id3->offset before calling qtmovie_read. */
    samplesdone = (uint32_t)(((uint64_t)(ci->id3->offset) * ci->id3->frequency) /  
                  (ci->id3->bitrate*128));
  
    /* if qtmovie_read returns successfully, the stream is up to
     * the movie data, which can be used directly by the decoder */
    if (!qtmovie_read(&input_stream, &demux_res)) {
        LOGF("ALAC: Error initialising file\n");
        return CODEC_ERROR;
    }

    /* initialise the sound converter */
    alac_set_info(&alac, demux_res.codecdata);
  
    /* Set i for first frame, seek to desired sample position for resuming. */
    i=0;
    if (samplesdone > 0) {
        if (m4a_seek(&demux_res, &input_stream, samplesdone,
                      &samplesdone, (int*) &i)) {
            elapsedtime = (samplesdone * 10) / (ci->id3->frequency / 100);
            ci->set_elapsed(elapsedtime);
        } else {
            samplesdone = 0;
        }
    }

    ci->set_elapsed(elapsedtime);

    /* The main decoding loop */
    while (i < demux_res.num_sample_byte_sizes) {
        enum codec_command_action action = ci->get_command(&param);

        if (action == CODEC_ACTION_HALT)
            break;

        /* Request the required number of bytes from the input buffer */
        buffer=ci->request_buffer(&n, ALAC_BYTE_BUFFER_SIZE);

        /* Deal with any pending seek requests */
        if (action == CODEC_ACTION_SEEK_TIME) {
            if (m4a_seek(&demux_res, &input_stream,
                         (param/10) * (ci->id3->frequency/100),
                         &samplesdone, (int *)&i)) {
                elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
            }
            ci->set_elapsed(elapsedtime);
            ci->seek_complete();
        }

        /* Request the required number of bytes from the input buffer */
        buffer=ci->request_buffer(&n, ALAC_BYTE_BUFFER_SIZE);

        /* Decode one block - returned samples will be host-endian */
        samplesdecoded=alac_decode_frame(&alac, buffer, outputbuffer, ci->yield);
        ci->yield();

        /* Advance codec buffer by amount of consumed bytes */
        ci->advance_buffer(alac.bytes_consumed);

        /* Output the audio */
        ci->pcmbuf_insert(outputbuffer[0], outputbuffer[1], samplesdecoded);

        /* Update the elapsed-time indicator */
        samplesdone+=samplesdecoded;
        elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
        ci->set_elapsed(elapsedtime);

        i++;
    }

    LOGF("ALAC: Decoded %lu samples\n",(unsigned long)samplesdone);
    return CODEC_OK;
//.........这里部分代码省略.........
开发者ID:ifroz,项目名称:rockbox,代码行数:101,代码来源:alac.c


示例14: VBoxDispDrvEscape

ULONG APIENTRY VBoxDispDrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
    PVBOXDISPDEV pDev = (PVBOXDISPDEV)pso->dhpdev;
    LOGF_ENTER();

    switch (iEsc)
    {
#ifdef VBOX_WITH_CROGL
        case OPENGL_GETINFO:
        {
            if (pvOut && cjOut >= sizeof(OPENGL_INFO))
            {
                POPENGL_INFO pInfo = (POPENGL_INFO)pvOut;

                pInfo->dwVersion        = 2;
                pInfo->dwDriverVersion  = 1;
                pInfo->szDriverName[0]  = 'V';
                pInfo->szDriverName[1]  = 'B';
                pInfo->szDriverName[2]  = 'o';
                pInfo->szDriverName[3]  = 'x';
                pInfo->szDriverName[4]  = 'O';
                pInfo->szDriverName[5]  = 'G';
                pInfo->szDriverName[6]  = 'L';
                pInfo->szDriverName[7]  = 0;

                LOG(("OPENGL_GETINFO ok"));
                return cjOut;
            }
            else
            {
                WARN(("OPENGL_GETINFO invalid parms"));
                return 0;
            }
        }
        case QUERYESCSUPPORT:
        {
            if (pvIn && cjIn == sizeof(DWORD))
            {
                DWORD nEscapeQuery = *(DWORD *)pvIn;

                if (nEscapeQuery==OPENGL_GETINFO)
                {
                    LOG(("QUERYESCSUPPORT OPENGL_GETINFO"));
                    return 1;
                }
                else
                {
                    LOG(("QUERYESCSUPPORT unsupported query %d", nEscapeQuery));
                    return 0;
                }
            }
            else
            {
                WARN(("QUERYESCSUPPORT invalid parms"));
                return 0;
            }
        }
#endif
        case VBOXESC_ISVRDPACTIVE:
        {
            if (pDev && pDev->vbvaCtx.pVBVA && pDev->vbvaCtx.pVBVA->hostFlags.u32HostEvents&VBVA_F_MODE_VRDP)
            {
                LOGF(("VBOXESC_ISVRDPACTIVE: 1"));
                return 1;
            }
            LOGF(("VBOXESC_ISVRDPACTIVE: 0"));
            return 0;
        }
        case VBOXESC_SETVISIBLEREGION:
        {
            LOGF(("VBOXESC_SETVISIBLEREGION"));
            LPRGNDATA lpRgnData = (LPRGNDATA)pvIn;
            DWORD cRects;

            if (    cjIn >= sizeof(RGNDATAHEADER)
                &&  pvIn
                &&  lpRgnData->rdh.dwSize == sizeof(RGNDATAHEADER)
                &&  lpRgnData->rdh.iType  == RDH_RECTANGLES
                &&  (cRects = lpRgnData->rdh.nCount) <= _1M
                &&  cjIn == cRects * (uint64_t)sizeof(RECT) + sizeof(RGNDATAHEADER))
            {
                /** @todo this whole conversion thing could maybe be skipped
                 *        since RTRECT matches the RECT layout. */
#if 0
                AssertCompile(sizeof(RTRECT) == sizeof(RECT));
                AssertCompileMembersSameSizeAndOffset(RTRECT, xLeft,    RECT, left);
                AssertCompileMembersSameSizeAndOffset(RTRECT, xBottom,  RECT, bottom);
                AssertCompileMembersSameSizeAndOffset(RTRECT, xRight,   RECT, right);
                AssertCompileMembersSameSizeAndOffset(RTRECT, xTop,     RECT, top);

                rc = VBoxDispMPSetVisibleRegion(pDev->hDriver, (PRTRECT)&lpRgnData->Buffer[0], cRects);
                VBOX_WARNRC(rc);
#else
                DWORD   i;
                PRTRECT pRTRect;
                int     rc;
                RECT   *pRect = (RECT *)&lpRgnData->Buffer;

                pRTRect = (PRTRECT) EngAllocMem(0, cRects*sizeof(RTRECT), MEM_ALLOC_TAG);
                if (!pRTRect)
//.........这里部分代码省略.........
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:101,代码来源:VBoxDispDriver.cpp


示例15: VBoxDispDrvAssertMode

/* Called to reset device to default mode or to mode specified with dhpdev */
BOOL APIENTRY VBoxDispDrvAssertMode(DHPDEV dhpdev, BOOL bEnable)
{
    PVBOXDISPDEV pDev = (PVBOXDISPDEV) dhpdev;
    DWORD dwrc;
    int rc;
    LOGF_ENTER();

    if (!bEnable)
    {
        LOGF(("!bEnable"));
#ifdef VBOX_WITH_VIDEOHWACCEL
        /* tells we can not process host commands any more and ensures that
         * we've completed processing of the host VHWA commands
         */
        VBoxDispVHWADisable(pDev);
#endif

        /* disable VBVA */
        if (pDev->hgsmi.bSupported)
        {
            VBoxVBVADisable(&pDev->vbvaCtx, &pDev->hgsmi.ctx, -1);
        }

        /* reset the device to default mode */
        rc = VBoxDispMPResetDevice(pDev->hDriver);
        VBOX_WARNRC_RETV(rc, FALSE);
    }
    else
    {
        LOGF(("bEnable"));

        /* switch device to previous pDev mode */
        rc = VBoxDispMPSetCurrentMode(pDev->hDriver, pDev->mode.ulIndex);
        VBOX_WARNRC_RETV(rc, NULL);

        /* enable VBVA */
        if (pDev->hgsmi.bSupported)
        {
            if (pDev->mode.ulBitsPerPel==16 || pDev->mode.ulBitsPerPel==24 || pDev->mode.ulBitsPerPel==32)
            {
                VBVABUFFER *pVBVA = (VBVABUFFER *)((uint8_t *)pDev->memInfo.VideoRamBase+pDev->layout.offVBVABuffer);
                pDev->hgsmi.bSupported = VBoxVBVAEnable(&pDev->vbvaCtx, &pDev->hgsmi.ctx, pVBVA, -1);
                LogRel(("VBoxDisp[%d]: VBVA %senabled\n", pDev->iDevice, pDev->hgsmi.bSupported? "":"not "));
            }
        }

        /* inform host */
        if (pDev->hgsmi.bSupported)
        {
            VBoxHGSMIProcessDisplayInfo(&pDev->hgsmi.ctx, pDev->iDevice, pDev->orgDev.x, pDev->orgDev.y,
                                        0, abs(pDev->mode.lScanlineStride), pDev->mode.ulWidth, pDev->mode.ulHeight,
                                        (uint16_t)pDev->mode.ulBitsPerPel, VBVA_SCREEN_F_ACTIVE);
        }

#ifdef VBOX_WITH_VIDEOHWACCEL
        /* tells we can process host commands */
       VBoxDispVHWAEnable(pDev);
#endif

        /* Associate back GDI bitmap residing in our framebuffer memory with GDI's handle to our device */
        dwrc = EngAssociateSurface((HSURF)pDev->surface.hBitmap, pDev->hDevGDI, 0);
        if (dwrc != NO_ERROR)
        {
            WARN(("EngAssociateSurface on bitmap failed with %#x", dwrc));
            return FALSE;
        }

        /* Associate device managed surface with GDI's handle to our device */
        dwrc = EngAssociateSurface(pDev->surface.hSurface, pDev->hDevGDI, pDev->flDrawingHooks);
        if (dwrc != NO_ERROR)
        {
            WARN(("EngAssociateSurface on surface failed with %#x", dwrc));
            return FALSE;
        }
    }

    LOGF_LEAVE();
    return TRUE;
}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:80,代码来源:VBoxDispDriver.cpp


示例16: vrdpAdjustRect

void vrdpAdjustRect(SURFOBJ *pso, RECTL *prcl)
{
    int x;
    int y;
    int w;
    int h;

    LOGF(("%d-%d %d-%d on %dx%d\n", prcl->left, prcl->right, prcl->top, prcl->bottom, pso->sizlBitmap.cx, pso->sizlBitmap.cy));

    if (prcl->left <= prcl->right)
    {
        x = prcl->left;
        w = prcl->right - prcl->left;
    }
    else
    {
        WARN(("Inverse X coordinates"));
        x = prcl->right;
        w = prcl->left - prcl->right;
    }

    if (prcl->top <= prcl->bottom)
    {
        y = prcl->top;
        h = prcl->bottom - prcl->top;
    }
    else
    {
        WARN(("Inverse Y coordinates"));
        y = prcl->bottom;
        h = prcl->top - prcl->bottom;
    }

    Assert(w >= 0 && h >= 0);

    /* Correct negative x and y coordinates. */
    if (x < 0)
    {
        x += w; /* Compute xRight which is also the new width. */

        w = (x < 0)? 0: x;

        x = 0;
    }

    if (y < 0)
    {
        y += h; /* Compute xBottom, which is also the new height. */

        h = (y < 0)? 0: y;

        y = 0;
    }

    /* Also check if coords are greater than the display resolution. */
    if (x + w > pso->sizlBitmap.cx)
    {
        w = pso->sizlBitmap.cx > x? pso->sizlBitmap.cx - x: 0;
    }

    if (y + h > pso->sizlBitmap.cy)
    {
        h = pso->sizlBitmap.cy > y? pso->sizlBitmap.cy - y: 0;
    }

    prcl->left   = x;
    prcl->top    = y;
    prcl->right  = x + w;
    prcl->bottom = y + h;

    LOGF(("result %d-%d %d-%d", prcl->left, prcl->right, prcl->top, prcl->bottom));
}
开发者ID:carmark,项目名称:vbox,代码行数:72,代码来源:VBoxDispVRDP.cpp


示例17: vrdpGetIntersectingClipRects

static int vrdpGetIntersectingClipRects(VRDPCLIPRECTS *pClipRects, SURFOBJ *pso, RECTL *prcl, CLIPOBJ *pco, POINTL *pptlSrc)
{
    BOOL bTooManyRects = FALSE;

    LOGF(("pso = %p, pptlSrc = %p", pso, pptlSrc));

    pso = getSurfObj(pso);

    pClipRects->rclDstOrig = *prcl;
    pClipRects->rclDst     = *prcl;
    pClipRects->rects.c    = 0;

    vrdpAdjustRect(pso, &pClipRects->rclDst);

    if (pco && (pco->iDComplexity != DC_TRIVIAL))
    {
        ULONG iDirection = CD_ANY;

        if (pptlSrc)
        {
            /* Operation is performed on the same (screen) surface and enumeration direction
             * must take into account the position of source and target rectangles.
             */
            if (pptlSrc->x <= prcl->left)
            {
                if (pptlSrc->y <= prcl->top)
                {
                    iDirection = CD_LEFTUP;
                }
                else
                {
                    iDirection = CD_LEFTDOWN;
                }
            }
            else
            {
                if (pptlSrc->y <= prcl->top)
                {
                    iDirection = CD_RIGHTUP;
                }
                else
                {
                    iDirection = CD_RIGHTDOWN;
                }
            }
        }

        /* Clip the target rect by entire clipping region. Obtain the effective target. */
        vrdpIntersectRects(&pClipRects->rclDst, &pClipRects->rclDst, &pco->rclBounds);

        /* Enumerate rectangles. Try to get all rectangles at once and if there is not
         * enough space (too many rectangles) fail with the bTooManyRects condition.
         */
        CLIPOBJ_cEnumStart(pco, FALSE, CT_RECTANGLES, iDirection, 0);

        bTooManyRects = CLIPOBJ_bEnum(pco, sizeof(pClipRects->rects), &pClipRects->rects.c);

        if (!bTooManyRects)
        {
            RECTL *prclClipSrc = &pClipRects->rects.arcl[0];
            RECTL *prclClipDst = prclClipSrc;

            ULONG cRects = pClipRects->rects.c;

            LOGF(("%d rects", cRects));

            if (cRects > 0)
            {
                for (; cRects != 0; cRects--, prclClipSrc++)
                {
                    vrdpIntersectRects(prclClipDst, prclClipSrc, &pClipRects->rclDst);

                    if (vrdpIsRectEmpty(prclClipDst))
                    {
                        pClipRects->rects.c--;
                    }
                    else
                    {
                        prclClipDst++;
                    }
                }
            }

            if (pClipRects->rects.c == 0)
            {
                pClipRects->rclDst.left = pClipRects->rclDst.right = 0;
            }
            LOGF(("%d rects remains", pClipRects->rects.c));
        }
    }

    if (vrdpIsRectEmpty(&pClipRects->rclDst))
    {
        return VRDP_CLIP_NO_INTERSECTION;
    }

    if (bTooManyRects)
    {
        pClipRects->rects.c = 0;

//.........这里部分代码省略.........
开发者ID:carmark,项目名称:vbox,代码行数:101,代码来源:VBoxDispVRDP.cpp


示例18: VBoxDispDrvSaveScreenBits

ULONG_PTR APIENTRY VBoxDispDrvSaveScreenBits(SURFOBJ *pso, ULONG iMode, ULONG_PTR ident, RECTL *prcl)
{
    ULONG_PTR rc = 0; /* 0 means the function failure for every iMode. */
    RECTL rcl;
    SSB *pSSB;
    SURFOBJ *psoOrg = pso;
    BOOL bCallVBVA = FALSE;

    PVBOXDISPDEV pDev = (PVBOXDISPDEV) pso->dhpdev;

    LOGF(("%p, %d, %d, %d,%d %d,%d", pso, iMode, ident, prcl->left, prcl->top, prcl->right, prcl->bottom));

    if (!pDev)
    {
        return rc;
    }

    pso = getSurfObj(pso);

    /* Order the rectangle. */
    if (prcl->left <= prcl->right)
    {
        rcl.left = prcl->left;
        rcl.right = prcl->right;
    }
    else
    {
        rcl.left = prcl->right;
        rcl.right = prcl->left;
    }

    if (prcl->top <= prcl->bottom)
    {
        rcl.top = prcl->top;
        rcl.bottom = prcl->bottom;
    }
    else
    {
        rcl.top = prcl->bottom;
        rcl.bottom = prcl->top;
    }

    /* Implementation of the save/restore is a bit complicated because RDP
     * requires "the sequencing of saves and restores is such that they
     * behave as a last-in, first-out stack.".
     */
    switch (iMode)
    {
        case SS_SAVE:
        {
            LOG(("SS_SAVE %d", pDev->cSSB));

            if (pDev->cSSB >= RT_ELEMENTS(pDev->aSSB))
            {
                /* All slots are already in use. Fail. */
                WARN(("no more slots %d!!!", pDev->cSSB));
                break;
            }

            /* Get pointer to the slot where bits will be saved. */
            pSSB = &pDev->aSSB[pDev->cSSB];

            /* Allocate memory for screen bits and copy them to the buffer. */
            if (ssbCopy(pSSB, pso, &rcl, FALSE /* bToScreen */))
            {
                /* Bits where successfully copied. Increase the active slot number
                 * and call VBVA levels, 'ident' is also assigned, the VBVA level
                 * will use it even for the SS_SAVE.
                 */
                ident = rc = pSSB->ident = ++pDev->cSSB;
                bCallVBVA = TRUE;
            }
        } break;

        case SS_RESTORE:
        {
            LOG(("SS_RESTORE"));

            if (pDev->cSSB == 0 || ident == 0 || ident > pDev->cSSB)
            {
                WARN(("no slot: pDev->cSSB = %d!!!", pDev->cSSB));
      

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LOGFN函数代码示例发布时间:2022-05-30
下一篇:
C++ LOGE_IF函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap