/* * cmyth_livetv_wait() * * After starting live TV or after a channel change wait here until some * recording data is available. */ static int cmyth_livetv_wait(cmyth_recorder_t rec) { int i = 0, rc = -1; cmyth_conn_t conn; static int failures = 0; usleep(250000*failures); conn = cmyth_conn_reconnect(rec->rec_conn); while (i++ < 10) { int len; cmyth_proginfo_t prog; cmyth_file_t file; if (!cmyth_recorder_is_recording(rec)) { usleep(1000); continue; } prog = cmyth_recorder_get_cur_proginfo(rec); if (prog == NULL) { usleep(1000); continue; } file = cmyth_conn_connect_file(prog, conn, 4096, 4096); ref_release(prog); if (file == NULL) { if (failures < 4) { failures++; } usleep(1000); continue; } len = cmyth_file_request_block(file, 512); ref_release(file); if (len == 512) { rc = 0; break; } if (failures < 4) { failures++; } usleep(1000); } ref_release(conn); return rc; }
int cmyth_conn_reconnect_event(cmyth_conn_t conn) { int ret; cmyth_dbg(CMYTH_DBG_PROTO, "%s: re-connecting event channel connection\n", __FUNCTION__); ret = cmyth_conn_reconnect(conn, 1); cmyth_dbg(CMYTH_DBG_PROTO, "%s: done re-connecting event channel connection ret = %d\n", __FUNCTION__, ret); return ret; }
/* * cmyth_conn_reconnect_ctrl(cmyth_conn_t control) * * Scope: PUBLIC * * Description: * * Create a connection for use as a control connection within the * MythTV protocol. Return a pointer to the newly created connection. * The connection is returned held, and may be released using * ref_release(). * * Return Value: * * Success: 1 * * Failure: 0 */ int cmyth_conn_reconnect_ctrl(cmyth_conn_t control) { int ret; cmyth_dbg(CMYTH_DBG_PROTO, "%s: reconnecting control connection\n", __FUNCTION__); ret = cmyth_conn_reconnect(control, 0); if (ret) control->conn_hang = 0; cmyth_dbg(CMYTH_DBG_PROTO, "%s: done reconnecting control connection ret = %d\n", __FUNCTION__, ret); return ret; }