linuxdvb: add option to stop closing FEs and attempt to stop on retune

Rather than adding an explicit flag (to stop mux calls) on retune I
have moved the frontend close operation to be done in the background
monitor timer. This isn't foolproof but will cover most things
and I can probably add a delay to cause that to not execute immediately
should the timer be about to expire.
This commit is contained in:
Adam Sutton 2013-09-11 00:18:44 +01:00
parent ee03fde53a
commit 2a149671d6
2 changed files with 25 additions and 15 deletions

View file

@ -143,6 +143,12 @@ const idclass_t linuxdvb_frontend_class =
.name = "Full Mux RX mode",
.off = offsetof(linuxdvb_frontend_t, lfe_fullmux),
},
{
.type = PT_BOOL,
.id = "noclosefe",
.name = "Keep FE open",
.off = offsetof(linuxdvb_frontend_t, lfe_noclosefe),
},
{}
}
};
@ -269,18 +275,11 @@ linuxdvb_frontend_stop_mux
tvhdebug("linuxdvb", "%s - stopped dvr thread", buf1);
}
/* TODO: no way to know whether we need to close the FE or not */
if (lfe->lfe_fe_fd > 0) {
tvhtrace("linuxdvb", "%s - closing frontend", buf1);
close(lfe->lfe_fe_fd);
lfe->lfe_fe_fd = -1;
}
/* Stop monitor */
gtimer_disarm(&lfe->lfe_monitor_timer);
/* Not locked */
lfe->lfe_locked = 0;
/* Ensure it won't happen immediately */
gtimer_arm(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, 2);
}
static int
@ -475,6 +474,13 @@ linuxdvb_frontend_monitor ( void *aux )
lfe->mi_display_name((mpegts_input_t*)lfe, buf, sizeof(buf));
tvhtrace("linuxdvb", "%s - checking FE status", buf);
/* Close FE */
if (lfe->lfe_fe_fd > 0 && !mmi && !lfe->lfe_noclosefe) {
tvhtrace("linuxdvb", "%s - closing frontend", buf);
close(lfe->lfe_fe_fd);
lfe->lfe_fe_fd = -1;
}
/* Check accessibility */
if (lfe->lfe_fe_fd <= 0) {
if (lfe->lfe_fe_path && access(lfe->lfe_fe_path, R_OK | W_OK)) {
@ -484,6 +490,9 @@ linuxdvb_frontend_monitor ( void *aux )
}
}
gtimer_arm(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, 1);
if (!mmi) return;
/* Get current status */
if (ioctl(lfe->lfe_fe_fd, FE_READ_STATUS, &fe_status) == -1) {
tvhwarn("linuxdvb", "%s - FE_READ_STATUS error %s", buf, strerror(errno));
@ -500,11 +509,9 @@ linuxdvb_frontend_monitor ( void *aux )
status = SIGNAL_NONE;
/* Set default period */
gtimer_arm(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, 1);
tvhtrace("linuxdvb", "%s - status %d", buf, status);
/* Get current mux */
if (!mmi) return;
mm = mmi->mmi_mux;
/* Waiting for lock */
@ -796,9 +803,11 @@ linuxdvb_frontend_tune1
r = linuxdvb_frontend_tune0(lfe, mmi, freq);
/* Start monitor */
time(&lfe->lfe_monitor);
lfe->lfe_monitor += 4;
gtimer_arm_ms(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, 50);
if (!r) {
time(&lfe->lfe_monitor);
lfe->lfe_monitor += 4;
gtimer_arm_ms(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, 50);
}
return r;
}

View file

@ -144,6 +144,7 @@ struct linuxdvb_frontend
* Configuration
*/
int lfe_fullmux;
int lfe_noclosefe;
/*
* Callbacks