| 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 | #ifndef PHONON_X_AUDIOFORMAT_H |
| 24 | #define PHONON_X_AUDIOFORMAT_H |
| 25 | |
| 26 | #include <QtGlobal> |
| 27 | #include "phononnamespace.h" |
| 28 | |
| 29 | namespace Phonon |
| 30 | { |
| 31 | namespace Experimental |
| 32 | { |
| 33 | |
| 34 | class AudioFormatPrivate; |
| 35 | class AudioFormat |
| 36 | { |
| 37 | //Q_DECLARE_PRIVATE(AudioFormat) |
| 38 | public: |
| 39 | AudioFormat(int sampleRate = 48000, int channelCount = 2, Phonon::Experimental::BitRate bitRate = Phonon::Experimental::Signed16Bit, QSysInfo::Endian byteOrder = QSysInfo::ByteOrder); |
| 40 | AudioFormat(const AudioFormat &); |
| 41 | ~AudioFormat(); |
| 42 | |
| 43 | AudioFormat &operator=(const AudioFormat &); |
| 44 | |
| 45 | int sampleRate() const; |
| 46 | int channelCount() const; |
| 47 | Phonon::Experimental::BitRate bitRate() const; |
| 48 | QSysInfo::Endian byteOrder() const; |
| 49 | |
| 50 | bool operator==(const AudioFormat &) const; |
| 51 | inline bool operator!=(const AudioFormat &f) const { return !operator==(f); } |
| 52 | |
| 53 | /** |
| 54 | * ess than operator for sorting: |
| 55 | * A Format is considered smaller if |
| 56 | * - smaller bit rate |
| 57 | * - smaller sample rate |
| 58 | * - less channels |
| 59 | * - non-native byte order |
| 60 | */ |
| 61 | bool operator<(const AudioFormat &) const; |
| 62 | |
| 63 | quint32 key() const; |
| 64 | |
| 65 | private: |
| 66 | union |
| 67 | { |
| 68 | struct |
| 69 | { |
| 70 | int m_sampleRate; |
| 71 | int m_channelCount; |
| 72 | Phonon::Experimental::BitRate m_bitRate; |
| 73 | QSysInfo::Endian m_byteOrder; |
| 74 | } s; |
| 75 | // for future use: |
| 76 | AudioFormatPrivate *d_ptr; |
| 77 | }; |
| 78 | }; |
| 79 | |
| 80 | inline uint qHash(const AudioFormat &p) |
| 81 | { |
| 82 | return p.key(); |
| 83 | } |
| 84 | |
| 85 | } // namespace Experimental |
| 86 | } // namespace Phonon |
| 87 | |
| 88 | #if defined(Q_CC_MSVC) && _MSC_VER <= 1300 |
| 89 | //this ensures that code outside Phonon can use the hash function |
| 90 | //it also a workaround for some compilers |
| 91 | inline uint qHash(const Phonon::Experimental::AudioFormat &p) { return Phonon::Experimental::qHash(p); } //krazy:exclude=inline |
| 92 | #endif |
| 93 | |
| 94 | |
| 95 | #endif // PHONON_X_AUDIOFORMAT_H |
| 96 | |