hold the lnbp overcurrent detection at static detection until the rotor has
[enigma2.git] / lib / dvb / dvb.cpp
index 0184347bc26bebc30dd9f6914ad7e76ca41a8917..fa15d66289ddf5f13148b60514b3f8fd944cdcc8 100644 (file)
@@ -891,8 +891,10 @@ void eDVBChannel::cueSheetEvent(int event)
        case eCueSheet::evtSkipmode:
        {
                {
-                       eSingleLocker l(m_cue->m_lock);
+                       m_cue->m_lock.WrLock();
                        m_cue->m_seek_requests.push_back(std::pair<int, pts_t>(1, 0)); /* resync */
+                       m_cue->m_lock.Unlock();
+                       eRdLocker l(m_cue->m_lock);
                        if (m_cue->m_skipmode_ratio)
                        {
                                int bitrate = m_tstools.calcBitrate(); /* in bits/s */
@@ -975,13 +977,13 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                return;
        }
 
-       eSingleLocker l(m_cue->m_lock);
-       
+       m_cue->m_lock.RdLock();
        if (!m_cue->m_decoding_demux)
        {
                start = current_offset;
                size = max;
                eDebug("getNextSourceSpan, no decoding demux. forcing normal play");
+               m_cue->m_lock.Unlock();
                return;
        }
 
@@ -998,7 +1000,11 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
        while (!m_cue->m_seek_requests.empty())
        {
                std::pair<int, pts_t> seek = m_cue->m_seek_requests.front();
+               m_cue->m_lock.Unlock();
+               m_cue->m_lock.WrLock();
                m_cue->m_seek_requests.pop_front();
+               m_cue->m_lock.Unlock();
+               m_cue->m_lock.RdLock();
                int relative = seek.first;
                pts_t pts = seek.second;
 
@@ -1051,7 +1057,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                        pts_t nextap;
                        if (m_tstools.getNextAccessPoint(nextap, now, pts))
                        {
-                               pts = now;
+                               pts = now - 90000; /* approx. 1s */
                                eDebug("AP relative seeking failed!");
                        } else
                        {
@@ -1071,6 +1077,8 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                current_offset = align(offset, blocksize); /* in case tstools return non-aligned offset */
        }
 
+       m_cue->m_lock.Unlock();
+
        for (std::list<std::pair<off_t, off_t> >::const_iterator i(m_source_span.begin()); i != m_source_span.end(); ++i)
        {
                long long aligned_start = align(i->first, blocksize);
@@ -1094,7 +1102,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                        {
                                        /* in normal playback, just start at the next zone. */
                                start = i->first;
-                               
+
                                        /* size is not 64bit! */
                                if ((i->second - i->first) > max)
                                        size = max;
@@ -1115,8 +1123,11 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                                --i;
                                eDebug("skip to previous block, which is %llx..%llx", i->first, i->second);
                                size_t len;
-                               
-                               if ((i->second - i->first) > max)
+
+                               aligned_start = align(i->first, blocksize);
+                               aligned_end = align(i->second, blocksize);
+
+                               if ((aligned_end - aligned_start) > max)
                                        len = max;
                                else
                                        len = aligned_end - aligned_start;
@@ -1124,19 +1135,19 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
                                start = aligned_end - len;
                                eDebug("skipping to %llx, %d", start, len);
                        }
-                       
+
                        eDebug("result: %llx, %x (%llx %llx)", start, size, aligned_start, aligned_end);
                        return;
                }
        }
-       
+
        if ((current_offset < -m_skipmode_m) && (m_skipmode_m < 0))
        {
                eDebug("reached SOF");
                m_skipmode_m = 0;
                m_pvr_thread->sendEvent(eFilePushThread::evtUser);
        }
-       
+
        start = current_offset;
        size = max;
 
@@ -1404,25 +1415,24 @@ eCueSheet::eCueSheet()
 
 void eCueSheet::seekTo(int relative, const pts_t &pts)
 {
-       {
-               eSingleLocker l(m_lock);
-               m_seek_requests.push_back(std::pair<int, pts_t>(relative, pts));
-       }
+       m_lock.WrLock();
+       m_seek_requests.push_back(std::pair<int, pts_t>(relative, pts));
+       m_lock.Unlock();
        m_event(evtSeek);
 }
        
 void eCueSheet::clear()
 {
-       eSingleLocker l(m_lock);
+       m_lock.WrLock();
        m_spans.clear();
+       m_lock.Unlock();
 }
 
 void eCueSheet::addSourceSpan(const pts_t &begin, const pts_t &end)
 {
-       {
-               eSingleLocker l(m_lock);
-               m_spans.push_back(std::pair<pts_t, pts_t>(begin, end));
-       }
+       m_lock.WrLock();
+       m_spans.push_back(std::pair<pts_t, pts_t>(begin, end));
+       m_lock.Unlock();
 }
 
 void eCueSheet::commitSpans()
@@ -1432,10 +1442,9 @@ void eCueSheet::commitSpans()
 
 void eCueSheet::setSkipmode(const pts_t &ratio)
 {
-       {
-               eSingleLocker l(m_lock);
-               m_skipmode_ratio = ratio;
-       }
+       m_lock.WrLock();
+       m_skipmode_ratio = ratio;
+       m_lock.Unlock();
        m_event(evtSkipmode);
 }