static MMAL_STATUS_T mmal_connection_destroy_internal(MMAL_CONNECTION_T *connection) { MMAL_STATUS_T status; if (connection->is_enabled) { status = mmal_connection_disable(connection); if (status != MMAL_SUCCESS) return status; } /* Special case for tunnelling */ if (connection->flags & MMAL_CONNECTION_FLAG_TUNNELLING) { status = mmal_port_disconnect(connection->out); if (status != MMAL_SUCCESS) LOG_ERROR("connection %s could not be cleared", connection->name); } /* Cleanup resources */ if (connection->pool) mmal_pool_destroy(connection->pool); if (connection->queue) mmal_queue_destroy(connection->queue); vcos_free(connection); return MMAL_SUCCESS; }
/** Destroys an instance of mmalplay. * Note: this is test code. Do not use it in your app. It *will* change or even be removed without notice. */ void mmalplay_destroy(MMALPLAY_T *ctx) { unsigned int i; LOG_TRACE("%p, %s", ctx, ctx->uri); /* Disable connections */ for (i = ctx->connection_num; i; i--) mmal_connection_disable(ctx->connection[i-1]); LOG_INFO("--- statistics ---"); LOG_INFO("decoded %i frames in %.2fs (%.2ffps)", (int)ctx->decoded_frames, ctx->time_playback / 1000000.0, ctx->decoded_frames * 1000000.0 / ctx->time_playback); for (i = 0; i < ctx->connection_num; i++) { LOG_INFO("%s", ctx->connection[i]->name); LOG_INFO("- setup time: %ims", (int)(ctx->connection[i]->time_setup / 1000)); LOG_INFO("- enable time: %ims, disable time: %ims", (int)(ctx->connection[i]->time_enable / 1000), (int)(ctx->connection[i]->time_disable / 1000)); } /* Destroy connections */ for (i = ctx->connection_num; i; i--) mmal_connection_destroy(ctx->connection[i-1]); /* Destroy components */ for (i = ctx->component_num; i; i--) { ctx->component[i-1].time_cleanup = vcos_getmicrosecs(); mmal_component_destroy(ctx->component[i-1].comp); ctx->component[i-1].time_cleanup = vcos_getmicrosecs() - ctx->component[i-1].time_cleanup; } vcos_semaphore_delete(&ctx->event); for (i = 0; i < ctx->component_num; i++) { LOG_INFO("%s:", ctx->component[i].name); LOG_INFO("- setup time: %ims, cleanup time: %ims", (int)(ctx->component[i].time_setup / 1000), (int)(ctx->component[i].time_cleanup / 1000)); } LOG_INFO("-----------------"); free(ctx); }
void CMMALVideo::Reset(void) { if (g_advancedSettings.CanLogComponent(LOGVIDEO)) CLog::Log(LOGDEBUG, "%s::%s", CLASSNAME, __func__); if (m_dec_input && m_dec_input->is_enabled) mmal_port_disable(m_dec_input); if (m_deint_connection && m_deint_connection->is_enabled) mmal_connection_disable(m_deint_connection); if (m_dec_output && m_dec_output->is_enabled) mmal_port_disable(m_dec_output); if (!m_finished) { if (m_dec_input) mmal_port_enable(m_dec_input, dec_input_port_cb); if (m_deint_connection) mmal_connection_enable(m_deint_connection); if (m_dec_output) mmal_port_enable(m_dec_output, dec_output_port_cb_static); } // blow all ready video frames bool old_drop_state = m_drop_state; SetDropState(true); pthread_mutex_lock(&m_output_mutex); while(!m_dts_queue.empty()) m_dts_queue.pop(); while (!m_demux_queue.empty()) m_demux_queue.pop(); m_demux_queue_length = 0; pthread_mutex_unlock(&m_output_mutex); if (!old_drop_state) SetDropState(false); if (!m_finished) SendCodecConfigData(); m_startframe = false; m_decoderPts = DVD_NOPTS_VALUE; m_droppedPics = 0; m_decode_frame_number = 1; m_preroll = !m_hints.stills && (m_speed == DVD_PLAYSPEED_NORMAL || m_speed == DVD_PLAYSPEED_PAUSE); }
/* Stop SVP. Stops worker thread + disables MMAL connection. */ void svp_stop(SVP_T *svp) { vcos_timer_cancel(&svp->wd_timer); vcos_timer_cancel(&svp->timer); /* Stop worker thread */ if (svp->created & SVP_CREATED_THREAD) { svp_set_stop(svp, SVP_STOP_USER); vcos_semaphore_post(&svp->sema); vcos_thread_join(&svp->thread, NULL); svp->created &= ~SVP_CREATED_THREAD; } if (svp->connection) { mmal_connection_disable(svp->connection); } mmal_port_disable(svp->video_output); }