File indexing completed on 2024-04-28 04:43:21

0001 /*
0002     Copyright (C) 2013 Harald Sitter <sitter@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Lesser General Public License for more details.
0013 
0014     You should have received a copy of the GNU Lesser General Public
0015     License along with this library.  If not, see <http://www.gnu.org/licenses/>.
0016 */
0017 
0018 #include "sinknode.h"
0019 
0020 #include "utils/debug.h"
0021 #include "mediaobject.h"
0022 #include "mediaplayer.h"
0023 
0024 namespace Phonon {
0025 namespace VLC {
0026 
0027 SinkNode::SinkNode()
0028     : m_mediaObject(0)
0029     , m_player(0)
0030 {
0031 }
0032 
0033 SinkNode::~SinkNode()
0034 {
0035     if (m_mediaObject) {
0036         disconnectFromMediaObject(m_mediaObject);
0037     }
0038 }
0039 
0040 void SinkNode::connectToMediaObject(MediaObject *mediaObject)
0041 {
0042     if (m_mediaObject) {
0043         error() << Q_FUNC_INFO << "m_mediaObject already connected";
0044     }
0045 
0046     m_mediaObject = mediaObject;
0047     m_player = mediaObject->m_player;
0048     m_mediaObject->addSink(this);
0049 
0050     // ---> Global handling goes here! Above the derivee handle! <--- //
0051 
0052     handleConnectToMediaObject(mediaObject);
0053 }
0054 
0055 void SinkNode::disconnectFromMediaObject(MediaObject *mediaObject)
0056 {
0057     handleDisconnectFromMediaObject(mediaObject);
0058 
0059     // ---> Global handling goes here! Below the derivee handle! <--- //
0060 
0061     if (m_mediaObject != mediaObject) {
0062         error() << Q_FUNC_INFO << "SinkNode was not connected to mediaObject";
0063     }
0064 
0065     if (m_mediaObject) {
0066         m_mediaObject->removeSink(this);
0067     }
0068 
0069     m_mediaObject = 0;
0070     m_player = 0;
0071 }
0072 
0073 void SinkNode::addToMedia(Media *media)
0074 {
0075     // ---> Global handling goes here! Above the derivee handle! <--- //
0076 
0077     handleAddToMedia(media);
0078 }
0079 
0080 } // namespace VLC
0081 } // namespace Phonon