source: pacpusframework/trunk/src/DBITEPlayerLib/DbtPlyTrigger.cpp@ 51

Last change on this file since 51 was 31, checked in by sgosseli, 12 years ago

Huge commit: use the new includes style in all the files, add the license header in all the headers, and in some cpp.

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