Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
descrambler: do not allow to open new pids when flushed
  • Loading branch information
perexg committed Sep 17, 2014
1 parent a766245 commit a7f80d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/descrambler/descrambler.c
Expand Up @@ -134,6 +134,7 @@ descrambler_service_start ( service_t *t )
dr->dr_key_index = 0xff;
dr->dr_last_descramble = dispatch_clock;
}
((mpegts_service_t *)t)->s_dvb_mux->mm_descrambler_flush = 0;
}

void
Expand Down Expand Up @@ -507,6 +508,8 @@ descrambler_open_pid_( mpegts_mux_t *mux, void *opaque, int pid,

if (mux == NULL)
return 0;
if (mux->mm_descrambler_flush)
return 0;
flags = pid >> 16;
pid &= 0x1fff;
TAILQ_FOREACH(dt, &mux->mm_descrambler_tables, link) {
Expand Down Expand Up @@ -605,6 +608,7 @@ descrambler_flush_tables( mpegts_mux_t *mux )
cwc_caid_update(mux, 0, 0, -1);
#endif
pthread_mutex_lock(&mux->mm_descrambler_lock);
mux->mm_descrambler_flush = 1;
while ((dt = TAILQ_FIRST(&mux->mm_descrambler_tables)) != NULL) {
while ((ds = TAILQ_FIRST(&dt->sections)) != NULL) {
TAILQ_REMOVE(&dt->sections, ds, link);
Expand Down Expand Up @@ -703,8 +707,11 @@ descrambler_open_emm( mpegts_mux_t *mux, void *opaque, int caid,
if (mux == NULL)
return 0;
pthread_mutex_lock(&mux->mm_descrambler_lock);
if (mux->mm_descrambler_flush)
goto unlock;
TAILQ_FOREACH(emm, &mux->mm_descrambler_emms, link) {
if (emm->caid == caid && emm->opaque == opaque) {
unlock:
pthread_mutex_unlock(&mux->mm_descrambler_lock);
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/input/mpegts.h
Expand Up @@ -388,6 +388,7 @@ struct mpegts_mux
TAILQ_HEAD(, descrambler_table) mm_descrambler_tables;
TAILQ_HEAD(, descrambler_emm) mm_descrambler_emms;
pthread_mutex_t mm_descrambler_lock;
int mm_descrambler_flush;

/*
* Functions
Expand Down

0 comments on commit a7f80d2

Please sign in to comment.