Fix malfunction of recording path
authorsmlee <smlee@dev3>
Tue, 22 Nov 2016 08:53:58 +0000 (17:53 +0900)
committersmlee <smlee@dev3>
Tue, 22 Nov 2016 09:53:45 +0000 (18:53 +0900)
lib/base/filepush.cpp
lib/base/filepush.h
lib/dvb/demux.cpp
lib/dvb/demux.h
lib/dvb/idemux.h
lib/service/servicedvb.cpp

index 5de9ef2..fa7fb53 100644 (file)
@@ -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;
index 3fb051e..b6b4039 100644 (file)
@@ -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
index 0cebc70..b677275 100644 (file)
@@ -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;
index ca7fc4d..b34ad27 100644 (file)
@@ -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();
 
index 0cb82cf..ecbea36 100644 (file)
@@ -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;
 
index 2bd6998..086f595 100755 (executable)
@@ -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;