git.cweiske.de
/
enigma2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'bug_570_playback_skip_fixes_and_cleanup_ml_aholst'
[enigma2.git]
/
lib
/
base
/
rawfile.cpp
diff --git
a/lib/base/rawfile.cpp
b/lib/base/rawfile.cpp
index e444ba90c7613a36264ea8dbf2445ae23bb222a5..3a09e07eef2b2a4f663200fcc4666eadcbe59c52 100644
(file)
--- a/
lib/base/rawfile.cpp
+++ b/
lib/base/rawfile.cpp
@@
-1,9
+1,13
@@
+#include <cstdio>
#include <unistd.h>
#include <fcntl.h>
#include <lib/base/rawfile.h>
#include <lib/base/eerror.h>
#include <unistd.h>
#include <fcntl.h>
#include <lib/base/rawfile.h>
#include <lib/base/eerror.h>
+DEFINE_REF(eRawFile);
+
eRawFile::eRawFile()
eRawFile::eRawFile()
+ :m_lock(false)
{
m_fd = -1;
m_file = 0;
{
m_fd = -1;
m_file = 0;
@@
-51,6
+55,13
@@
void eRawFile::setfd(int fd)
}
off_t eRawFile::lseek(off_t offset, int whence)
}
off_t eRawFile::lseek(off_t offset, int whence)
+{
+ eSingleLocker l(m_lock);
+ m_current_offset = lseek_internal(offset, whence);
+ return m_current_offset;
+}
+
+off_t eRawFile::lseek_internal(off_t offset, int whence)
{
// eDebug("lseek: %lld, %d", offset, whence);
/* if there is only one file, use the native lseek - the file could be growing! */
{
// eDebug("lseek: %lld, %d", offset, whence);
/* if there is only one file, use the native lseek - the file could be growing! */
@@
-60,7
+71,8
@@
off_t eRawFile::lseek(off_t offset, int whence)
return ::lseek(m_fd, offset, whence);
else
{
return ::lseek(m_fd, offset, whence);
else
{
- ::fseeko(m_file, offset, whence);
+ if (::fseeko(m_file, offset, whence) < 0)
+ perror("fseeko");
return ::ftello(m_file);
}
}
return ::ftello(m_file);
}
}
@@
-99,11
+111,19
@@
int eRawFile::close()
}
}
}
}
-ssize_t eRawFile::read(void *buf, size_t count)
+ssize_t eRawFile::read(
off_t offset,
void *buf, size_t count)
{
{
-// eDebug("read: %p, %d", buf, count);
+ eSingleLocker l(m_lock);
+
+ if (offset != m_current_offset)
+ {
+ m_current_offset = lseek_internal(offset, SEEK_SET);
+ if (m_current_offset < 0)
+ return m_current_offset;
+ }
+
switchOffset(m_current_offset);
switchOffset(m_current_offset);
-
+
if (m_nrfiles >= 2)
{
if (m_current_offset + count > m_totallength)
if (m_nrfiles >= 2)
{
if (m_current_offset + count > m_totallength)
@@
-226,3
+246,8
@@
int eRawFile::openFileUncached(int nr)
}
return ::open(filename.c_str(), O_RDONLY | O_LARGEFILE);
}
}
return ::open(filename.c_str(), O_RDONLY | O_LARGEFILE);
}
+
+off_t eRawFile::length()
+{
+ return m_totallength;
+}