diff options
| author | ghost <andreas.monzner@multimedia-labs.de> | 2009-12-17 14:58:54 +0100 |
|---|---|---|
| committer | ghost <andreas.monzner@multimedia-labs.de> | 2009-12-17 15:15:25 +0100 |
| commit | b64b791cb481944585fceaf5bcac9e2c699dbeb0 (patch) | |
| tree | dba3f33f2804fabec8f4288eb33c864176031ed6 | |
| parent | 5e05afa7dbc5acfc92a158dcc88b0be12c52af62 (diff) | |
| download | enigma2-b64b791cb481944585fceaf5bcac9e2c699dbeb0.tar.gz enigma2-b64b791cb481944585fceaf5bcac9e2c699dbeb0.zip | |
lib/dvb/tstools.h/cpp: make eDVBTSTool thread safe (i.e. this fixes seeking in timeshift and seeking in files without additional startcode/accespoint file
| -rw-r--r-- | lib/dvb/tstools.cpp | 10 | ||||
| -rw-r--r-- | lib/dvb/tstools.h | 6 |
2 files changed, 12 insertions, 4 deletions
diff --git a/lib/dvb/tstools.cpp b/lib/dvb/tstools.cpp index a9eef406..2c261837 100644 --- a/lib/dvb/tstools.cpp +++ b/lib/dvb/tstools.cpp @@ -7,6 +7,7 @@ #include <stdio.h> eDVBTSTools::eDVBTSTools() + :m_file_lock(true) { m_pid = -1; m_maxrange = 256*1024; @@ -47,6 +48,7 @@ int eDVBTSTools::openFile(const char *filename, int nostreaminfo) m_samples_taken = 0; + eSingleLocker l(m_file_lock); if (m_file.open(filename, 1) < 0) return -1; return 0; @@ -54,6 +56,7 @@ int eDVBTSTools::openFile(const char *filename, int nostreaminfo) void eDVBTSTools::closeFile() { + eSingleLocker l(m_file_lock); m_file.close(); } @@ -78,7 +81,8 @@ int eDVBTSTools::getPTS(off_t &offset, pts_t &pts, int fixed) return -1; offset -= offset % 188; - + + eSingleLocker l(m_file_lock); if (m_file.lseek(offset, SEEK_SET) < 0) { eDebug("lseek failed"); @@ -355,7 +359,8 @@ void eDVBTSTools::calcEnd() { if (!m_file.valid()) return; - + + eSingleLocker l(m_file_lock); off_t end = m_file.lseek(0, SEEK_END); if (llabs(end - m_last_filelength) > 1*1024*1024) @@ -504,6 +509,7 @@ int eDVBTSTools::findPMT(int &pmt_pid, int &service_id) return -1; } + eSingleLocker l(m_file_lock); if (m_file.lseek(0, SEEK_SET) < 0) { eDebug("seek failed"); diff --git a/lib/dvb/tstools.h b/lib/dvb/tstools.h index c230a341..ed8b9241 100644 --- a/lib/dvb/tstools.h +++ b/lib/dvb/tstools.h @@ -4,6 +4,7 @@ #include <sys/types.h> #include <lib/dvb/pvrparse.h> #include <lib/base/rawfile.h> +#include <lib/base/elock.h> /* * Note: we're interested in PTS values, not STC values. @@ -75,9 +76,10 @@ public: private: int m_pid; int m_maxrange; - + + eSingleLock m_file_lock; eRawFile m_file; - + int m_begin_valid, m_end_valid; pts_t m_pts_begin, m_pts_end; off_t m_offset_begin, m_offset_end; |
