summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/phonon/mmf/mmf_medianode.cpp
diff options
context:
space:
mode:
authorFrans Englich <frans.englich@nokia.com>2009-09-06 23:22:32 (GMT)
committerGareth Stockwell <gareth.stockwell@sosco.com>2009-09-09 15:30:19 (GMT)
commitc4fb0864e229ff33e4b454c74116573a9ea79054 (patch)
tree15b70bac51904b01c1885c103bb69a6d95551b6c /src/3rdparty/phonon/mmf/mmf_medianode.cpp
parent7d2d15bbc9d598daf94800b576aff19a68119ed1 (diff)
downloadQt-c4fb0864e229ff33e4b454c74116573a9ea79054.zip
Qt-c4fb0864e229ff33e4b454c74116573a9ea79054.tar.gz
Qt-c4fb0864e229ff33e4b454c74116573a9ea79054.tar.bz2
Make the MediaObject propagation generic for all kinds of nodes.
Previously the MediaObject propagation was only done for effects, but now it's for all kinds of nodes. This is needed for AudioOutput.
Diffstat (limited to 'src/3rdparty/phonon/mmf/mmf_medianode.cpp')
-rw-r--r--src/3rdparty/phonon/mmf/mmf_medianode.cpp56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/3rdparty/phonon/mmf/mmf_medianode.cpp b/src/3rdparty/phonon/mmf/mmf_medianode.cpp
index a210c49..54c51a0 100644
--- a/src/3rdparty/phonon/mmf/mmf_medianode.cpp
+++ b/src/3rdparty/phonon/mmf/mmf_medianode.cpp
@@ -16,6 +16,8 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "mediaobject.h"
+
#include "mmf_medianode.h"
QT_BEGIN_NAMESPACE
@@ -26,6 +28,7 @@ using namespace Phonon::MMF;
MMF::MediaNode::MediaNode(QObject *parent) : QObject::QObject(parent)
, m_source(0)
, m_target(0)
+ , m_isApplied(false)
{
}
@@ -33,13 +36,15 @@ bool MMF::MediaNode::connectMediaNode(MediaNode *target)
{
m_target = target;
m_target->setSource(this);
- return true;
+
+ return applyNodesOnMediaObject(target);
}
bool MMF::MediaNode::disconnectMediaNode(MediaNode *target)
{
Q_UNUSED(target);
m_target = 0;
+ m_isApplied = false;
return false;
}
@@ -58,6 +63,55 @@ MMF::MediaNode *MMF::MediaNode::target() const
return m_target;
}
+bool MediaNode::applyNodesOnMediaObject(MediaNode *)
+{
+ // Algorithmically, this can be expressed in a more efficient way by
+ // exercising available assumptions, but it complicates code for input
+ // data(length of the graph) which typically is very small.
+
+ // First, we go to the very beginning of the graph.
+ MediaNode *current = this;
+ do {
+ MediaNode *const candidate = current->source();
+ if (candidate)
+ current = candidate;
+ else
+ break;
+ }
+ while (current);
+
+ // Now we do two things, while walking to the other end:
+ // 1. Find the MediaObject, if present
+ // 2. Collect a list of all unapplied MediaNodes
+
+ QList<MediaNode *> unapplied;
+ MMF::MediaObject *mo = 0;
+
+ do {
+ if (!current->m_isApplied)
+ unapplied.append(current);
+
+ if (!mo)
+ mo = qobject_cast<MMF::MediaObject *>(current);
+
+ current = current->target();
+ }
+ while (current);
+
+ // Now, lets activate all the objects, if we found the MediaObject.
+
+ if (mo) {
+ for (int i = 0; i < unapplied.count(); ++i) {
+ MediaNode *const at = unapplied.at(i);
+
+ // We don't want to apply MediaObject on itself.
+ if (at != mo)
+ at->activateOnMediaObject(mo);
+ }
+ }
+
+ return true;
+}
QT_END_NAMESPACE