/*
- 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 "afeed.h"
-
#include "log.h"
#include "demuxer.h"
#include "callback.h"
+#include "afeed.h"
AFeed::AFeed(Callback* tcb)
: cb(*tcb)
audioEnabled = 1;
}
-int AFeed::init()
-{
- return 1;
-}
-
-int AFeed::shutdown()
-{
- // FIXME
- return 1;
-}
-
void AFeed::disable()
{
audioEnabled = 0;
audioEnabled = 1;
}
-int AFeed::start()
+void AFeed::start()
{
audioEnabled = 1;
- return threadStart();
+
+ threadStartProtect.lock();
+ feedThread = std::thread( [this]
+ {
+ threadStartProtect.lock();
+ threadStartProtect.unlock();
+ threadMethod();
+ });
+ threadStartProtect.unlock();
}
void AFeed::stop()
{
- Log::getInstance()->log("AFeed", Log::DEBUG, "Stop1");
- threadCancel();
- Log::getInstance()->log("AFeed", Log::DEBUG, "Stop2");
+ Log::getInstance()->log("AFeed", Log::DEBUG, "Stop1");
+ if (!feedThread.joinable()) return;
+ stopThread = true;
+ feedThread.join();
+ stopThread = false;
+ Log::getInstance()->log("AFeed", Log::DEBUG, "Stop2");
}
void AFeed::threadMethod()
while(1)
{
- threadCheckExit();
+ if (stopThread) return;
if (audioEnabled)
{
/*
- 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 AFEED_H
#define AFEED_H
-#include <stdio.h>
-#include <time.h>
-
-
-#include "threadsystem.h"
+#include <thread>
+#include <mutex>
class Callback;
-class AFeed : public Thread_TYPE
+class AFeed
{
public:
AFeed(Callback* tcb);
- int init();
- int shutdown();
-
- int start();
+ void start();
void stop();
void enable();
void disable();
private:
+ std::thread feedThread;
+ std::mutex threadStartProtect;
void threadMethod();
+ bool stopThread{};
+
int audioEnabled;
bool callbacksend;
Callback& cb;
return 0;
}
- afeed.init();
audio->stop();
initted = true;
return 0;
}
- afeed.init();
- tfeed.init();
video->stop();
video->blank();
return false;
}
- afeed.init();
audio->stop();
lengthBytes = tlengthBytes;
return 0;
}
- afeed.init();
- tfeed.init();
-
video->stop();
video->blank();
audio->stop();
/*
-
Copyright 2008 Marten Richter
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 "tfeed.h"
#include "log.h"
#include "demuxer.h"
#include "callback.h"
+#include "tfeed.h"
TFeed::TFeed(Callback* tcb): cb(*tcb)
{
teletextEnabled = 1;
}
-
-int TFeed::init()
-{
- return 1;
-}
-
-int TFeed::shutdown()
-{
- // FIXME
- return 1;
-}
-
void TFeed::disable()
{
- teletextEnabled = 0;
+ teletextEnabled = 0;
}
void TFeed::enable()
{
- teletextEnabled = 1;
+ teletextEnabled = 1;
}
-int TFeed::start()
+void TFeed::start()
{
teletextEnabled = 1;
- return threadStart();
+
+ threadStartProtect.lock();
+ feedThread = std::thread( [this]
+ {
+ threadStartProtect.lock();
+ threadStartProtect.unlock();
+ threadMethod();
+ });
+ threadStartProtect.unlock();
}
void TFeed::stop()
{
- threadCancel();
+ if (!feedThread.joinable()) return;
+ stopThread = true;
+ feedThread.join();
+ stopThread = false;
}
void TFeed::threadMethod()
{
bool tlen;
- while(1){
- threadCheckExit();
+ while(1)
+ {
+ if (stopThread) return;
+
tlen = Demuxer::getInstance()->writeTeletext();
if (tlen)
}
}
}
-
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 TFEED_H
#define TFEED_H
+#include <thread>
+#include <mutex>
-#include <stdio.h>
-#include <time.h>
+class Callback;
-#include "threadsystem.h"
+class TFeed
+{
+ public:
+ TFeed(Callback* tcb);
-class Callback;
+ void start();
+ void stop();
+ void enable();
+ void disable();
-class TFeed: public Thread_TYPE {
-public:
- TFeed(Callback* tcb);
- int init();
- int shutdown();
- int start();
- void stop();
- void enable();
- void disable();
-
-private:
-
- void threadMethod();
- int teletextEnabled;
- Callback& cb;
+ private:
+ std::thread feedThread;
+ std::mutex threadStartProtect;
+ void threadMethod();
+ bool stopThread{};
+
+ int teletextEnabled;
+ Callback& cb;
};
#endif
-
-
std::thread feedThread;
std::mutex threadStartProtect;
void threadMethod();
- Callback& cb;
bool stopThread{};
+ Callback& cb;
};
#endif