1/*
2 Copyright (C) 2013 Harald Sitter <sitter@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#include "sinknode.h"
19
20#include "utils/debug.h"
21#include "mediaobject.h"
22#include "mediaplayer.h"
23
24namespace Phonon {
25namespace VLC {
26
27SinkNode::SinkNode()
28 : m_mediaObject(0)
29 , m_player(0)
30{
31}
32
33SinkNode::~SinkNode()
34{
35 if (m_mediaObject) {
36 disconnectFromMediaObject(mediaObject: m_mediaObject);
37 }
38}
39
40void SinkNode::connectToMediaObject(MediaObject *mediaObject)
41{
42 if (m_mediaObject) {
43 error() << Q_FUNC_INFO << "m_mediaObject already connected";
44 }
45
46 m_mediaObject = mediaObject;
47 m_player = mediaObject->m_player;
48 m_mediaObject->addSink(node: this);
49
50 // ---> Global handling goes here! Above the derivee handle! <--- //
51
52 handleConnectToMediaObject(mediaObject);
53}
54
55void SinkNode::disconnectFromMediaObject(MediaObject *mediaObject)
56{
57 handleDisconnectFromMediaObject(mediaObject);
58
59 // ---> Global handling goes here! Below the derivee handle! <--- //
60
61 if (m_mediaObject != mediaObject) {
62 error() << Q_FUNC_INFO << "SinkNode was not connected to mediaObject";
63 }
64
65 if (m_mediaObject) {
66 m_mediaObject->removeSink(node: this);
67 }
68
69 m_mediaObject = 0;
70 m_player = 0;
71}
72
73void SinkNode::addToMedia(Media *media)
74{
75 // ---> Global handling goes here! Above the derivee handle! <--- //
76
77 handleAddToMedia(media);
78}
79
80} // namespace VLC
81} // namespace Phonon
82

source code of phonon-vlc/src/sinknode.cpp