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