/** The Destructor
 */
OMX_ERRORTYPE omx_alsasink_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp) {
  omx_alsasink_component_PrivateType* omx_alsasink_component_Private = openmaxStandComp->pComponentPrivate;
  OMX_U32 i;

  if(omx_alsasink_component_Private->hw_params) {
    snd_pcm_hw_params_free (omx_alsasink_component_Private->hw_params);
  }
  if(omx_alsasink_component_Private->playback_handle) {
    snd_pcm_close(omx_alsasink_component_Private->playback_handle);
  }

  /* frees port/s */
  if (omx_alsasink_component_Private->ports) {
    for (i=0; i < (omx_alsasink_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
                   omx_alsasink_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts); i++) {
      if(omx_alsasink_component_Private->ports[i])
        omx_alsasink_component_Private->ports[i]->PortDestructor(omx_alsasink_component_Private->ports[i]);
    }
    free(omx_alsasink_component_Private->ports);
    omx_alsasink_component_Private->ports=NULL;
  }

  noAlsasinkInstance--;

  return omx_base_sink_Destructor(openmaxStandComp);

}
/** The destructor
  */
OMX_ERRORTYPE omx_audio_renderer_component_Destructor(
  OMX_COMPONENTTYPE *pComponent)
{
  omx_audio_renderer_component_PrivateType* pPrivate = pComponent->pComponentPrivate;
  OMX_U32 i;

  DEBUG(DEB_LEV_FUNCTION_NAME, "%s\n", __func__);

  /* Free port(s) */
  if (pPrivate->ports) {
    for (i=0; i < pPrivate->sPortTypesParam[OMX_PortDomainAudio].nPorts; i++) {
      if(pPrivate->ports[i])
        pPrivate->ports[i]->PortDestructor(pPrivate->ports[i]);
    }
    free(pPrivate->ports);
    pPrivate->ports=NULL;
  }

  pPrivate->BufferMgmtCallback = omx_audio_renderer_component_BufferMgmtCallback;
  omx_base_sink_Destructor(pComponent);

  nComponentInstances--;

  return OMX_ErrorNone;
}
/** The Destructor
 */
OMX_ERRORTYPE omx_xvideo_sink_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp) {
  omx_xvideo_sink_component_PrivateType* omx_xvideo_sink_component_Private = openmaxStandComp->pComponentPrivate;
  OMX_U32 i;

  /* frees port/s */
  if (omx_xvideo_sink_component_Private->ports) {
    for (i=0; i < (omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts); i++) {
      if(omx_xvideo_sink_component_Private->ports[i])
        omx_xvideo_sink_component_Private->ports[i]->PortDestructor(omx_xvideo_sink_component_Private->ports[i]);
    }
    free(omx_xvideo_sink_component_Private->ports);
    omx_xvideo_sink_component_Private->ports=NULL;
  }

  if(omx_xvideo_sink_component_Private->xvideoSyncSem) {
    tsem_deinit(omx_xvideo_sink_component_Private->xvideoSyncSem);
    free(omx_xvideo_sink_component_Private->xvideoSyncSem);
    omx_xvideo_sink_component_Private->xvideoSyncSem = NULL;
  }

  omx_base_sink_Destructor(openmaxStandComp);
  noxvideo_sinkInstance--;

  return OMX_ErrorNone;
}
/** The Destructor 
 */
OMX_ERRORTYPE omx_xvideo_sink_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp) {
  omx_xvideo_sink_component_PrivateType* omx_xvideo_sink_component_Private = openmaxStandComp->pComponentPrivate;
  OMX_U32 i;
 
  /* frees port/s */
  if (omx_xvideo_sink_component_Private->ports) {
    for (i=0; i < (omx_xvideo_sink_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts); i++) {
      if(omx_xvideo_sink_component_Private->ports[i])
        omx_xvideo_sink_component_Private->ports[i]->PortDestructor(omx_xvideo_sink_component_Private->ports[i]);
    }
    free(omx_xvideo_sink_component_Private->ports);
    omx_xvideo_sink_component_Private->ports=NULL;
  }

#ifdef AV_SYNC_LOG
   if(fd != NULL) {
      fclose(fd);
      fd = NULL;
   }
#endif

  omx_base_sink_Destructor(openmaxStandComp);
  noxvideo_sinkInstance--;

  return OMX_ErrorNone;
}