From 02acf3cebd9ec61193f63415590929ef40c504c1 Mon Sep 17 00:00:00 2001 From: blacky Date: Fri, 1 Jul 2011 12:53:35 +0200 Subject: update & cleanup --- AudioManagerDeamon/AudioManagerCore.cpp | 191 ++++++++++++++++++++------------ 1 file changed, 120 insertions(+), 71 deletions(-) (limited to 'AudioManagerDeamon/AudioManagerCore.cpp') diff --git a/AudioManagerDeamon/AudioManagerCore.cpp b/AudioManagerDeamon/AudioManagerCore.cpp index 8a548ce..9133006 100644 --- a/AudioManagerDeamon/AudioManagerCore.cpp +++ b/AudioManagerDeamon/AudioManagerCore.cpp @@ -35,7 +35,8 @@ Task::Task(AudioManagerCore* core) { m_core = core; } -TaskAsyncConnect::TaskAsyncConnect(AudioManagerCore* core, sink_t sink, source_t source) : +TaskAsyncConnect::TaskAsyncConnect(AudioManagerCore* core, sink_t sink, + source_t source) : Task(core), m_ParamSink(sink), m_ParamSource(source) { } @@ -43,11 +44,16 @@ TaskAsyncConnect::~TaskAsyncConnect() { } void TaskAsyncConnect::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); - QObject::connect((const QObject*) m_core->returnReceiver(), SIGNAL(signal_ackConnect(genHandle_t , genError_t )), (const QObject*) this, SLOT(slot_connect_finished(genHandle_t , genError_t ))); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) m_core->returnReceiver(), + SIGNAL(signal_ackConnect(genHandle_t, genError_t)), + (const QObject*) this, + SLOT(slot_connect_finished(genHandle_t, genError_t))); m_timer = new QTimer(); m_timer->setSingleShot(true); - QObject::connect(m_timer, SIGNAL(timeout()), (const QObject*) this, SLOT(slot_timeout())); + QObject::connect(m_timer, SIGNAL(timeout()), (const QObject*) this, + SLOT(slot_timeout())); DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Started Connect")); m_timer->start(CONNECT_TIMEOUT); m_core->connect(m_ParamSource, m_ParamSink, &m_handle); @@ -69,7 +75,8 @@ source_t TaskAsyncConnect::getSource() { return m_ParamSource; } -void TaskAsyncConnect::slot_connect_finished(genHandle_t handle, genError_t error) { +void TaskAsyncConnect::slot_connect_finished(genHandle_t handle, + genError_t error) { if (handle == m_handle && error == GEN_OK) { m_timer->stop(); delete m_timer; @@ -96,27 +103,30 @@ TaskConnect::~TaskConnect() { } void TaskConnect::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Started Syncronous Connect")); m_core->connect(m_ParamSource, m_ParamSink); emit signal_nextTask(); } TaskDisconnect::TaskDisconnect(AudioManagerCore* core, connection_t ID) : - Task(core), m_ParamConnectionID(ID) { + Task(core), m_ParamConnectionID(ID) { } TaskDisconnect::~TaskDisconnect() { } void TaskDisconnect::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); m_core->disconnect(m_ParamConnectionID); emit signal_nextTask(); } -TaskInterruptWait::TaskInterruptWait(AudioManagerCore* core,genInt_t interruptID) : - Task(core), m_interruptID(interruptID) { +TaskInterruptWait::TaskInterruptWait(AudioManagerCore* core, + genInt_t interruptID) : + Task(core), m_interruptID(interruptID) { } TaskInterruptWait::~TaskInterruptWait() { @@ -124,17 +134,21 @@ TaskInterruptWait::~TaskInterruptWait() { } void TaskInterruptWait::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); - QObject::connect((const QObject*) m_core->returnCommandInterface(), SIGNAL(signal_interruptResume(genInt_t)), (const QObject*) this, SLOT(slot_interrupt_ready(genInt_t))); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) m_core->returnCommandInterface(), + SIGNAL(signal_interruptResume(genInt_t)), (const QObject*) this, + SLOT(slot_interrupt_ready(genInt_t))); } void TaskInterruptWait::slot_interrupt_ready(genInt_t ID) { - if (ID==m_interruptID) { + if (ID == m_interruptID) { emit signal_nextTask(); } } -TaskSetVolume::TaskSetVolume(AudioManagerCore* core, volume_t newVolume, sink_t sink) : +TaskSetVolume::TaskSetVolume(AudioManagerCore* core, volume_t newVolume, + sink_t sink) : Task(core), m_volume(newVolume), m_sink(sink) { } @@ -159,14 +173,16 @@ sink_t TaskSetVolume::getSink() { } void TaskSetVolume::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Started Changed Volume")); m_core->setVolume(m_sink, m_volume); emit signal_nextTask(); } -TaskSetSourceVolume::TaskSetSourceVolume(AudioManagerCore* core, volume_t newVolume, source_t source) : - Task(core), m_volume(newVolume), m_source(source) { +TaskSetSourceVolume::TaskSetSourceVolume(AudioManagerCore* core, + volume_t newVolume, source_t source) : + Task(core), m_volume(newVolume), m_source(source) { } @@ -175,14 +191,14 @@ TaskSetSourceVolume::~TaskSetSourceVolume() { } void TaskSetSourceVolume::setVolume(volume_t newVolume) { - m_volume=newVolume; + m_volume = newVolume; } void TaskSetSourceVolume::setSource(source_t source) { - m_source=source; + m_source = source; } -volume_t TaskSetSourceVolume::getVolume(){ +volume_t TaskSetSourceVolume::getVolume() { return m_volume; } source_t TaskSetSourceVolume::getSource() { @@ -190,7 +206,8 @@ source_t TaskSetSourceVolume::getSource() { } void TaskSetSourceVolume::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Started Changed Source Volume")); m_core->setSourceVolume(m_source, m_volume); emit signal_nextTask(); @@ -212,10 +229,12 @@ int TaskWait::getTime() { } void TaskWait::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); m_timer = new QTimer(); m_timer->setSingleShot(true); - QObject::connect(m_timer, SIGNAL(timeout()), (const QObject*) this, SLOT(slot_timeIsup())); + QObject::connect(m_timer, SIGNAL(timeout()), (const QObject*) this, + SLOT(slot_timeIsup())); DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Start Sleep ")); m_timer->start(m_ParamMSeconds); } @@ -226,7 +245,8 @@ void TaskWait::slot_timeIsup() { emit signal_nextTask(); } -TaskEnterUserConnect::TaskEnterUserConnect(AudioManagerCore* core, genRoute_t route, connection_t connID) : +TaskEnterUserConnect::TaskEnterUserConnect(AudioManagerCore* core, + genRoute_t route, connection_t connID) : Task(core), m_route(route), m_connectionID(connID) { } @@ -235,7 +255,7 @@ TaskEnterUserConnect::~TaskEnterUserConnect() { void TaskEnterUserConnect::setConnection(genRoute_t route, connection_t connID) { m_route = route; - m_connectionID=connID; + m_connectionID = connID; } genRoute_t TaskEnterUserConnect::returnConnection() { @@ -243,13 +263,16 @@ genRoute_t TaskEnterUserConnect::returnConnection() { } void TaskEnterUserConnect::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); - m_core->returnDatabaseHandler()->updateMainConnection(m_connectionID,m_route); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); + m_core->returnDatabaseHandler()->updateMainConnection(m_connectionID, + m_route); emit signal_nextTask(); } -TaskRemoveUserConnect::TaskRemoveUserConnect(AudioManagerCore* core, connection_t connID): - Task(core), m_connectionID(connID) { +TaskRemoveUserConnect::TaskRemoveUserConnect(AudioManagerCore* core, + connection_t connID) : + Task(core), m_connectionID(connID) { } TaskRemoveUserConnect::~TaskRemoveUserConnect() { @@ -257,7 +280,7 @@ TaskRemoveUserConnect::~TaskRemoveUserConnect() { } void TaskRemoveUserConnect::setConnectionID(connection_t connID) { - m_connectionID=connID; + m_connectionID = connID; } connection_t TaskRemoveUserConnect::returnConnectionID() { @@ -265,21 +288,26 @@ connection_t TaskRemoveUserConnect::returnConnectionID() { } void TaskRemoveUserConnect::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); m_core->returnDatabaseHandler()->removeMainConnection(m_connectionID); emit signal_nextTask(); } -TaskEnterInterrupt::TaskEnterInterrupt(AudioManagerCore* core, genInt_t ID, bool mixed, connection_t connID, QList listInterruptedSources) : - Task(core), m_intID(ID), m_mixed(mixed), m_connectionID(connID), m_interruptedSourcesList(listInterruptedSources) { +TaskEnterInterrupt::TaskEnterInterrupt(AudioManagerCore* core, genInt_t ID, + bool mixed, connection_t connID, QList listInterruptedSources) : + Task(core), m_intID(ID), m_mixed(mixed), m_connectionID(connID), + m_interruptedSourcesList(listInterruptedSources) { } TaskEnterInterrupt::~TaskEnterInterrupt() { } void TaskEnterInterrupt::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); - m_core->returnDatabaseHandler()->updateInterrupt(m_intID,m_connectionID,m_mixed,m_interruptedSourcesList); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); + m_core->returnDatabaseHandler()->updateInterrupt(m_intID, m_connectionID, + m_mixed, m_interruptedSourcesList); emit signal_nextTask(); } @@ -291,45 +319,51 @@ TaskRemoveInterrupt::~TaskRemoveInterrupt() { } void TaskRemoveInterrupt::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); m_core->returnDatabaseHandler()->removeInterrupt(m_intID); emit signal_nextTask(); } TaskSetSourceMute::TaskSetSourceMute(AudioManagerCore* core, source_t source) : - Task(core), m_source(source) { + Task(core), m_source(source) { } -TaskSetSourceMute::~TaskSetSourceMute(){ +TaskSetSourceMute::~TaskSetSourceMute() { } void TaskSetSourceMute::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); m_core->setSourceMute(m_source); emit signal_nextTask(); } -TaskSetSourceUnmute::TaskSetSourceUnmute(AudioManagerCore* core, source_t source): - Task(core), m_source(source) { +TaskSetSourceUnmute::TaskSetSourceUnmute(AudioManagerCore* core, + source_t source) : + Task(core), m_source(source) { } TaskSetSourceUnmute::~TaskSetSourceUnmute() { } void TaskSetSourceUnmute::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); m_core->setSourceUnMute(m_source); emit signal_nextTask(); } -TaskEmitSignalConnect::TaskEmitSignalConnect(AudioManagerCore* core) : Task(core) { +TaskEmitSignalConnect::TaskEmitSignalConnect(AudioManagerCore* core) : + Task(core) { } TaskEmitSignalConnect::~TaskEmitSignalConnect() { } void TaskEmitSignalConnect::executeTask(Queue* queue) { - QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), (const QObject*) queue, SLOT(slot_nextTask())); + QObject::connect((const QObject*) this, SIGNAL(signal_nextTask()), + (const QObject*) queue, SLOT(slot_nextTask())); m_core->emitSignalConnect(); emit signal_nextTask(); } @@ -341,15 +375,14 @@ Queue::Queue(AudioManagerCore* core, QString name) : Queue::~Queue() { DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("shoot all tasks")); - foreach (Task* task, m_taskList) - { - delete task; - } + foreach (Task* task, m_taskList) { + delete task; + } m_core->removeQueue(this); } void Queue::run() { - if (m_taskList.isEmpty()==false) { + if (m_taskList.isEmpty() == false) { Task* task = m_taskList.first(); DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Started to execute Task")); task->executeTask(this); @@ -397,10 +430,9 @@ AudioManagerCore::AudioManagerCore() : AudioManagerCore::~AudioManagerCore() { DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("delete all running queues")); - foreach (Queue* queue, m_queueList) - { - delete queue; - } + foreach (Queue* queue, m_queueList) { + delete queue; + } } Router* AudioManagerCore::returnRouter() { @@ -440,19 +472,21 @@ void AudioManagerCore::registerReceiver(RoutingReceiver* receiver) { } void AudioManagerCore::registerCommandInterface(DBusCommandInterface* command) { - m_command=command; + m_command = command; } genError_t AudioManagerCore::UserConnect(source_t source, sink_t sink) { Queue* userConnectionRequestQ = new Queue(this, "User Connect"); - m_hookHandler->fireHookUserConnectionRequest(userConnectionRequestQ, source, sink); + m_hookHandler->fireHookUserConnectionRequest(userConnectionRequestQ, + source, sink); userConnectionRequestQ->run(); return GEN_OK; } genError_t AudioManagerCore::UserDisconnect(connection_t connID) { Queue* userDisconnectionRequestQ = new Queue(this, "User Disconnect"); - m_hookHandler->fireHookUserDisconnectionRequest(userDisconnectionRequestQ,connID); + m_hookHandler->fireHookUserDisconnectionRequest(userDisconnectionRequestQ, + connID); userDisconnectionRequestQ->run(); return GEN_OK; } @@ -482,11 +516,13 @@ void AudioManagerCore::emitSignalConnect() { emit signal_connectionChanged(); } -genError_t AudioManagerCore::connect(source_t source, sink_t sink, genHandle_t* handle) { +genError_t AudioManagerCore::connect(source_t source, sink_t sink, + genHandle_t* handle) { genHandle_t localhandle; DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Connect"), DLT_INT(source), DLT_STRING(" to "), DLT_INT(sink)); domain_t domainID = m_databaseHandler->get_Domain_ID_from_Source_ID(source); - RoutingSendInterface* iface = m_busHandler->getInterfaceforBus(m_databaseHandler->get_Bus_from_Domain_ID(domainID)); + RoutingSendInterface* iface = m_busHandler->getInterfaceforBus( + m_databaseHandler->get_Bus_from_Domain_ID(domainID)); localhandle = m_databaseHandler->insertConnection(source, sink); if (handle) { @@ -502,7 +538,8 @@ genError_t AudioManagerCore::connect(source_t source, sink_t sink, genHandle_t* genError_t AudioManagerCore::disconnect(connection_t ID) { domain_t domainID = m_databaseHandler->get_Domain_ID_from_Connection_ID(ID); - RoutingSendInterface* iface = m_busHandler->getInterfaceforBus(m_databaseHandler->get_Bus_from_Domain_ID(domainID)); + RoutingSendInterface* iface = m_busHandler->getInterfaceforBus( + m_databaseHandler->get_Bus_from_Domain_ID(domainID)); iface->disconnect(ID); m_databaseHandler->removeConnection(ID); return GEN_OK; @@ -512,7 +549,9 @@ genError_t AudioManagerCore::disconnect(connection_t ID) { } genError_t AudioManagerCore::setVolume(sink_t sink, volume_t volume) { - RoutingSendInterface* iface = m_busHandler->getInterfaceforBus(m_databaseHandler->get_Bus_from_Domain_ID(m_databaseHandler->get_Domain_ID_from_Sink_ID(sink))); + RoutingSendInterface* iface = m_busHandler->getInterfaceforBus( + m_databaseHandler->get_Bus_from_Domain_ID( + m_databaseHandler->get_Domain_ID_from_Sink_ID(sink))); iface->setSinkVolume(volume, sink); return GEN_OK; /** @@ -520,37 +559,47 @@ genError_t AudioManagerCore::setVolume(sink_t sink, volume_t volume) { */ } -genError_t AudioManagerCore::interruptRequest(source_t interruptSource, sink_t sink, genInt_t* interrupt) { +genError_t AudioManagerCore::interruptRequest(source_t interruptSource, + sink_t sink, genInt_t* interrupt) { Queue* interruptRequestQ = new Queue(this, "Interrupt Request"); - m_hookHandler->fireHookInterruptRequest(interruptRequestQ, interruptSource, sink, interrupt); + m_hookHandler->fireHookInterruptRequest(interruptRequestQ, interruptSource, + sink, interrupt); interruptRequestQ->run(); return GEN_OK; } -genError_t AudioManagerCore::setSourceVolume (source_t source, volume_t volume) { - RoutingSendInterface* iface = m_busHandler->getInterfaceforBus(m_databaseHandler->get_Bus_from_Domain_ID(m_databaseHandler->get_Domain_ID_from_Source_ID(source))); +genError_t AudioManagerCore::setSourceVolume(source_t source, volume_t volume) { + RoutingSendInterface* iface = m_busHandler->getInterfaceforBus( + m_databaseHandler->get_Bus_from_Domain_ID( + m_databaseHandler->get_Domain_ID_from_Source_ID(source))); iface->setSourceVolume(volume, source); return GEN_OK; } -genError_t AudioManagerCore::setSourceMute (source_t source) { - RoutingSendInterface* iface = m_busHandler->getInterfaceforBus(m_databaseHandler->get_Bus_from_Domain_ID(m_databaseHandler->get_Domain_ID_from_Source_ID(source))); +genError_t AudioManagerCore::setSourceMute(source_t source) { + RoutingSendInterface* iface = m_busHandler->getInterfaceforBus( + m_databaseHandler->get_Bus_from_Domain_ID( + m_databaseHandler->get_Domain_ID_from_Source_ID(source))); iface->muteSource(source); return GEN_OK; } -genError_t AudioManagerCore::setSourceUnMute (source_t source) { - RoutingSendInterface* iface = m_busHandler->getInterfaceforBus(m_databaseHandler->get_Bus_from_Domain_ID(m_databaseHandler->get_Domain_ID_from_Source_ID(source))); +genError_t AudioManagerCore::setSourceUnMute(source_t source) { + RoutingSendInterface* iface = m_busHandler->getInterfaceforBus( + m_databaseHandler->get_Bus_from_Domain_ID( + m_databaseHandler->get_Domain_ID_from_Source_ID(source))); iface->unmuteSource(source); return GEN_OK; } -genError_t AudioManagerCore::getRoute(const bool onlyfree, const source_t source, const sink_t sink, QList* ReturnList) { - m_hookHandler->fireHookRoutingRequest(onlyfree,source,sink,ReturnList); +genError_t AudioManagerCore::getRoute(const bool onlyfree, + const source_t source, const sink_t sink, QList* ReturnList) { + m_hookHandler->fireHookRoutingRequest(onlyfree, source, sink, ReturnList); return GEN_OK; } -connection_t AudioManagerCore::returnConnectionIDforSinkSource (sink_t sink, source_t source) { +connection_t AudioManagerCore::returnConnectionIDforSinkSource(sink_t sink, + source_t source) { return m_databaseHandler->getConnectionID(source, sink); } -- cgit v1.2.1