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