| 1 | /* This file is part of the KDE project |
|---|---|
| 2 | Copyright (C) 2008 Matthias Kretz <kretz@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) version 3, or any |
| 8 | later version accepted by the membership of KDE e.V. (or its |
| 9 | successor approved by the membership of KDE e.V.), Nokia Corporation |
| 10 | (or its successors, if any) and the KDE Free Qt Foundation, which shall |
| 11 | act as a proxy defined in Section 6 of version 3 of the license. |
| 12 | |
| 13 | This library is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | Lesser General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU Lesser General Public |
| 19 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | #include "abstractaudiodataoutput.h" |
| 24 | #include "abstractaudiodataoutput_p.h" |
| 25 | #include "audiodataoutputinterface.h" |
| 26 | #include "factory_p.h" |
| 27 | #include "../phonondefs_p.h" |
| 28 | |
| 29 | namespace Phonon |
| 30 | { |
| 31 | namespace Experimental |
| 32 | { |
| 33 | |
| 34 | AbstractAudioDataOutput::AbstractAudioDataOutput() |
| 35 | : MediaNode(*new AbstractAudioDataOutputPrivate) |
| 36 | { |
| 37 | P_D(AbstractAudioDataOutput); |
| 38 | d->isRunning = false; |
| 39 | d->allowedFormats << AudioFormat(); |
| 40 | } |
| 41 | |
| 42 | AbstractAudioDataOutput::~AbstractAudioDataOutput() |
| 43 | { |
| 44 | setRunning(false); |
| 45 | } |
| 46 | |
| 47 | QSet<AudioFormat> AbstractAudioDataOutput::allowedFormats() const |
| 48 | { |
| 49 | P_D(const AbstractAudioDataOutput); |
| 50 | return d->allowedFormats; |
| 51 | } |
| 52 | |
| 53 | void AbstractAudioDataOutput::setAllowedFormats(const QSet<AudioFormat> &allowedFormats) |
| 54 | { |
| 55 | P_D(AbstractAudioDataOutput); |
| 56 | d->allowedFormats = allowedFormats; |
| 57 | } |
| 58 | |
| 59 | bool AbstractAudioDataOutput::isRunning() const |
| 60 | { |
| 61 | P_D(const AbstractAudioDataOutput); |
| 62 | return d->isRunning; |
| 63 | } |
| 64 | |
| 65 | void AbstractAudioDataOutput::setRunning(bool running) |
| 66 | { |
| 67 | P_D(AbstractAudioDataOutput); |
| 68 | Iface<AudioDataOutputInterface> iface(d); |
| 69 | if (iface) { |
| 70 | if (running) { |
| 71 | iface->setFrontendObject(this); |
| 72 | } else { |
| 73 | iface->setFrontendObject(nullptr); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | void AbstractAudioDataOutput::start() |
| 79 | { |
| 80 | setRunning(true); |
| 81 | } |
| 82 | |
| 83 | void AbstractAudioDataOutput::stop() |
| 84 | { |
| 85 | setRunning(false); |
| 86 | } |
| 87 | |
| 88 | void AbstractAudioDataOutputPrivate::setupBackendObject() |
| 89 | { |
| 90 | P_Q(AbstractAudioDataOutput); |
| 91 | Q_ASSERT(m_backendObject); |
| 92 | //AbstractAudioOutputPrivate::setupBackendObject(); |
| 93 | if (isRunning) { |
| 94 | Iface<AudioDataOutputInterface> iface(this); |
| 95 | if (iface) { |
| 96 | iface->setFrontendObject(q); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void AbstractAudioDataOutputPrivate::createBackendObject() |
| 102 | { |
| 103 | if (m_backendObject) |
| 104 | return; |
| 105 | //P_Q(AbstractAudioDataOutput); |
| 106 | m_backendObject = Factory::createAudioDataOutput(parent: nullptr); |
| 107 | if (m_backendObject) { |
| 108 | setupBackendObject(); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | } // namespace Experimental |
| 113 | } // namespace Phonon |
| 114 |
