source: pacpusframework/branches/0.0.x/src/DBITEPlayerLib/DbtPlyTrigger.cpp@ 185

Last change on this file since 185 was 91, checked in by DHERBOMEZ Gérald, 12 years ago

Improvement of the build system to avoid some workarounds

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1// %pacpus:license{
2// This file is part of the PACPUS framework distributed under the
3// CECILL-C License, Version 1.0.
4// %pacpus:license}
5/// @author Gerald Dherbomez <firstname.surname@utc.fr>
6/// @version $Id: DbtPlyTrigger.cpp 91 2013-05-19 10:32:48Z gdherbom $
7
8#include <Pacpus/DbitePlayer/DbtPlyTrigger.h>
9
10#include <Pacpus/kernel/ComponentManager.h>
11#include <Pacpus/kernel/Log.h>
12
13namespace pacpus {
14
15DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyTrigger");
16
17// Construction de la fabrique de composant DbtPlyTrigger
18//static ComponentFactory<DbtPlyTrigger> factory("DbtPlyTrigger");
19
20DbtPlyTrigger::DbtPlyTrigger(QString name)
21 : ComponentBase(name)
22 , mEngine(NULL)
23{
24 THREAD_ALIVE = false;
25}
26
27DbtPlyTrigger::~DbtPlyTrigger()
28{
29}
30
31ComponentBase::COMPONENT_CONFIGURATION DbtPlyTrigger::configureComponent(XmlComponentConfig /*config*/)
32{
33 ComponentManager * mgr = ComponentManager::getInstance();
34 // we get a pointer to the engine component
35 mEngine = dynamic_cast<DbtPlyEngine *>(mgr->getComponent("dbiteEngine"));
36 if (NULL == mEngine) {
37 LOG_FATAL("cannot get a pointer of the 'dbiteEngine' component");
38 return CONFIGURED_FAILED;
39 }
40 connect(this, SIGNAL(triggerSig()),
41 mEngine,SLOT(engReceiver()),
42 Qt::DirectConnection);
43
44 return CONFIGURED_OK;
45}
46
47void DbtPlyTrigger::startActivity()
48{
49 THREAD_ALIVE = true;
50 start();
51}
52
53void DbtPlyTrigger::stopActivity()
54{
55 THREAD_ALIVE = false;
56}
57
58// The thread is started when the user press the play button
59void DbtPlyTrigger::run()
60{
61#ifdef WIN32
62 timeBeginPeriod(1);
63#endif
64
65 while(THREAD_ALIVE) {
66 if (mEngine->isPlaying()) {
67 Q_EMIT triggerSig();
68 }
69 msleep(1);
70 }
71
72#ifdef WIN32
73 timeEndPeriod(1);
74#endif
75}
76
77} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.