cmyth_chain_t cmyth_chain_create(cmyth_recorder_t rec, char *chain_id) { cmyth_chain_t chain; struct event_loop_args *args; args = ref_alloc(sizeof(*args)); chain = ref_alloc(sizeof(*chain)); chain->chain_id = ref_strdup(chain_id); chain->chain_count = 0; chain->chain_current = -1; chain->chain_list = NULL; chain->chain_callback = NULL; chain->chain_event = NULL; chain->chain_thread = 0; chain->chain_conn = ref_hold(rec->rec_conn); pthread_mutex_init(&chain->chain_mutex, NULL); pthread_cond_init(&chain->chain_cond, NULL); ref_set_destroy(chain, (ref_destroy_t)cmyth_chain_destroy); args->rec = ref_hold(rec); args->chain = ref_hold(chain); chain->chain_thread_args = (void*)args; pthread_create(&chain->chain_thread, NULL, cmyth_chain_event_loop, (void*)args); return chain; }
/** * Allocate a dynamic query string to have parameters added to it * \param db database connection object * \param query_string Query string with ? placemarks for all dynamic * parameters, this is NOT copied and must therefore * remain valid for the life of the query. */ cmyth_mysql_query_t * cmyth_mysql_query_create(cmyth_database_t db, const char * query_string) { cmyth_mysql_query_t * out; out = ref_alloc(sizeof(*out)); if(out != NULL) { ref_set_destroy(out,query_destroy); out->source = out->source_pos = query_string; out->source_len = strlen(out->source); out->buf_size = out->source_len *2; out->buf_used = 0; out->db = ref_hold(db); out->buf = ref_alloc(out->buf_size); if(out->buf == NULL) { ref_release(out); out = NULL; } else { out->buf[0] = '\0'; } } return out; }
void thread_destroy(struct thread *t) { if (t != NULL) { thread_clear(t); vm_stack_destroy(t->vm_stack); free(t->ref_buckets); ref_set_destroy(t->excluded_set); #ifdef DMP if (t->dmp != NULL) thread_dmp_destroy(t->dmp); #endif heap_free(heap, t); free(t->free_buckets); } }
cmyth_storagegroup_file_t cmyth_storagegroup_file_create(void) { cmyth_storagegroup_file_t ret = ref_alloc(sizeof(*ret)); memset(ret, 0, sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_storagegroup_file_destroy); return ret; }
/* * cmyth_recordingrule_create() * * Scope: PRIVATE * * Description * * Create a recording schedule structure to be used to hold channel and return * a pointer to the structure. * Before forgetting the reference to this recording schedule structure the * caller must call ref_release(). * * Return Value: * * Success: A non-NULL cmyth_channel_t (this type is a pointer) * * Failure: NULL */ cmyth_recordingrule_t cmyth_recordingrule_create(void) { cmyth_recordingrule_t ret = ref_alloc(sizeof(*ret)); memset(ret, 0, sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s: ref_alloc() failed\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_recordingrule_destroy); return ret; }
/* * cmyth_posmap_create(void) * * Scope: PUBLIC * * Description * * Allocate and initialize a position map structure. * * Return Value: * * Success: A non-NULL cmyth_posmap_t (this type is a pointer) * * Failure: A NULL cmyth_posmap_t */ cmyth_posmap_t cmyth_posmap_create(void) { cmyth_posmap_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); if (!ret) { return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_posmap_destroy); ret->posmap_count = 0; ret->posmap_list = NULL; return ret; }
/* * cmyth_rec_num_create(void) * * Scope: PUBLIC * * Description * * Create a recorder number structure. * * Return Value: * * Success: A non-NULL cmyth_rec_num_t (this type is a pointer) * * Failure: A NULL cmyth_rec_num_t */ cmyth_rec_num_t cmyth_rec_num_create(void) { cmyth_rec_num_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); if (!ret) { return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_rec_num_destroy); ret->recnum_host = NULL; ret->recnum_port = 0; ret->recnum_id = 0; return ret; }
cmyth_commbreaklist_t cmyth_commbreaklist_create(void) { cmyth_commbreaklist_t ret; cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); ret = ref_alloc(sizeof(*ret)); if (!ret) { return(NULL); } ref_set_destroy(ret, (ref_destroy_t)cmyth_commbreaklist_destroy); ret->commbreak_list = NULL; ret->commbreak_count = 0; return ret; }
/* * cmyth_proglist_create() * * Scope: PUBLIC * * Description * * Create a timestamp structure and return a pointer to the structure. * * Return Value: * * Success: A non-NULL cmyth_proglist_t (this type is a pointer) * * Failure: A NULL cmyth_proglist_t */ cmyth_proglist_t cmyth_proglist_create(void) { cmyth_proglist_t ret; cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); ret = ref_alloc(sizeof(*ret)); if (!ret) { return(NULL); } ref_set_destroy(ret, (ref_destroy_t)cmyth_proglist_destroy); ret->proglist_list = NULL; ret->proglist_count = 0; pthread_mutex_init(&ret->proglist_mutex, NULL); return ret; }
cmyth_commbreak_t cmyth_commbreak_create(void) { cmyth_commbreak_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_commbreak_destroy); ret->start_mark = 0; ret->start_offset = 0; ret->end_mark = 0; ret->end_offset = 0; cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__); return ret; }
/* * cmyth_livetv_chain_create(void) * * Scope: PUBLIC * * Description * * Allocate and initialize a ring buffer structure. * * Return Value: * * Success: A non-NULL cmyth_livetv_chain_t (this type is a pointer) * * Failure: A NULL cmyth_livetv_chain_t */ cmyth_livetv_chain_t cmyth_livetv_chain_create(char * chainid) { cmyth_livetv_chain_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); if (!ret) { return NULL; } ret->chainid = ref_strdup(chainid); ret->chain_ct = 0; ret->chain_switch_on_create = 0; ret->chain_current = -1; ret->chain_urls = NULL; ret->chain_files = NULL; ret->progs = NULL; ref_set_destroy(ret, (ref_destroy_t)cmyth_livetv_chain_destroy); return ret; }
/* * cmyth_conn_create(void) * * Scope: PRIVATE (static) * * Description * * Allocate and initialize a cmyth_conn_t structure. This should only * be called by cmyth_connect(), which establishes a connection. * * Return Value: * * Success: A non-NULL cmyth_conn_t (this type is a pointer) * * Failure: A NULL cmyth_conn_t */ static cmyth_conn_t cmyth_conn_create(void) { cmyth_conn_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_conn_destroy); ret->conn_fd = -1; ret->conn_buf = NULL; ret->conn_len = 0; ret->conn_buflen = 0; ret->conn_pos = 0; ret->conn_hang = 0; cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__); return ret; }
cmyth_input_t cmyth_input_create(void) { cmyth_input_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_input_destroy); ret->inputname = NULL; ret->sourceid = 0; ret->inputid = 0; ret->cardid = 0; ret->multiplexid = 0; cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__); return ret; }
/* * cmyth_ringbuf_create(void) * * Scope: PUBLIC * * Description * * Allocate and initialize a ring buffer structure. * * Return Value: * * Success: A non-NULL cmyth_ringbuf_t (this type is a pointer) * * Failure: A NULL cmyth_ringbuf_t */ cmyth_ringbuf_t cmyth_ringbuf_create(void) { cmyth_ringbuf_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); if (!ret) { return NULL; } ret->conn_data = NULL; ret->ringbuf_url = NULL; ret->ringbuf_size = 0; ret->ringbuf_fill = 0; ret->file_pos = 0; ret->file_id = 0; ret->ringbuf_hostname = NULL; ret->ringbuf_port = 0; ref_set_destroy(ret, (ref_destroy_t)cmyth_ringbuf_destroy); return ret; }
/* * cmyth_recorder_create() * * Scope: PUBLIC * * Description * * Allocate and initialize a cmyth recorder structure. * * Return Value: * * Success: A non-NULL cmyth_recorder_t (this type is a pointer) * * Failure: A NULL cmyth_recorder_t */ cmyth_recorder_t cmyth_recorder_create(void) { cmyth_recorder_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); if (!ret) { return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_recorder_destroy); ret->rec_server = NULL; ret->rec_port = 0; ret->rec_have_stream = 0; ret->rec_id = 0; ret->rec_ring = NULL; ret->rec_conn = NULL; ret->rec_framerate = 0.0; ret->rec_livetv_chain = NULL; ret->rec_livetv_file = NULL; return ret; }
/* * cmyth_file_create(cmyth_conn_t control) * * Scope: PRIVATE (mapped to __cmyth_file_create) * * Description * * Allocate and initialize a cmyth_file_t structure. This should only * be called by cmyth_connect_file(), which establishes a file * transfer connection. * * Return Value: * * Success: A non-NULL cmyth_file_t (this type is a pointer) * * Failure: A NULL cmyth_file_t */ cmyth_file_t cmyth_file_create(cmyth_conn_t control) { cmyth_file_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_file_destroy); ret->file_control = ref_hold(control); ret->file_data = NULL; ret->file_id = -1; ret->file_start = 0; ret->file_length = 0; ret->file_pos = 0; ret->closed_callback = NULL; cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__); return ret; }
/* * cmyth_livetv_chain_create(void) * * Scope: PUBLIC * * Description * * Allocate and initialize a ring buffer structure. * * Return Value: * * Success: A non-NULL cmyth_livetv_chain_t (this type is a pointer) * * Failure: A NULL cmyth_livetv_chain_t */ cmyth_livetv_chain_t cmyth_livetv_chain_create(char * chainid) { cmyth_livetv_chain_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s\n", __FUNCTION__); if (!ret) { return NULL; } ret->chainid = ref_strdup(chainid); ret->chain_ct = 0; ret->chain_switch_on_create = 0; ret->chain_current = -1; ret->chain_urls = NULL; ret->chain_files = NULL; ret->progs = NULL; ret->livetv_watch = 0; /* JLB: Manage program breaks. Set to 1 on chain setup */ ret->livetv_tcp_rcvbuf = 0; ref_set_destroy(ret, (ref_destroy_t)cmyth_livetv_chain_destroy); return ret; }
/* * cmyth_proginfo_create(void) * * Scope: PUBLIC * * Description * * Create a programinfo structure to be used to hold program * information and return a pointer to the structure. The structure * is initialized to default values. * * Return Value: * * Success: A non-NULL cmyth_proginfo_t (this type is a pointer) * * Failure: A NULL cmyth_proginfo_t */ cmyth_proginfo_t cmyth_proginfo_create(void) { cmyth_proginfo_t ret = ref_alloc(sizeof(*ret)); cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_proginfo_destroy); ret->proginfo_start_ts = cmyth_timestamp_create(); if (!ret->proginfo_start_ts) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!!\n", __FUNCTION__); goto err; } ret->proginfo_end_ts = cmyth_timestamp_create(); if (!ret->proginfo_end_ts) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!!!\n", __FUNCTION__); goto err; } ret->proginfo_rec_start_ts = cmyth_timestamp_create(); if (!ret->proginfo_rec_start_ts) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!!!!\n", __FUNCTION__); goto err; } ret->proginfo_rec_end_ts = cmyth_timestamp_create(); if (!ret->proginfo_rec_end_ts) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s } !!!!!\n", __FUNCTION__); goto err; } ret->proginfo_lastmodified = cmyth_timestamp_create(); if (!ret->proginfo_lastmodified) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s } !!!!!!\n", __FUNCTION__); goto err; } ret->proginfo_originalairdate = cmyth_timestamp_create(); if (!ret->proginfo_originalairdate) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s } !!!!!!!\n", __FUNCTION__); goto err; } ret->proginfo_title = NULL; ret->proginfo_subtitle = NULL; ret->proginfo_description = NULL; ret->proginfo_season = 0; ret->proginfo_episode = 0; ret->proginfo_category = NULL; ret->proginfo_chanId = 0; ret->proginfo_chanstr = NULL; ret->proginfo_chansign = NULL; ret->proginfo_channame = NULL; ret->proginfo_chanicon = NULL; ret->proginfo_url = NULL; ret->proginfo_pathname = NULL; ret->proginfo_host = NULL; ret->proginfo_port = -1; ret->proginfo_Length = 0; ret->proginfo_conflicting = 0; ret->proginfo_unknown_0 = NULL; ret->proginfo_recording = 0; ret->proginfo_override = 0; ret->proginfo_hostname = NULL; ret->proginfo_source_id = 0; ret->proginfo_card_id = 0; ret->proginfo_input_id = 0; ret->proginfo_rec_priority = 0; ret->proginfo_rec_status = 0; ret->proginfo_record_id = 0; ret->proginfo_rec_type = 0; ret->proginfo_rec_dups = 0; ret->proginfo_unknown_1 = 0; ret->proginfo_repeat = 0; ret->proginfo_program_flags = 0; ret->proginfo_rec_profile = NULL; ret->proginfo_recgroup = NULL; ret->proginfo_chancommfree = NULL; ret->proginfo_chan_output_filters = NULL; ret->proginfo_seriesid = NULL; ret->proginfo_programid = NULL; ret->proginfo_inetref = NULL; ret->proginfo_stars = NULL; ret->proginfo_version = 12; ret->proginfo_hasairdate = 0; ret->proginfo_playgroup = NULL; ret->proginfo_storagegroup = NULL; ret->proginfo_recpriority_2 = NULL; ret->proginfo_parentid = 0; ret->proginfo_audioproperties = 0; ret->proginfo_videoproperties = 0; ret->proginfo_subtitletype = 0; ret->proginfo_year = 0; cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__); return ret; err: ref_release(ret); cmyth_dbg(CMYTH_DBG_DEBUG, "%s } !++\n", __FUNCTION__); return NULL; }
/* * cmyth_proginfo_create(void) * * Scope: PRIVATE (static) * * Description * * Duplicate a program information structure into a new one. The sub-fields * get held, not actually copied. * * Return Value: * * Success: A non-NULL cmyth_proginfo_t (this type is a pointer) * * Failure: A NULL cmyth_proginfo_t */ static cmyth_proginfo_t cmyth_proginfo_dup(cmyth_proginfo_t p) { cmyth_proginfo_t ret = cmyth_proginfo_create(); cmyth_dbg(CMYTH_DBG_DEBUG, "%s {\n", __FUNCTION__); if (!ret) { cmyth_dbg(CMYTH_DBG_DEBUG, "%s }!\n", __FUNCTION__); return NULL; } ref_set_destroy(ret, (ref_destroy_t)cmyth_proginfo_destroy); ret->proginfo_start_ts = ref_hold(p->proginfo_start_ts); ret->proginfo_end_ts = ref_hold(p->proginfo_end_ts); ret->proginfo_rec_start_ts = ref_hold(p->proginfo_rec_start_ts); ret->proginfo_rec_end_ts = ref_hold(p->proginfo_rec_end_ts); ret->proginfo_lastmodified = ref_hold(p->proginfo_lastmodified); ret->proginfo_originalairdate = ref_hold(p->proginfo_originalairdate); ret->proginfo_title = ref_hold(p->proginfo_title); ret->proginfo_subtitle = ref_hold(p->proginfo_subtitle); ret->proginfo_description = ref_hold(p->proginfo_description); ret->proginfo_season = p->proginfo_season; ret->proginfo_episode = p->proginfo_episode; ret->proginfo_category = ref_hold(p->proginfo_category); ret->proginfo_chanId = p->proginfo_chanId; ret->proginfo_chanstr = ref_hold(p->proginfo_chanstr); ret->proginfo_chansign = ref_hold(p->proginfo_chansign); ret->proginfo_channame = ref_hold(p->proginfo_channame); ret->proginfo_chanicon = ref_hold(p->proginfo_chanicon); ret->proginfo_url = ref_hold(p->proginfo_url); ret->proginfo_pathname = ref_hold(p->proginfo_pathname); ret->proginfo_host = ref_hold(p->proginfo_host); ret->proginfo_port = p->proginfo_port; ret->proginfo_Length = p->proginfo_Length; ret->proginfo_conflicting = p->proginfo_conflicting; ret->proginfo_unknown_0 = ref_hold(p->proginfo_unknown_0); ret->proginfo_recording = p->proginfo_recording; ret->proginfo_override = p->proginfo_override; ret->proginfo_hostname = ref_hold(p->proginfo_hostname); ret->proginfo_source_id = p->proginfo_source_id; ret->proginfo_card_id = p->proginfo_card_id; ret->proginfo_input_id = p->proginfo_input_id; ret->proginfo_rec_priority = ref_hold(p->proginfo_rec_priority); ret->proginfo_rec_status = p->proginfo_rec_status; ret->proginfo_record_id = p->proginfo_record_id; ret->proginfo_rec_type = p->proginfo_rec_type; ret->proginfo_rec_dups = p->proginfo_rec_dups; ret->proginfo_unknown_1 = p->proginfo_unknown_1; ret->proginfo_repeat = p->proginfo_repeat; ret->proginfo_program_flags = p->proginfo_program_flags; ret->proginfo_rec_profile = ref_hold(p->proginfo_rec_profile); ret->proginfo_recgroup = ref_hold(p->proginfo_recgroup); ret->proginfo_chancommfree = ref_hold(p->proginfo_chancommfree); ret->proginfo_chan_output_filters = ref_hold(p->proginfo_chan_output_filters); ret->proginfo_seriesid = ref_hold(p->proginfo_seriesid); ret->proginfo_programid = ref_hold(p->proginfo_programid); ret->proginfo_inetref = ref_hold(p->proginfo_inetref); ret->proginfo_stars = ref_hold(p->proginfo_stars); ret->proginfo_version = p->proginfo_version; ret->proginfo_hasairdate = p->proginfo_hasairdate; ret->proginfo_playgroup = ref_hold(p->proginfo_playgroup); ret->proginfo_storagegroup = ref_hold(p->proginfo_storagegroup); ret->proginfo_recpriority_2 = ref_hold(p->proginfo_recpriority_2); ret->proginfo_parentid = p->proginfo_parentid; ret->proginfo_audioproperties = p->proginfo_audioproperties; ret->proginfo_videoproperties = p->proginfo_videoproperties; ret->proginfo_subtitletype = p->proginfo_subtitletype; ret->proginfo_year = p->proginfo_year; cmyth_dbg(CMYTH_DBG_DEBUG, "%s }\n", __FUNCTION__); return ret; }