mpegts: ensure that potentially valid muxes are not ignored

It's possible a mux is not tunable, yet that doesn't imply the presence
of a free tuner means its invalid. It could just be that its an S2 mux
with only an S tuner available (just one example).
This commit is contained in:
Adam Sutton 2013-09-11 09:03:31 +01:00
parent f7cb2fd74d
commit e74f993b76
3 changed files with 25 additions and 3 deletions

View file

@ -374,7 +374,11 @@ mpegts_mux_start
if (!tune) {
tvhdebug("mpegts", "%s - no free input (fail=%d)", buf, fail);
return havefree ? SM_CODE_TUNING_FAILED : SM_CODE_NO_FREE_ADAPTER;
LIST_FOREACH(mmi, &mm->mm_instances, mmi_mux_link)
if (!mmi->mmi_tune_failed)
return havefree ? SM_CODE_NO_VALID_ADAPTER : SM_CODE_NO_FREE_ADAPTER;
tvhdebug("mpegts", "%s - tuning failed", buf);
return SM_CODE_TUNING_FAILED;
}
return 0;

View file

@ -238,10 +238,14 @@ mpegts_network_initial_scan(void *aux)
{
int r;
mpegts_network_t *mn = aux;
mpegts_mux_t *mm;
mpegts_mux_t *mm, *mark = NULL;
tvhtrace("mpegts", "setup initial scan for %p", mn);
while((mm = TAILQ_FIRST(&mn->mn_initial_scan_pending_queue)) != NULL) {
/* Stop */
if (mm == mark) break;
assert(mm->mm_initial_scan_status == MM_SCAN_PENDING);
r = mpegts_mux_subscribe(mm, "initscan", 1);
@ -255,8 +259,21 @@ mpegts_network_initial_scan(void *aux)
continue;
}
/* Remove */
TAILQ_REMOVE(&mn->mn_initial_scan_pending_queue, mm, mm_initial_scan_link);
/* Available tuners can't be used
* Note: this is subtly different it does not imply there are no free
* tuners, just that none of the free ones can service this mux.
* therefore we move this to the back of the queue and see if we
* can find one we can tune
*/
if (r == SM_CODE_NO_VALID_ADAPTER) {
if (!mark) mark = mm;
TAILQ_INSERT_TAIL(&mn->mn_initial_scan_pending_queue, mm, mm_initial_scan_link);
continue;
}
/* Remove */
mpegts_mux_initial_scan_fail(mm);
}
gtimer_arm(&mn->mn_initial_scan_timer, mpegts_network_initial_scan, mn, 10);

View file

@ -371,6 +371,7 @@ typedef enum {
#define SM_CODE_BAD_SIGNAL 205
#define SM_CODE_NO_SOURCE 206
#define SM_CODE_NO_SERVICE 207
#define SM_CODE_NO_VALID_ADAPTER 308
#define SM_CODE_ABORTED 300