static int om_mux_cmp ( epggrab_ota_mux_t *a, epggrab_ota_mux_t *b ) { mpegts_mux_t *a1 = mpegts_mux_find0(&a->om_mux_uuid); mpegts_mux_t *b1 = mpegts_mux_find0(&b->om_mux_uuid); if (a1 == NULL || b1 == NULL) { if (a1 == NULL && b1 == NULL) return 0; return a1 == NULL ? 1 : -1; } return mpegts_mux_compare(a1, b1); }
static void epggrab_ota_done ( epggrab_ota_mux_t *om, int reason ) { static const char *reasons[] = { [EPGGRAB_OTA_DONE_COMPLETE] = "complete", [EPGGRAB_OTA_DONE_TIMEOUT] = "timeout", [EPGGRAB_OTA_DONE_NO_DATA] = "no data", [EPGGRAB_OTA_DONE_STOLEN] = "stolen" }; char ubuf[UUID_HEX_SIZE]; mpegts_mux_t *mm; epggrab_ota_map_t *map; if (om->om_save) epggrab_ota_save(om); mm = mpegts_mux_find0(&om->om_mux_uuid); if (mm == NULL) { tvhdebug(LS_EPGGRAB, "unable to find mux %s (grab done: %s)", uuid_get_hex(&om->om_mux_uuid, ubuf), reasons[reason]); return; } tvhdebug(LS_EPGGRAB, "grab done for %s (%s)", mm->mm_nicename, reasons[reason]); mtimer_disarm(&om->om_timer); mtimer_disarm(&om->om_data_timer); mtimer_disarm(&om->om_handlers_timer); assert(om->om_q_type == EPGGRAB_OTA_MUX_ACTIVE); TAILQ_REMOVE(&epggrab_ota_active, om, om_q_link); om->om_q_type = EPGGRAB_OTA_MUX_IDLE; LIST_FOREACH(map, &om->om_modules, om_link) if (map->om_module->stop) map->om_module->stop(map, mm); if (reason == EPGGRAB_OTA_DONE_STOLEN) { /* Do not requeue completed muxes */ if (!om->om_done && om->om_requeue) { TAILQ_INSERT_HEAD(&epggrab_ota_pending, om, om_q_link); om->om_q_type = EPGGRAB_OTA_MUX_PENDING; } else { om->om_requeue = 0; } } else if (reason == EPGGRAB_OTA_DONE_TIMEOUT) { om->om_requeue = 0; LIST_FOREACH(map, &om->om_modules, om_link) if (!map->om_complete) tvhwarn(LS_EPGGRAB, "%s - data completion timeout for %s", map->om_module->name, mm->mm_nicename); } else {