File indexing completed on 2024-05-05 04:44:40
0001 /* This file is part of the KDE project 0002 Copyright (C) 2008 Matthias Kretz <kretz@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) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 0021 */ 0022 0023 #include "abstractaudiodataoutput.h" 0024 #include "abstractaudiodataoutput_p.h" 0025 #include "audiodataoutputinterface.h" 0026 #include "factory_p.h" 0027 #include "../phonondefs_p.h" 0028 0029 namespace Phonon 0030 { 0031 namespace Experimental 0032 { 0033 0034 AbstractAudioDataOutput::AbstractAudioDataOutput() 0035 : MediaNode(*new AbstractAudioDataOutputPrivate) 0036 { 0037 P_D(AbstractAudioDataOutput); 0038 d->isRunning = false; 0039 d->allowedFormats << AudioFormat(); 0040 } 0041 0042 AbstractAudioDataOutput::~AbstractAudioDataOutput() 0043 { 0044 setRunning(false); 0045 } 0046 0047 QSet<AudioFormat> AbstractAudioDataOutput::allowedFormats() const 0048 { 0049 P_D(const AbstractAudioDataOutput); 0050 return d->allowedFormats; 0051 } 0052 0053 void AbstractAudioDataOutput::setAllowedFormats(const QSet<AudioFormat> &allowedFormats) 0054 { 0055 P_D(AbstractAudioDataOutput); 0056 d->allowedFormats = allowedFormats; 0057 } 0058 0059 bool AbstractAudioDataOutput::isRunning() const 0060 { 0061 P_D(const AbstractAudioDataOutput); 0062 return d->isRunning; 0063 } 0064 0065 void AbstractAudioDataOutput::setRunning(bool running) 0066 { 0067 P_D(AbstractAudioDataOutput); 0068 Iface<AudioDataOutputInterface> iface(d); 0069 if (iface) { 0070 if (running) { 0071 iface->setFrontendObject(this); 0072 } else { 0073 iface->setFrontendObject(nullptr); 0074 } 0075 } 0076 } 0077 0078 void AbstractAudioDataOutput::start() 0079 { 0080 setRunning(true); 0081 } 0082 0083 void AbstractAudioDataOutput::stop() 0084 { 0085 setRunning(false); 0086 } 0087 0088 void AbstractAudioDataOutputPrivate::setupBackendObject() 0089 { 0090 P_Q(AbstractAudioDataOutput); 0091 Q_ASSERT(m_backendObject); 0092 //AbstractAudioOutputPrivate::setupBackendObject(); 0093 if (isRunning) { 0094 Iface<AudioDataOutputInterface> iface(this); 0095 if (iface) { 0096 iface->setFrontendObject(q); 0097 } 0098 } 0099 } 0100 0101 void AbstractAudioDataOutputPrivate::createBackendObject() 0102 { 0103 if (m_backendObject) 0104 return; 0105 //P_Q(AbstractAudioDataOutput); 0106 m_backendObject = Factory::createAudioDataOutput(nullptr); 0107 if (m_backendObject) { 0108 setupBackendObject(); 0109 } 0110 } 0111 0112 } // namespace Experimental 0113 } // namespace Phonon