@@ -62,6 +62,7 @@ int a_count;
62
62
char disabled [MAX_ADAPTERS ]; // disabled adapters
63
63
int sock_signal ;
64
64
char do_dump_pids = 1 ;
65
+ uint64_t source_map [MAX_SOURCES ];
65
66
66
67
SMutex a_mutex ;
67
68
@@ -97,7 +98,7 @@ adapter *adapter_alloc()
97
98
ad -> diseqc_multi = opts .diseqc_multi ;
98
99
99
100
/* enable all sources */
100
- ad -> debug_pos [0 ]= '\0' ;
101
+ ad -> debug_pos [0 ] = '\0' ;
101
102
ad -> debug_src = 0 ;
102
103
int i ;
103
104
for (i = 0 ; i <= MAX_SOURCES ; i ++ )
@@ -111,7 +112,6 @@ adapter *adapter_alloc()
111
112
ad -> diseqc_param .lnb_circular = opts .lnb_circular ;
112
113
ad -> diseqc_param .lnb_switch = opts .lnb_switch ;
113
114
114
- ad -> failed_adapter = 0 ;
115
115
ad -> adapter_timeout = opts .adapter_timeout ;
116
116
117
117
ad -> strength_multiplier = opts .strength_multiplier ;
@@ -234,6 +234,19 @@ int close_adapter_for_socket(sockets *s)
234
234
return close_adapter (aid );
235
235
}
236
236
237
+ void adapter_set_dvr (adapter * ad )
238
+ {
239
+ ad -> sock = sockets_add (ad -> dvr , NULL , ad -> id , TYPE_DVR , (socket_action )read_dmx ,
240
+ (socket_action )close_adapter_for_socket ,
241
+ (socket_action )adapter_timeout );
242
+ memset (ad -> buf , 0 , opts .adapter_buffer + 1 );
243
+ set_socket_buffer (ad -> sock , (unsigned char * )ad -> buf , opts .adapter_buffer );
244
+ if (ad -> adapter_timeout > 0 )
245
+ sockets_timeout (ad -> sock , ad -> adapter_timeout );
246
+ if (opts .th_priority > 0 )
247
+ set_thread_prio (get_socket_thread (ad -> sock ), opts .th_priority );
248
+ }
249
+
237
250
int init_complete = 0 ;
238
251
int num_adapters = 0 ;
239
252
@@ -268,12 +281,10 @@ int init_hw(int i)
268
281
goto NOK ;
269
282
}
270
283
271
- ad -> sock = -1 ;
272
284
ad -> id = i ;
273
285
ad -> fe_sock = -1 ;
274
286
ad -> sock = -1 ;
275
287
ad -> force_close = 0 ;
276
- ad -> restart_needed = 0 ;
277
288
ad -> err = 0 ;
278
289
#ifdef GXAPI
279
290
ad -> gx_ts_config = opts .ts_config & 0x1f ;
@@ -336,11 +347,9 @@ int init_hw(int i)
336
347
}
337
348
memset (ad -> buf , 0 , opts .adapter_buffer + 1 );
338
349
init_dvb_parameters (& ad -> tp );
339
- if (!ad -> failed_adapter )
340
- {
341
- mark_pids_deleted (i , -1 , NULL );
342
- update_pids (i );
343
- }
350
+ mark_pids_deleted (i , -1 , NULL );
351
+ update_pids (i );
352
+
344
353
if (!ad -> sys [0 ])
345
354
ad -> delsys (i , ad -> fe , ad -> sys );
346
355
ad -> master_sid = -1 ;
@@ -353,19 +362,11 @@ int init_hw(int i)
353
362
ad -> threshold = opts .udp_threshold ;
354
363
ad -> updating_pids = 0 ;
355
364
ad -> wait_new_stream = 0 ;
356
- ad -> failed_adapter = 0 ;
357
365
ad -> rtime = getTick ();
358
- ad -> sock = sockets_add (ad -> dvr , NULL , i , TYPE_DVR , (socket_action )read_dmx ,
359
- (socket_action )close_adapter_for_socket ,
360
- (socket_action )adapter_timeout );
361
- memset (ad -> buf , 0 , opts .adapter_buffer + 1 );
362
- set_socket_buffer (ad -> sock , (unsigned char * )ad -> buf , opts .adapter_buffer );
363
- if (ad -> adapter_timeout > 0 )
364
- sockets_timeout (ad -> sock , ad -> adapter_timeout );
366
+ adapter_set_dvr (ad );
365
367
snprintf (ad -> name , sizeof (ad -> name ), "AD%d" , i );
366
- set_socket_thread (ad -> sock , start_new_thread (ad -> name ));
367
- if (opts .th_priority > 0 )
368
- set_thread_prio (get_socket_thread (ad -> sock ), opts .th_priority );
368
+ ad -> thread = start_new_thread (ad -> name );
369
+ set_socket_thread (ad -> sock , ad -> thread );
369
370
#ifndef DISABLE_PMT
370
371
pmt_init_device (ad );
371
372
#endif
@@ -402,18 +403,6 @@ int init_hw(int i)
402
403
return 1 ;
403
404
}
404
405
405
- int enable_failed_adapter (int id )
406
- {
407
- if (id < 0 || id >= MAX_ADAPTERS )
408
- return 1 ;
409
- adapter * ad = a [id ];
410
- if (!ad )
411
- return 1 ;
412
-
413
- ad -> failed_adapter = 1 ;
414
- return init_hw (id );
415
- }
416
-
417
406
int init_all_hw ()
418
407
{
419
408
int i , rv ;
@@ -537,7 +526,7 @@ int getAdaptersCount()
537
526
// Note: Adapter 0 uses map bit 0, sources_pos ranges from 0..MAX_SOURCES+1 and source_map ranges from 0..SRC-1 (SRC=0 can't be configured)
538
527
for (j = 0 ; j < MAX_SOURCES ; j ++ )
539
528
{
540
- ad -> sources_pos [j + 1 ] = (source_map [j ] >> i ) & 1 ;
529
+ ad -> sources_pos [j + 1 ] = (source_map [j ] >> i ) & 1 ;
541
530
}
542
531
543
532
if (!opts .force_sadapter && (delsys_match (ad , SYS_DVBS ) || delsys_match (ad , SYS_DVBS2 )))
@@ -611,7 +600,7 @@ int getAdaptersCount()
611
600
for (i = 0 ; i < MAX_ADAPTERS ; i ++ )
612
601
if ((ad = a [i ]))
613
602
{
614
- ad -> debug_pos [0 ]= '\0' ;
603
+ ad -> debug_pos [0 ] = '\0' ;
615
604
ad -> debug_src = 0 ;
616
605
lsrc [0 ] = '\0' ;
617
606
for (j = 1 ; j <= MAX_SOURCES ; j ++ )
@@ -631,7 +620,7 @@ int getAdaptersCount()
631
620
}
632
621
}
633
622
if (strlen (lsrc ) > 0 )
634
- lsrc [0 ]= ' ' ;
623
+ lsrc [0 ] = ' ' ;
635
624
DEBUGM ("Adpater %d enabled sources:%s" , i , lsrc );
636
625
DEBUGM ("Adpater %d debug sources: %s (%lu)" , i , ad -> debug_pos , ad -> debug_src );
637
626
}
@@ -857,11 +846,10 @@ int set_adapter_for_stream(int sid, int aid)
857
846
return 0 ;
858
847
}
859
848
860
- void close_adapter_for_stream (int sid , int aid )
849
+ void close_adapter_for_stream (int sid , int aid , int close_stream )
861
850
{
862
851
adapter * ad ;
863
852
streams * s = get_sid (sid );
864
- int is_slave = 1 ;
865
853
if (!(ad = get_adapter (aid )))
866
854
return ;
867
855
@@ -879,16 +867,14 @@ void close_adapter_for_stream(int sid, int aid)
879
867
}
880
868
if (ad -> sid_cnt > 0 )
881
869
ad -> sid_cnt -- ;
882
- LOG ("closed adapter %d for sid %d m:%d sid_cnt:%d, restart_needed %d" , aid , sid , ad -> master_sid ,
883
- ad -> sid_cnt , ad -> restart_needed );
870
+ LOG ("closed adapter %d for sid %d m:%d sid_cnt:%d" , aid , sid , ad -> master_sid , ad -> sid_cnt );
884
871
// delete the attached PIDs as well
885
872
if (ad -> sid_cnt == 0 )
886
873
{
887
- is_slave = 0 ;
888
874
ad -> master_sid = -1 ;
889
875
mark_pids_deleted (aid , -1 , NULL );
890
876
init_dvb_parameters (& ad -> tp );
891
- if (ad -> standby )
877
+ if (ad -> standby && close_stream )
892
878
ad -> standby (ad );
893
879
#ifdef AXE
894
880
free_axe_input (ad );
@@ -906,12 +892,6 @@ void close_adapter_for_stream(int sid, int aid)
906
892
update_pids (aid );
907
893
adapter_update_threshold (ad );
908
894
mutex_unlock (& ad -> mutex );
909
- if ((ad -> restart_needed == 1 ) && !is_slave )
910
- {
911
- LOG ("restarting adapter %d as needed" , ad -> id );
912
- // request_adapter_close (ad);
913
- close_adapter (ad -> id );
914
- }
915
895
}
916
896
917
897
int update_pids (int aid )
@@ -922,7 +902,7 @@ int update_pids(int aid)
922
902
if (!ad || ad -> updating_pids )
923
903
return 1 ;
924
904
925
- if (ad -> err )
905
+ if (ad -> err )
926
906
{
927
907
LOG ("adapter %d in error state %d" , aid , ad -> err );
928
908
return 1 ;
@@ -970,7 +950,12 @@ int update_pids(int aid)
970
950
dp = 0 ;
971
951
if (ad -> pids [i ].fd <= 0 )
972
952
{
973
- if ((ad -> pids [i ].fd = ad -> set_pid (ad , ad -> pids [i ].pid )) < 0 )
953
+ int pid = ad -> pids [i ].pid ;
954
+ // For pids=all emulation add just the PAT pid. process_pmt will add
955
+ // the other pids
956
+ if (opts .emulate_pids_all && pid == 8192 )
957
+ pid = 0 ;
958
+ if ((ad -> pids [i ].fd = ad -> set_pid (ad , pid )) < 0 )
974
959
{
975
960
ad -> max_pids = ad -> max_active_pids - 1 ;
976
961
LOG0 ("Maximum pid filter reached, lowering the value to %d" , opts .max_pids );
@@ -985,6 +970,7 @@ int update_pids(int aid)
985
970
ad -> pat_processed = 0 ;
986
971
ad -> pids [i ].packets = 0 ;
987
972
ad -> pids [i ].cc = -1 ;
973
+ ad -> pids [i ].cc1 = -1 ;
988
974
ad -> pids [i ].cc_err = 0 ;
989
975
ad -> pids [i ].dec_err = 0 ;
990
976
}
@@ -1044,8 +1030,6 @@ int tune(int aid, int sid)
1044
1030
ad -> snr = 0 ;
1045
1031
flush_data = 1 ;
1046
1032
ad -> is_t2mi = 0 ;
1047
- if (ad -> restart_when_tune )
1048
- ad -> restart_needed = 1 ;
1049
1033
set_socket_pos (ad -> sock , 0 ); // flush the existing buffer
1050
1034
ad -> rlen = 0 ;
1051
1035
if (ad -> sid_cnt > 1 ) // the master changed the frequency
@@ -1159,6 +1143,14 @@ void mark_pids_deleted(int aid, int sid, char *pids) //pids==NULL -> delete all
1159
1143
1160
1144
LOG ("deleting pids on adapter %d, sid %d, pids=%s" , aid , sid ,
1161
1145
pids ? pids : "NULL" );
1146
+
1147
+ // If "delpids=all" provided, delete all the pids for this stream
1148
+ if (pids && strstr (pids , "all" ))
1149
+ {
1150
+ LOG ("deleting all the pids on adapter %d, sid %d, pids=%s" , aid , sid , pids );
1151
+ pids = NULL ;
1152
+ }
1153
+
1162
1154
if (pids )
1163
1155
{
1164
1156
la = split (arg , pids , ARRAY_SIZE (arg ), ',' );
@@ -1336,7 +1328,7 @@ int set_adapter_parameters(int aid, int sid, transponder *tp)
1336
1328
return -1 ;
1337
1329
}
1338
1330
}
1339
-
1331
+
1340
1332
if (0 && (ad -> tp .apids || ad -> tp .pids || ad -> tp .dpids ))
1341
1333
dump_pids (aid );
1342
1334
mutex_unlock (& ad -> mutex );
@@ -1389,7 +1381,7 @@ describe_adapter(int sid, int aid, char *dad, int ld)
1389
1381
ss = get_sid (sid );
1390
1382
1391
1383
use_ad = 1 ;
1392
- if (!(ad = get_adapter (aid )) || (ss && !ss -> do_play ))
1384
+ if (!(ad = get_adapter_nw (aid )) || (ss && !ss -> do_play ))
1393
1385
{
1394
1386
if (aid < 0 )
1395
1387
aid = 0 ;
@@ -1464,7 +1456,7 @@ describe_adapter(int sid, int aid, char *dad, int ld)
1464
1456
else
1465
1457
strlcatf (dad , ld , len , "%s" , t -> pids ? t -> pids : t -> apids );
1466
1458
}
1467
- else if (!use_ad )
1459
+ else if (!use_ad )
1468
1460
strlcatf (dad , ld , len , "%s" , "none" );
1469
1461
1470
1462
LOGM ("describe_adapter: sid %d, aid %d => %s" , sid , aid , dad );
@@ -1720,7 +1712,7 @@ void set_sources_adapters(char *o)
1720
1712
goto ERR ;
1721
1713
source_map [i ] = all ;
1722
1714
char buf2 [128 ];
1723
- buf2 [0 ]= '\0' ;
1715
+ buf2 [0 ] = '\0' ;
1724
1716
for (j = 0 ; j < MAX_ADAPTERS ; j ++ )
1725
1717
strcat (buf2 , "X" );
1726
1718
LOGM (" src=%d using adapters %s (%lu)" , i + 1 , buf2 , (unsigned long )source_map [i ]);
@@ -1752,7 +1744,7 @@ void set_sources_adapters(char *o)
1752
1744
}
1753
1745
}
1754
1746
}
1755
- buf2 [0 ]= '\0' ;
1747
+ buf2 [0 ] = '\0' ;
1756
1748
for (j = 0 ; j < MAX_ADAPTERS ; j ++ )
1757
1749
if (source_map [i ] & ((unsigned long )1 << j ))
1758
1750
strcat (buf2 , "X" );
@@ -1769,7 +1761,6 @@ void set_sources_adapters(char *o)
1769
1761
LOG ("Adapter sources format parameter %s, using defaults for all adapters!" , strlen (arg [0 ]) > 0 ? "incorrect" : "missing" );
1770
1762
}
1771
1763
1772
-
1773
1764
void set_diseqc_multi (char * o )
1774
1765
{
1775
1766
int i , la , a_id , position ;
@@ -2368,19 +2359,6 @@ char *get_all_delsys(int aid, char *dest, int max_size)
2368
2359
return dest ;
2369
2360
}
2370
2361
2371
- void restart_needed_adapters (int aid , int sid )
2372
- {
2373
- adapter * ad = get_adapter (aid );
2374
- if (ad )
2375
- LOGM ("starting restart_needed_adapters %d, rn: %d, sc %d, master_sid %d, sid %d" , aid , ad -> restart_needed , ad -> sid_cnt , ad -> master_sid , sid );
2376
-
2377
- if (ad && ad -> enabled && ad -> restart_needed && ((ad -> sid_cnt == 0 || ad -> master_sid == sid )))
2378
- {
2379
- LOG ("restart of the adapter %d requested" , ad -> id );
2380
- close_adapter (ad -> id );
2381
- }
2382
- }
2383
-
2384
2362
int get_adapter_ccerrs (int aid )
2385
2363
{
2386
2364
int i , cc = 0 ;
0 commit comments