static void
alsa_destroy(cubeb * ctx)
{
  int r;

  assert(ctx);

  pthread_mutex_lock(&ctx->mutex);
  ctx->shutdown = 1;
  poll_wake(ctx);
  pthread_mutex_unlock(&ctx->mutex);

  r = pthread_join(ctx->thread, NULL);
  assert(r == 0);

  close(ctx->control_fd_read);
  close(ctx->control_fd_write);
  pthread_mutex_destroy(&ctx->mutex);
  free(ctx->fds);

  if (ctx->local_config) {
    pthread_mutex_lock(&cubeb_alsa_mutex);
    snd_config_delete(ctx->local_config);
    pthread_mutex_unlock(&cubeb_alsa_mutex);
  }

  free(ctx);
}
Exemple #2
0
void so_wake_poll(struct socket *so, struct sockbuf *sb)
{

    /* Read */
    if (&so->so_rcv == sb) {
        if (soreadable(so)) {
            poll_wake(so->fp, (POLLIN | POLLRDNORM));
            sb->sb_flags &= ~SB_SEL;
        }
    }

    /* Write */
    if (&so->so_snd == sb) {
        if (sowriteable(so)) {
            poll_wake(so->fp, (POLLOUT | POLLWRNORM));
            sb->sb_flags &= ~SB_SEL;
        }
    }
}
static void
alsa_set_stream_state(cubeb_stream * stm, enum stream_state state)
{
  cubeb * ctx;
  int r;

  ctx = stm->context;
  stm->state = state;
  r = pthread_cond_broadcast(&stm->cond);
  assert(r == 0);
  ctx->rebuild = 1;
  poll_wake(ctx);
}