Beispiel #1
0
void
timeshift_destroy(streaming_target_t *pad)
{
  timeshift_t *ts = (timeshift_t*)pad;
  streaming_message_t *sm;
  int i;

  /* Must hold global lock */
  lock_assert(&global_lock);

  /* Ensure the threads exits */
  // Note: this is a workaround for the fact the Q might have been flushed
  //       in reader thread (VERY unlikely)
  pthread_mutex_lock(&ts->state_mutex);
  sm = streaming_msg_create(SMT_EXIT);
  streaming_target_deliver2(&ts->wr_queue.sq_st, sm);
  timeshift_write_exit(ts->rd_pipe.wr);
  pthread_mutex_unlock(&ts->state_mutex);

  /* Wait for all threads */
  pthread_join(ts->rd_thread, NULL);
  pthread_join(ts->wr_thread, NULL);

  /* Shut stuff down */
  streaming_queue_deinit(&ts->wr_queue);
  for (i = 0; i < TIMESHIFT_BACKLOG_MAX; i++)
    streaming_queue_clear(&ts->backlog[i]);

  close(ts->rd_pipe.rd);
  close(ts->rd_pipe.wr);

  /* Flush files */
  timeshift_filemgr_flush(ts, NULL);

  /* Release SMT_START index */
  if (ts->smt_start)
    streaming_start_unref(ts->smt_start);

  if (ts->path)
    free(ts->path);
  free(ts);
}
Beispiel #2
0
void
dvr_rec_unsubscribe(dvr_entry_t *de, int stopcode)
{
  assert(de->de_s != NULL);

  subscription_unsubscribe(de->de_s);

  streaming_target_deliver(&de->de_sq.sq_st, streaming_msg_create(SMT_EXIT));
  
  pthread_join(de->de_thread, NULL);
  de->de_s = NULL;

  if(de->de_tsfix)
    tsfix_destroy(de->de_tsfix);

  if(de->de_gh)
    globalheaders_destroy(de->de_gh);

  de->de_last_error = stopcode;
}
Beispiel #3
0
void
timeshift_destroy(streaming_target_t *pad)
{
  timeshift_t *ts = (timeshift_t*)pad;
  streaming_message_t *sm;

  /* Must hold global lock */
  lock_assert(&global_lock);

  /* Ensure the threads exits */
  // Note: this is a workaround for the fact the Q might have been flushed
  //       in reader thread (VERY unlikely)
  pthread_mutex_lock(&ts->state_mutex);
  sm = streaming_msg_create(SMT_EXIT);
  streaming_target_deliver2(&ts->wr_queue.sq_st, sm);
  if (!ts->exit)
    timeshift_write_exit(ts->rd_pipe.wr);
  pthread_mutex_unlock(&ts->state_mutex);

  /* Wait for all threads */
  pthread_join(ts->rd_thread, NULL);
  pthread_join(ts->wr_thread, NULL);

  /* Shut stuff down */
  streaming_queue_deinit(&ts->wr_queue);

  close(ts->rd_pipe.rd);
  close(ts->rd_pipe.wr);

  /* Flush files */
  timeshift_filemgr_flush(ts, NULL);

  if (ts->smt_start)
    streaming_start_unref(ts->smt_start);

  if (ts->path)
    free(ts->path);

  free(ts);
  memoryinfo_free(&timeshift_memoryinfo, sizeof(timeshift_t));
}
Beispiel #4
0
void
dvr_rec_unsubscribe(dvr_entry_t *de, int stopcode)
{
  profile_chain_t *prch = de->de_chain;

  assert(de->de_s != NULL);
  assert(prch != NULL);

  streaming_target_deliver(prch->prch_st, streaming_msg_create(SMT_EXIT));
  
  pthread_join(de->de_thread, NULL);

  subscription_unsubscribe(de->de_s);
  de->de_s = NULL;

  de->de_chain = NULL;
  profile_chain_close(prch);
  free(prch);

  de->de_last_error = stopcode;
}
Beispiel #5
0
void
dvr_rec_unsubscribe(dvr_entry_t *de, int stopcode)
{
  dvr_config_t *cfg = dvr_config_find_by_name_default(de->de_config_name);
  assert(de->de_s != NULL);

  subscription_unsubscribe(de->de_s);

  streaming_target_deliver(&de->de_sq.sq_st, streaming_msg_create(SMT_EXIT));
  
  pthread_join(de->de_thread, NULL);
  de->de_s = NULL;

  if(strcmp(cfg->dvr_format, "matroska") == 0) {
    tsfix_destroy(de->de_tsfix);
    globalheaders_destroy(de->de_gh);
  // } else if { (Other containers)
  // mpegts works like rawts
  }

  de->de_last_error = stopcode;
}