Changeset 9320
- Timestamp:
- 01/13/14 21:20:48 (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-dvbapi.c
r9319 r9320 1193 1193 if(demux[demux_id].ca_mask & (1 << i)) 1194 1194 { 1195 bool actionneeded = false;1195 int8_t action = 0; 1196 1196 if(enable){ 1197 action needed = !update_streampid_list(i, demux[demux_id].STREAMpids[num], idx);1197 action = update_streampid_list(i, demux[demux_id].STREAMpids[num], idx); 1198 1198 } 1199 1199 if(!enable){ 1200 action needed= remove_streampid_from_list(i, demux[demux_id].STREAMpids[num], idx);1200 action = remove_streampid_from_list(i, demux[demux_id].STREAMpids[num], idx); 1201 1201 } 1202 1202 1203 1203 1204 if(currentfd <= 0 && actionneeded)1204 if(currentfd <= 0 && (action == ADDED_STREAMPID_INDEX || action != NO_STREAMPID_LISTED)) 1205 1205 { 1206 1206 if(cfg.dvbapi_boxtype == BOXTYPE_PC) … … 1212 1212 } 1213 1213 1214 if(currentfd > 0 && actionneeded)1214 if(currentfd > 0 && (action == ADDED_STREAMPID_INDEX || action != NO_STREAMPID_LISTED)) 1215 1215 { 1216 1216 ca_pid_t ca_pid2; 1217 1217 memset(&ca_pid2, 0, sizeof(ca_pid2)); 1218 1218 ca_pid2.pid = demux[demux_id].STREAMpids[num]; 1219 if(action == REMOVED_STREAMPID_LASTINDEX) idx = -1; // removed last index of streampid -> disable pid with -1 1219 1220 ca_pid2.index = idx; 1220 1221 … … 1246 1247 (enable ? "enable" : "disable"), num + 1, ca_pid2.pid, ca_pid2.index, i); 1247 1248 } 1248 if(!enable && selected_api != STAPI && !is_ca_used(i)){ 1249 int8_t result = is_ca_used(i); 1250 if(!enable && result == CA_IS_CLEAR){ 1251 cs_debug_mask(D_DVBAPI, "[DVBAPI] Demuxer #%d close now unused CA%d device", demux_id, i); 1249 1252 int32_t ret = close(currentfd); 1250 1253 if(ret < 0) { cs_log("ERROR: Could not close demuxer fd (errno=%d %s)", errno, strerror(errno)); } … … 4427 4430 } 4428 4431 4429 boolupdate_streampid_list(uint8_t cadevice, uint16_t pid, int32_t idx)4432 int8_t update_streampid_list(uint8_t cadevice, uint16_t pid, int32_t idx) 4430 4433 { 4431 4434 struct s_streampid *listitem, *newlistitem; … … 4440 4443 if (cadevice == listitem->cadevice && pid == listitem->streampid){ 4441 4444 if(listitem->activeindexers & (1 << idx)){ 4442 return 1; // match found4445 return FOUND_STREAMPID_INDEX; // match found 4443 4446 }else{ 4444 4447 listitem->activeindexers|=(1 << idx); // ca + pid found but not this index -> add this index 4445 4448 cs_debug_mask(D_DVBAPI, "[DVBAPI] added streampid %04X with index %d to ca%d", pid, idx, cadevice); 4446 return 0;4449 return ADDED_STREAMPID_INDEX; 4447 4450 } 4448 4451 } … … 4450 4453 } 4451 4454 if(!cs_malloc(&newlistitem, sizeof(struct s_streampid))) 4452 { return 1; }4455 { return ADDED_STREAMPID_INDEX; } 4453 4456 newlistitem->cadevice = cadevice; 4454 4457 newlistitem->streampid = pid; … … 4456 4459 ll_append(ll_activestreampids, newlistitem); 4457 4460 cs_debug_mask(D_DVBAPI, "[DVBAPI] new streampid %04X added with index %d to ca%d", pid, idx, cadevice); 4458 return 0;4459 } 4460 4461 boolremove_streampid_from_list(uint8_t cadevice, uint16_t pid, int32_t idx)4461 return ADDED_STREAMPID_INDEX; 4462 } 4463 4464 int8_t remove_streampid_from_list(uint8_t cadevice, uint16_t pid, int32_t idx) 4462 4465 { 4463 4466 if(!ll_activestreampids) return 1; … … 4482 4485 ll_iter_remove_data(&itr); 4483 4486 cs_debug_mask(D_DVBAPI, "[DVBAPI] removed last indexer of streampid %04X from ca%d", pid, cadevice); 4484 } 4485 return 1; 4486 } 4487 } 4488 } 4489 return 0; 4487 return REMOVED_STREAMPID_LASTINDEX; 4488 } 4489 return REMOVED_STREAMPID_INDEX; 4490 } 4491 } 4492 } 4493 return NO_STREAMPID_LISTED; 4490 4494 } 4491 4495 … … 4526 4530 4527 4531 4528 boolis_ca_used(uint8_t cadevice)4529 { 4530 if(!ll_activestreampids) return 0;4532 int8_t is_ca_used(uint8_t cadevice) 4533 { 4534 if(!ll_activestreampids) return CA_IS_CLEAR; 4531 4535 4532 4536 struct s_streampid *listitem; … … 4539 4543 { 4540 4544 if (listitem->cadevice != cadevice) continue; 4541 return 1;4542 } 4543 } 4544 return 0;4545 return CA_IS_IN_USE; 4546 } 4547 } 4548 return CA_IS_CLEAR; 4545 4549 } 4546 4550 -
trunk/module-dvbapi.h
r9184 r9320 40 40 #define BOXTYPES 11 41 41 #define DMXMD5HASHSIZE 16 // use MD5() 42 #define REMOVED_STREAMPID_LASTINDEX 2 43 #define REMOVED_STREAMPID_INDEX 1 44 #define NO_STREAMPID_LISTED 0 45 #define FOUND_STREAMPID_INDEX 0 46 #define ADDED_STREAMPID_INDEX 1 47 #define CA_IS_IN_USE 1 48 #define CA_IS_CLEAR 0 42 49 43 50 struct box_devices … … 254 261 int32_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid); 255 262 void dvbapi_set_pid(int32_t demux_id, int32_t num, int32_t idx, bool enable); 256 boolupdate_streampid_list(uint8_t cadevice, uint16_t pid, int32_t idx);257 boolremove_streampid_from_list(uint8_t cadevice, uint16_t pid, int32_t idx);263 int8_t update_streampid_list(uint8_t cadevice, uint16_t pid, int32_t idx); 264 int8_t remove_streampid_from_list(uint8_t cadevice, uint16_t pid, int32_t idx); 258 265 void disable_unused_streampids(int16_t demux_id); 259 boolis_ca_used(uint8_t cadevice);266 int8_t is_ca_used(uint8_t cadevice); 260 267 261 268 #ifdef DVBAPI_LOG_PREFIX
Note:
See TracChangeset
for help on using the changeset viewer.