Ejemplo n.º 1
0
static void Close(vlc_object_t *obj)
{
    filter_t *filter = (filter_t*) obj;
    filter_sys_t *sys = filter->p_sys;
    unsigned int i, j;

    if (sys->omx_handle) {
        OMX_STATETYPE state;
        OMX_GetState(sys->omx_handle, &state);

        if (state == OMX_StateExecuting) {
            OMX_SendCommand(sys->omx_handle, OMX_CommandStateSet,
                    OMX_StateIdle, 0);
            while (1) {
                OMX_U32 cmd, state;
                WaitForSpecificOmxEvent(&sys->event_queue, OMX_EventCmdComplete,
                        &cmd, &state, 0);
                if (cmd == OMX_CommandStateSet && state == OMX_StateIdle)
                    break;
            }
        }

        OMX_GetState(sys->omx_handle, &state);
        if (state == OMX_StateIdle) {
            OMX_SendCommand(sys->omx_handle, OMX_CommandStateSet,
                    OMX_StateLoaded, 0);

            for (i = 0; i < sys->num_ports; i++) {
                OmxPort *port = &sys->ports[i];
                for (j = 0; j < sys->ports[i].i_buffers; j++) {
                    OMX_BUFFERHEADERTYPE *buffer;
                    OMX_FIFO_GET(&port->fifo, buffer);
                    OMX_FreeBuffer(sys->omx_handle, port->i_port_index,
                            buffer);
                }
            }

            WaitForSpecificOmxEvent(&sys->event_queue, OMX_EventCmdComplete,
                    0, 0, 0);
        }
        for (i = 0; i < sys->num_ports; i++)
            free(sys->ports[i].pp_buffers);
        pf_free_handle(sys->omx_handle);
        DeinitOmxEventQueue(&sys->event_queue);
    }

    free(sys);
    DeinitOmxCore();
}
Ejemplo n.º 2
0
static void Close(vlc_object_t *p_this)
{
    vout_display_t *vd = (vout_display_t *)p_this;
    vout_display_sys_t *p_sys = vd->sys;

    if (p_sys->omx_handle) {
        OMX_STATETYPE state;
        OMX_GetState(p_sys->omx_handle, &state);
        if (state == OMX_StateExecuting) {
            OMX_SendCommand(p_sys->omx_handle, OMX_CommandStateSet, OMX_StateIdle, 0);
            while (1) {
                OMX_U32 cmd, state;
                WaitForSpecificOmxEvent(&p_sys->event_queue, OMX_EventCmdComplete, &cmd, &state, 0);
                if (cmd == OMX_CommandStateSet && state == OMX_StateIdle)
                    break;
            }
        }
        OMX_GetState(p_sys->omx_handle, &state);
        if (state == OMX_StateIdle) {
            OMX_SendCommand(p_sys->omx_handle, OMX_CommandStateSet, OMX_StateLoaded, 0);
            for (unsigned int i = 0; i < p_sys->port.i_buffers; i++) {
                OMX_BUFFERHEADERTYPE *p_buffer;
                OMX_FIFO_GET(&p_sys->port.fifo, p_buffer);
                OMX_FreeBuffer(p_sys->omx_handle, p_sys->port.i_port_index, p_buffer);
            }
            WaitForSpecificOmxEvent(&p_sys->event_queue, OMX_EventCmdComplete, 0, 0, 0);
        }
        free(p_sys->port.pp_buffers);
        pf_free_handle(p_sys->omx_handle);
        DeinitOmxEventQueue(&p_sys->event_queue);
        OMX_FIFO_DESTROY(&p_sys->port.fifo);
    }

    if (p_sys->pool)
        picture_pool_Release(p_sys->pool);
    free(p_sys);
    DeinitOmxCore();
}