| 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 "kernel/ComponentManager.h"
|
|---|
| 12 | #include "kernel/Log.h"
|
|---|
| 13 | #include "DbitePlayer/DbtPlyTrigger.h"
|
|---|
| 14 |
|
|---|
| 15 | namespace pacpus {
|
|---|
| 16 |
|
|---|
| 17 | DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyTrigger");
|
|---|
| 18 |
|
|---|
| 19 | // Construction de la fabrique de composant DbtPlyTrigger
|
|---|
| 20 | //static ComponentFactory<DbtPlyTrigger> factory("DbtPlyTrigger");
|
|---|
| 21 |
|
|---|
| 22 | DbtPlyTrigger::DbtPlyTrigger(QString name)
|
|---|
| 23 | : ComponentBase(name)
|
|---|
| 24 | , mEngine(NULL)
|
|---|
| 25 | {
|
|---|
| 26 | THREAD_ALIVE = false;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | DbtPlyTrigger::~DbtPlyTrigger()
|
|---|
| 30 | {
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | ComponentBase::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 |
|
|---|
| 49 | void DbtPlyTrigger::startActivity()
|
|---|
| 50 | {
|
|---|
| 51 | THREAD_ALIVE = true;
|
|---|
| 52 | start();
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | void DbtPlyTrigger::stopActivity()
|
|---|
| 56 | {
|
|---|
| 57 | THREAD_ALIVE = false;
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | // The thread is started when the user press the play button
|
|---|
| 61 | void 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
|
|---|