/*
- Copyright 2004-2005 Chris Tallon
+ Copyright 2004-2020 Chris Tallon
This file is part of VOMP.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
-#include "vfeed.h"
-
#include "log.h"
#include "demuxer.h"
#include "callback.h"
+#include "vfeed.h"
+
VFeed::VFeed(Callback* tcb)
: cb(*tcb)
{
}
-int VFeed::init()
-{
- return 1;
-}
-
-int VFeed::shutdown()
+void VFeed::start()
{
- // FIXME
- return 1;
-}
-
-int VFeed::start(bool tWaitForSignal)
-{
- waitForSignal = tWaitForSignal;
- return threadStart();
+ threadStartProtect.lock();
+ feedThread = std::thread( [this]
+ {
+ threadStartProtect.lock();
+ threadStartProtect.unlock();
+ threadMethod();
+ });
+ threadStartProtect.unlock();
}
void VFeed::stop()
{
- Log::getInstance()->log("VFeed", Log::DEBUG, "Stop1");
- threadCancel();
- Log::getInstance()->log("VFeed", Log::DEBUG, "Stop2");
-}
-
-void VFeed::release()
-{
- threadSignal();
+ Log::getInstance()->log("VFeed", Log::DEBUG, "Stop1");
+ if (!feedThread.joinable()) return;
+ stopThread = true;
+ feedThread.join();
+ stopThread = false;
+ Log::getInstance()->log("VFeed", Log::DEBUG, "Stop2");
}
void VFeed::threadMethod()
bool vlen;
Log::getInstance()->log("VFeed", Log::DEBUG, "Started");
- if (waitForSignal) threadWaitForSignal(); // Don't feed video until audio has started
- Log::getInstance()->log("VFeed", Log::DEBUG, "Released");
while(1)
{
- threadCheckExit();
+ if (stopThread) return;
vlen = Demuxer::getInstance()->writeVideo();
if (vlen)
/*
- Copyright 2004-2005 Chris Tallon
+ Copyright 2004-2020 Chris Tallon
This file is part of VOMP.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef VFEED_H
#define VFEED_H
-#include <stdio.h>
-#include <time.h>
-
-#ifndef WIN32
-#ifdef __ANDROID__
-#include "threadpandroid.h"
-#else
-#include "threadp.h"
-#endif
-#else
-#include "threadwin.h"
-#endif
+#include <thread>
+#include <mutex>
class Callback;
-class VFeed : public Thread_TYPE
+class VFeed
{
public:
VFeed(Callback* tcb);
- int init();
-
- int shutdown();
- int start(bool tWaitForSignal = true);
+ void start();
void stop();
- void release();
private:
+ std::thread feedThread;
+ std::mutex threadStartProtect;
void threadMethod();
Callback& cb;
- bool waitForSignal;
+ bool stopThread{};
};
#endif