コード例 #1
0
ファイル: pbuf.c プロジェクト: MattHung/sage-graphics
int
audio_pbuf_decode(struct pbuf *playout_buf, struct timeval curr_time,
                             decode_frame_t decode_func, void *data)
{
        /* Find the first complete frame that has reached it's playout */
        /* time, and decode it into the framebuffer. Mark the frame as */
        /* decoded, but otherwise leave it in the playout buffer.      */
        struct pbuf_node *curr;

        pbuf_validate(playout_buf);

        curr = playout_buf->frst;
        while (curr != NULL) {
                /* WARNING: this one differs from video - we need to push audio immediately, because we do
                 * _not_ know the granularity of audio (typically 256 B for ALSA) which is only small fractal
                 * of frame time. The current RTP library isn't currently able to keep concurrently more frames.
                 */
                UNUSED(curr_time);
                if (!curr->decoded // && tv_gt(curr_time, curr->playout_time)
                                ) {
                        if (frame_complete(curr)) {
                                int ret = decode_func(curr->cdata, data);
                                curr->decoded = 1;
                                return ret;
                        }
                }
                curr = curr->nxt;
        }
        return 0;
}
コード例 #2
0
ファイル: pbuf.c プロジェクト: MattHung/sage-graphics
int
pbuf_decode(struct pbuf *playout_buf, struct timeval curr_time,
                             decode_frame_t decode_func, void *data)
{
        /* Find the first complete frame that has reached it's playout */
        /* time, and decode it into the framebuffer. Mark the frame as */
        /* decoded, but otherwise leave it in the playout buffer.      */
        struct pbuf_node *curr;

        pbuf_validate(playout_buf);

        curr = playout_buf->frst;
        while (curr != NULL) {
                if (!curr->decoded && tv_gt(curr_time, curr->playout_time)) {
                        if (frame_complete(curr)) {
                                int ret = decode_func(curr->cdata, data);
                                curr->decoded = 1;
                                return ret;
                        } else {
                                debug_msg
                                    ("Unable to decode frame due to missing data (RTP TS=%u)\n",
                                     curr->rtp_timestamp);
                        }
                }
                curr = curr->nxt;
        }
        return 0;
}
コード例 #3
0
ファイル: glretrace_ws.cpp プロジェクト: janesma/apitrace
bool
makeCurrent(trace::Call &call, glws::Drawable *drawable,
            glws::Drawable *readable, Context *context)
{
    Context *currentContext = currentContextPtr;
    glws::Drawable *currentDrawable = currentContext ? currentContext->drawable : NULL;
    glws::Drawable *currentReadable = currentContext ? currentContext->readable : NULL;

    if (drawable == currentDrawable &&
        readable == currentReadable &&
        context == currentContext) {
        return true;
    }

    if (currentContext) {
        glFlush();
        currentContext->needsFlush = false;
        if (!retrace::doubleBuffer) {
            frame_complete(call);
        }
    }

    flushQueries();

    beforeContextSwitch();

    bool success = glws::makeCurrent(drawable, readable, context ? context->wsContext : NULL);

    if (!success) {
        std::cerr << "error: failed to make current OpenGL context and drawable\n";
        exit(1);
    }

    if (context != currentContext) {
        if (context) {
            context->aquire();
        }
        currentContextPtr = context;
        if (currentContext) {
            currentContext->release();
        }
    }

    if (drawable && context) {
        context->drawable = drawable;
        context->readable = readable;

        if (!context->used) {
            initContext();
            context->used = true;
        }
    }

    afterContextSwitch();

    return true;
}
コード例 #4
0
ファイル: glretrace_ws.cpp プロジェクト: galtgendo/apitrace
bool
makeCurrent(trace::Call &call, glws::Drawable *drawable, Context *context)
{
    glws::Drawable *currentDrawable = currentContext ? currentContext->drawable : NULL;

    if (drawable == currentDrawable && context == currentContext) {
        return true;
    }

    if (currentContext) {
        glFlush();
        if (!retrace::doubleBuffer) {
            frame_complete(call);
        }
    }

    flushQueries();

    bool success = glws::makeCurrent(drawable, context ? context->wsContext : NULL);

    if (!success) {
        std::cerr << "error: failed to make current OpenGL context and drawable\n";
        exit(1);
        return false;
    }

    if (currentContext) {
        currentContext->drawable = NULL;
    }

    if (drawable && context) {
        currentContext = context;
        currentContext->drawable = drawable;
        
        if (!context->used) {
            initContext();
            context->used = true;
        }
    } else {
        currentContext = NULL;
    }

    return true;
}
コード例 #5
0
ファイル: glretrace_main.cpp プロジェクト: bgirard/apitrace
static void display(void) {
    Trace::Call *call;

    while ((call = parser.parse_call())) {
        const std::string &name = call->name();

        if ((name[0] == 'w' && name[1] == 'g' && name[2] == 'l') ||
            (name[0] == 'g' && name[1] == 'l' && name[2] == 'X')) {
            // XXX: We ignore the majority of the OS-specific calls for now
            if (name == "glXSwapBuffers" ||
                name == "wglSwapBuffers") {
                if (retrace::verbosity >= 1) {
                    std::cout << *call;
                    std::cout.flush();
                };
                frame_complete();
                if (double_buffer)
                    drawable->swapBuffers();
                else
                    glFlush();
            } else if (name == "glXMakeCurrent" ||
                       name == "wglMakeCurrent") {
                glFlush();
                if (!double_buffer) {
                    frame_complete();
                }
            } else {
                continue;
            }
        }

        if (name == "glFlush") {
            glFlush();
            if (!double_buffer) {
                frame_complete();
            }
        }
        
        retrace::retrace_call(*call);

        if (!insideGlBeginEnd && call->no >= dump_state) {
            state_dump(std::cout);
            exit(0);
        }

        delete call;
    }

    // Reached the end of trace
    glFlush();

    long long endTime = OS::GetTime();
    float timeInterval = (endTime - startTime) * 1.0E-6;

    if (retrace::verbosity >= -1) { 
        std::cout << 
            "Rendered " << frame << " frames"
            " in " <<  timeInterval << " secs,"
            " average of " << (frame/timeInterval) << " fps\n";
    }

    if (wait) {
        while (ws->processEvents()) {}
    } else {
        exit(0);
    }
}