예제 #1
0
void
media_global_hold(int on, int flag)
{
  int i;
  int count;
  media_pipe_t *mp;

  hts_mutex_lock(&media_mutex);
  count = num_media_pipelines;
  media_pipe_t **mpv = alloca(count * sizeof(media_pipe_t *));

  i = 0;
  LIST_FOREACH(mp, &media_pipelines, mp_global_link)
    mpv[i++] = mp_retain(mp);

  hts_mutex_unlock(&media_mutex);

  for(i = 0; i < count; i++) {
    mp = mpv[i];
    
    if(!(mp->mp_flags & MP_VIDEO))
      continue;

    if(on)
      mp_hold(mp, flag, NULL);
    else
      mp_unhold(mp, flag);

    mp_release(mp);
  }
}
예제 #2
0
int
mp_lockmgr(void *ptr, lockmgr_op_t op)
{
  media_pipe_t *mp = ptr;

  switch(op) {
  case LOCKMGR_UNLOCK:
    hts_mutex_unlock(&mp->mp_mutex);
    return 0;
  case LOCKMGR_LOCK:
    hts_mutex_lock(&mp->mp_mutex);
    return 0;
  case LOCKMGR_TRY:
    return hts_mutex_trylock(&mp->mp_mutex);

  case LOCKMGR_RETAIN:
    atomic_inc(&mp->mp_refcount);
    return 0;

  case LOCKMGR_RELEASE:
    mp_release(mp);
    return 0;
  }
  abort();
}
예제 #3
0
void
mp_destroy(media_pipe_t *mp)
{
  hts_mutex_lock(&media_mutex);
  LIST_REMOVE(mp, mp_global_link);
  num_media_pipelines--;
  hts_mutex_unlock(&media_mutex);

  mp_unbecome_primary(mp);

  assert(mp->mp_sub_currenttime != NULL);

  hts_mutex_lock(&mp->mp_mutex);

  prop_unsubscribe(mp->mp_sub_currenttime);
  prop_unsubscribe(mp->mp_sub_eventsink);

#if ENABLE_MEDIA_SETTINGS
  mp_settings_clear(mp);
#endif

  mp_track_mgr_destroy(&mp->mp_audio_track_mgr);
  mp_track_mgr_destroy(&mp->mp_subtitle_track_mgr);

  hts_mutex_unlock(&mp->mp_mutex);

  mp_release(mp);

}
예제 #4
0
void
video_decoder_stop(video_decoder_t *vd)
{
  media_pipe_t *mp = vd->vd_mp;

  mp_send_cmd(mp, &mp->mp_video, MB_CTRL_EXIT);

  hts_thread_join(&vd->vd_decoder_thread);
  mp_release(vd->vd_mp);
  vd->vd_mp = NULL;
}
예제 #5
0
static void
mp_unbecome_primary(media_pipe_t *mp)
{
  hts_mutex_lock(&media_mutex);

  assert(mp->mp_flags & MP_PRIMABLE);

  if(media_primary == mp) {
    /* We were primary */
    prop_set_int(mp->mp_prop_primary, 0);
    prop_unlink(media_prop_current);

    media_primary = NULL;
    mp_release(mp); // mp could be free'd here */
    prop_unselect(media_prop_sources);
  }
  hts_mutex_unlock(&media_mutex);
}