Phonon

medianode.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). <thierry.bastian@trolltech.com>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) version 3, or any
9 later version accepted by the membership of KDE e.V. (or its
10 successor approved by the membership of KDE e.V.), Nokia Corporation
11 (or its successors, if any) and the KDE Free Qt Foundation, which shall
12 act as a proxy defined in Section 6 of version 3 of the license.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library. If not, see <http://www.gnu.org/licenses/>.
21
22*/
23
24#include "medianode.h"
25#include "medianode_p.h"
26#include "medianodedestructionhandler_p.h"
27#include "factory_p.h"
28
29namespace Phonon
30{
31
32 MediaNode::MediaNode(MediaNodePrivate &dd)
33 : k_ptr(&dd)
34 {
35 k_ptr->q_ptr = this;
36 }
37
38bool MediaNode::isValid() const
39{
40 return const_cast<MediaNodePrivate *>(k_ptr)->backendObject() != nullptr;
41}
42
43 QList<Path> MediaNode::inputPaths() const
44 {
45 return k_ptr->inputPaths;
46 }
47
48 QList<Path> MediaNode::outputPaths() const
49 {
50 return k_ptr->outputPaths;
51 }
52
53 MediaNode::~MediaNode()
54 {
55 delete k_ptr;
56 }
57
58 QObject *MediaNodePrivate::backendObject()
59 {
60 if (!m_backendObject && Factory::backend()) {
61 createBackendObject();
62 }
63 return m_backendObject;
64 }
65
66 MediaNodePrivate::~MediaNodePrivate()
67 {
68 for (int i = 0 ; i < handlers.count(); ++i) {
69 handlers.at(i)->phononObjectDestroyed(this);
70 }
71 Factory::deregisterFrontendObject(this);
72 delete m_backendObject;
73 m_backendObject = nullptr;
74 }
75
76void MediaNodePrivate::deleteBackendObject()
77{
78 if (m_backendObject && aboutToDeleteBackendObject()) {
79 delete m_backendObject;
80 m_backendObject = nullptr;
81 }
82}
83
84 MediaNodePrivate::MediaNodePrivate(MediaNodePrivate::CastId _castId) : castId(_castId),
85 m_backendObject(nullptr)
86 {
87 Factory::registerFrontendObject(this);
88 }
89
90 void MediaNodePrivate::addDestructionHandler(MediaNodeDestructionHandler *handler)
91 {
92 handlers.append(handler);
93 }
94
95 void MediaNodePrivate::removeDestructionHandler(MediaNodeDestructionHandler *handler)
96 {
97 handlers.removeAll(handler);
98 }
99
100 void MediaNodePrivate::addOutputPath(const Path &p)
101 {
102 outputPaths.append(p);
103 }
104
105 void MediaNodePrivate::addInputPath(const Path &p)
106 {
107 inputPaths.append(p);
108 }
109
110 void MediaNodePrivate::removeOutputPath(const Path &p)
111 {
112 int ret = outputPaths.removeAll(p);
113 Q_ASSERT(ret == 1);
114 Q_UNUSED(ret);
115 }
116
117 void MediaNodePrivate::removeInputPath(const Path &p)
118 {
119 int ret = inputPaths.removeAll(p);
120 Q_ASSERT(ret == 1);
121 Q_UNUSED(ret);
122 }
123
124
125
126} // namespace Phonon
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:24 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.