Ticket #1502: myth-diff-against-9403.2

File myth-diff-against-9403.2, 2.4 KB (added by dscoular@…, 15 years ago)

This updates dvbchannel.cpp to do an initial usleep after FE_READ_STATUS.

Line 
1Index: libs/libmythtv/dvbchannel.cpp
2===================================================================
3--- libs/libmythtv/dvbchannel.cpp       (revision 9403)
4+++ libs/libmythtv/dvbchannel.cpp       (working copy)
5@@ -62,7 +62,7 @@
6 
7 static uint tuned_frequency(const DVBTuning&, fe_type_t, fe_sec_tone_mode_t *);
8 static void drain_dvb_events(int fd);
9-static bool wait_for_backend(int fd, int timeout_ms);
10+static bool wait_for_backend(int fd, int timeout_ms, uint tuning_delay);
11 static bool handle_diseq(const DVBTuning&, DVBDiSEqC*, bool reset);
12 
13 #define LOC QString("DVB#%1 ").arg(cardnum)
14@@ -636,11 +636,12 @@
15         }
16 
17         // Extra delay to add for broken DVB drivers
18-        if (tuning_delay)
19-            usleep(tuning_delay * 1000);
20+        if (tuning_delay) {
21+         CHANNEL(QString("DVBChannel: Sleeping for tuning_delay=%1 prior to wait_for_backend.").arg(tuning_delay));
22+         usleep(tuning_delay * 1000);
23+       }
24+        wait_for_backend(fd_frontend, 5 /* msec */, tuning_delay);
25 
26-        wait_for_backend(fd_frontend, 5 /* msec */);
27-
28         prev_tuning.params = params;
29         first_tune = false;
30     }
31@@ -718,7 +719,7 @@
32 
33 /** \fn drain_dvb_events(int)
34  *  \brief Reads all the events off the queue, so we can use select
35- *         in wait_for_backend(int,int).
36+ *         in wait_for_backend(int,int,uint).
37  */
38 static void drain_dvb_events(int fd)
39 {
40@@ -743,7 +744,7 @@
41     return (tone) ? lnb_hi : lnb_lo;
42 }
43 
44-/** \fn wait_for_backend(int,int)
45+/** \fn wait_for_backend(int,int,uint)
46  *  \brief Waits for backend to get tune message.
47  *
48  *   With linux 2.6.12 or later this should block
49@@ -766,7 +767,7 @@
50  *  \param fd         frontend file descriptor
51  *  \param timeout_ms timeout before FE_READ_STATUS in milliseconds
52  */
53-static bool wait_for_backend(int fd, int timeout_ms)
54+static bool wait_for_backend(int fd, int timeout_ms, uint tuning_delay)
55 {
56     struct timeval select_timeout = { 0, (timeout_ms % 1000) * 1000 /*usec*/};
57     fd_set fd_select_set;
58@@ -787,6 +788,11 @@
59         return false;
60     }
61 
62+    // Some broken cards need a delay after reading status.
63+    if (tuning_delay) {
64+      VERBOSE(VB_CHANNEL, QString("DVBChannel: Sleeping for tuning_delay=%1 after FE_READ_STATUS.").arg(tuning_delay));
65+      usleep(tuning_delay * 1000);
66+    }
67     VERBOSE(VB_CHANNEL, QString("dvbchannel.cpp:wait_for_backend: Status: %1")
68             .arg(toString(status)));
69     return true;