}
};
+class eRdWrLock
+{
+ friend class eRdLocker;
+ friend class eWrLocker;
+ pthread_rwlock_t m_lock;
+ eRdWrLock(eRdWrLock &);
+public:
+ eRdWrLock()
+ {
+ pthread_rwlock_init(&m_lock, 0);
+ }
+ ~eRdWrLock()
+ {
+ pthread_rwlock_destroy(&m_lock);
+ }
+ void RdLock()
+ {
+ pthread_rwlock_rdlock(&m_lock);
+ }
+ void WrLock()
+ {
+ pthread_rwlock_wrlock(&m_lock);
+ }
+ void Unlock()
+ {
+ pthread_rwlock_unlock(&m_lock);
+ }
+};
+
+class eRdLocker
+{
+ eRdWrLock &m_lock;
+public:
+ eRdLocker(eRdWrLock &m)
+ : m_lock(m)
+ {
+ pthread_rwlock_rdlock(&m_lock.m_lock);
+ }
+ ~eRdLocker()
+ {
+ pthread_rwlock_unlock(&m_lock.m_lock);
+ }
+};
+
+class eWrLocker
+{
+ eRdWrLock &m_lock;
+public:
+ eWrLocker(eRdWrLock &m)
+ : m_lock(m)
+ {
+ pthread_rwlock_wrlock(&m_lock.m_lock);
+ }
+ ~eWrLocker()
+ {
+ pthread_rwlock_unlock(&m_lock.m_lock);
+ }
+};
+
class eSingleLock
{
friend class eSingleLocker;
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 */
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;
}
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;
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);
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()
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);
}