summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmlee <smlee@dev3>2016-11-22 08:53:58 (GMT)
committersmlee <smlee@dev3>2016-11-22 09:53:45 (GMT)
commite41f07f1d0855ff8e47059f109413a41a065268b (patch)
treeef5dfbb0e85cf6197266eeefb1bcb8f7c6661ea6
parentb4322e10bb080404c5c622b856ed3a29617c703b (diff)
Fix malfunction of recording path
-rw-r--r--lib/base/filepush.cpp62
-rw-r--r--lib/base/filepush.h5
-rw-r--r--lib/dvb/demux.cpp10
-rw-r--r--lib/dvb/demux.h1
-rw-r--r--lib/dvb/idemux.h1
-rwxr-xr-xlib/service/servicedvb.cpp1
6 files changed, 69 insertions, 11 deletions
diff --git a/lib/base/filepush.cpp b/lib/base/filepush.cpp
index 5de9ef2..fa7fb53 100644
--- a/lib/base/filepush.cpp
+++ b/lib/base/filepush.cpp
@@ -31,6 +31,7 @@ eFilePushThread::eFilePushThread(int io_prio_class, int io_prio_level, int block
flush();
enablePVRCommit(0);
CONNECT(m_messagepump.recv_msg, eFilePushThread::recvEvent);
+ m_is_timeshift = false;
m_hdd_connected = false;
}
@@ -50,12 +51,6 @@ void eFilePushThread::thread()
size_t written_since_last_sync = 0;
- std::string tspath;
- if(ePythonConfigQuery::getConfigValue("config.usage.timeshift_path", tspath) == -1) {
- eDebug("could not query ts path from config");
- }
- tspath.append("/");
-
#if 0
DIR *tsdir_info;
struct dirent *tsdir_entry;
@@ -71,15 +66,20 @@ void eFilePushThread::thread()
}
}
#else
+ if (m_tspath.empty())
+ defaultTSPath(m_is_timeshift);
+
struct stat tspath_st;
- if (stat(tspath.c_str(), &tspath_st) == 0) {
+ if (stat(m_tspath.c_str(), &tspath_st) == 0) {
if (major(tspath_st.st_dev) == MAJORSD_) {
- eDebug("Timeshift location on HDD!");
+ eDebug("%s location on HDD!", m_tspath.c_str());
m_hdd_connected = true;
} else if (major(tspath_st.st_dev) == MAJORMMCBLK) {
- eDebug("Timeshift location on eMMC!");
+ eDebug("%s location on eMMC!", m_tspath.c_str());
m_hdd_connected = false;
}
+ } else {
+ eDebug("stat failed!");
}
#endif
@@ -158,11 +158,11 @@ void eFilePushThread::thread()
sendEvent(evtWriteError);
struct statfs fs;
- if (statfs(tspath.c_str(), &fs) < 0) {
+ if (statfs(m_tspath.c_str(), &fs) < 0) {
eDebug("statfs failed!");
}
if ((off_t)fs.f_bavail < 1) {
- eDebug("not enough diskspace for timeshift!");
+ eDebug("not enough diskspace!");
g_is_diskfull = true;
}
break;
@@ -362,6 +362,16 @@ void eFilePushThread::setStreamMode(int s)
m_stream_mode = s;
}
+void eFilePushThread::setTimeshift(bool s)
+{
+ m_is_timeshift = s;
+}
+
+void eFilePushThread::setTSPath(const std::string s)
+{
+ m_tspath = s;
+}
+
void eFilePushThread::setScatterGather(iFilePushScatterGather *sg)
{
m_sg = sg;
@@ -377,6 +387,36 @@ void eFilePushThread::recvEvent(const int &evt)
m_event(evt);
}
+void eFilePushThread::defaultTSPath(bool s)
+{
+ std::string tspath;
+
+ if (s) {
+ if (ePythonConfigQuery::getConfigValue("config.usage.timeshift_path", tspath) == -1)
+ eDebug("could not query ts path from config");
+ } else {
+ if (ePythonConfigQuery::getConfigValue("config.usage.instantrec_path", tspath) == -1) {
+ eDebug("could not query ts path from config");
+ } else {
+ if (tspath == "<default>") {
+ if (ePythonConfigQuery::getConfigValue("config.usage.default_path", tspath) == -1)
+ eDebug("could not query ts path from config");
+ } else if (tspath == "<current>") {
+ if (ePythonConfigQuery::getConfigValue("config.movielist.last_videodir", tspath) == -1)
+ eDebug("could not query ts path from config");
+ } else if (tspath == "<timer>") {
+ if (ePythonConfigQuery::getConfigValue("config.movielist.last_timer_videodir", tspath) == -1)
+ eDebug("could not query ts path from config");
+ }
+ }
+ }
+
+ if (!tspath.empty())
+ tspath.append("/");
+
+ m_tspath = tspath;
+}
+
int eFilePushThread::filterRecordData(const unsigned char *data, int len, size_t &current_span_remaining)
{
return len;
diff --git a/lib/base/filepush.h b/lib/base/filepush.h
index 3fb051e..b6b4039 100644
--- a/lib/base/filepush.h
+++ b/lib/base/filepush.h
@@ -36,6 +36,8 @@ public:
/* stream mode will wait on EOF until more data is available. */
void setStreamMode(int);
+ void setTimeshift(bool);
+ void setTSPath(const std::string);
void setScatterGather(iFilePushScatterGather *);
@@ -63,9 +65,12 @@ private:
ePtr<iTsSource> m_source;
eFixedMessagePump<int> m_messagepump;
+ std::string m_tspath;
+ bool m_is_timeshift;
bool m_hdd_connected;
void recvEvent(const int &evt);
+ void defaultTSPath(bool);
};
#endif
diff --git a/lib/dvb/demux.cpp b/lib/dvb/demux.cpp
index 0cebc70..b677275 100644
--- a/lib/dvb/demux.cpp
+++ b/lib/dvb/demux.cpp
@@ -654,6 +654,11 @@ RESULT eDVBTSRecorder::setTargetFD(int fd)
RESULT eDVBTSRecorder::setTargetFilename(const char *filename)
{
m_target_filename = filename;
+
+ std::string target_path = m_target_filename;
+ std::string::size_type filePos = target_path.rfind('/');
+ m_thread->setTSPath(target_path.erase(filePos));
+
return 0;
}
@@ -668,6 +673,11 @@ RESULT eDVBTSRecorder::setBoundary(off_t max)
return -1; // not yet implemented
}
+RESULT eDVBTSRecorder::setTimeshift(bool enable)
+{
+ m_thread->setTimeshift(enable);
+}
+
RESULT eDVBTSRecorder::stop()
{
int state=3;
diff --git a/lib/dvb/demux.h b/lib/dvb/demux.h
index ca7fc4d..b34ad27 100644
--- a/lib/dvb/demux.h
+++ b/lib/dvb/demux.h
@@ -103,6 +103,7 @@ public:
RESULT setTargetFilename(const char *filename);
RESULT enableAccessPoints(bool enable);
RESULT setBoundary(off_t max);
+ RESULT setTimeshift(bool enable);
RESULT stop();
diff --git a/lib/dvb/idemux.h b/lib/dvb/idemux.h
index 0cb82cf..ecbea36 100644
--- a/lib/dvb/idemux.h
+++ b/lib/dvb/idemux.h
@@ -40,6 +40,7 @@ public:
virtual RESULT setTargetFilename(const char *filename) = 0;
virtual RESULT enableAccessPoints(bool enable) = 0;
virtual RESULT setBoundary(off_t max) = 0;
+ virtual RESULT setTimeshift(bool enable) = 0;
virtual RESULT stop() = 0;
diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp
index 2bd6998..086f595 100755
--- a/lib/service/servicedvb.cpp
+++ b/lib/service/servicedvb.cpp
@@ -2247,6 +2247,7 @@ RESULT eDVBServicePlay::startTimeshift()
m_record->setTargetFD(m_timeshift_fd);
m_record->setTargetFilename(m_timeshift_file.c_str());
m_record->enableAccessPoints(false);
+ m_record->setTimeshift(true);
m_timeshift_enabled = 1;