Exemple #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);
  }
}
Exemple #2
0
void
mp_become_primary(struct media_pipe *mp)
{
  mp_init_audio(mp);

  if(media_primary == mp)
    return;

  hts_mutex_lock(&media_mutex);

  assert(mp->mp_flags & MP_PRIMABLE);

  if(media_primary != NULL) {
    prop_set_int(media_primary->mp_prop_primary, 0);

    event_t *e = event_create_action(ACTION_STOP);
    mp_enqueue_event(media_primary, e);
    event_release(e);
  }

  media_primary = mp_retain(mp);

  prop_select(mp->mp_prop_root);
  prop_link(mp->mp_prop_root, media_prop_current);
  prop_set_int(mp->mp_prop_primary, 1);

  hts_mutex_unlock(&media_mutex);
}
Exemple #3
0
int mp_register(mempool_priv_t *mp_priv, const char *name)
{
	int fd;
	int size;
	mempool_t *mp;
	int i, entries;

	fd = shm_open(name, O_RDWR, S_IRUSR|S_IWUSR);
	if (fd < 0) {
		fprintf(stderr, "can't open shared memory %s\n", name);
		return -1;
	}
	size = lseek(fd, 0L, SEEK_END);

	mp = mmap(NULL, size, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0);
	if ((long)mp == -1) {
		close(fd);
		return -1;
	}

	mp_retain(mp);

	mp_priv->mp = mp;
	entries = mp_priv->entries = mp->entries;
	memset(mp_priv->fds, -1, sizeof(int) * MEM_POOL_MAX_FDS);

	mp_priv->bucket[0] = (mp_ring_t *)((char *)mp + sizeof(mempool_t));
	for (i = 1; i < mp->buckets; i++) {
		mp_priv->bucket[i] = (mp_ring_t *)((char *)mp_priv->bucket[i-1]
						   + sizeof(mp_ring_t)
						   + sizeof(void *) * entries);
	}

	mp_priv->data = (mp_buf_t *)((char *)mp_priv->bucket[mp->buckets-1]
		      + sizeof(mp_ring_t) + sizeof(void *) * entries);
	if ((uintptr_t)mp_priv->data & __cache_line_mask) {
		fprintf(stderr, "buf not cache aligned\n");
		goto error;
	}

	close(fd);

	return 0;

 error:
	close(fd);
	atomic_sub_fetch(&mp->refcnt, 1);
	munmap(mp, size);

	return -1;
}
Exemple #4
0
video_decoder_t *
video_decoder_create(media_pipe_t *mp)
{
  video_decoder_t *vd = calloc(1, sizeof(video_decoder_t));

  vd->vd_mp = mp_retain(mp);

  vd_init_timings(vd);

  hts_thread_create_joinable("video decoder", 
			     &vd->vd_decoder_thread, vd_thread, vd,
			     THREAD_PRIO_VIDEO);
  
  return vd;
}