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 #ifndef PHONON_X_AUDIOFORMAT_H
0024 #define PHONON_X_AUDIOFORMAT_H
0025 
0026 #include <QtGlobal>
0027 #include "phononnamespace.h"
0028 
0029 namespace Phonon
0030 {
0031 namespace Experimental
0032 {
0033 
0034 class AudioFormatPrivate;
0035 class AudioFormat
0036 {
0037     //Q_DECLARE_PRIVATE(AudioFormat)
0038     public:
0039         AudioFormat(int sampleRate = 48000, int channelCount = 2, Phonon::Experimental::BitRate bitRate = Phonon::Experimental::Signed16Bit, QSysInfo::Endian byteOrder = QSysInfo::ByteOrder);
0040         AudioFormat(const AudioFormat &);
0041         ~AudioFormat();
0042 
0043         AudioFormat &operator=(const AudioFormat &);
0044 
0045         int sampleRate() const;
0046         int channelCount() const;
0047         Phonon::Experimental::BitRate bitRate() const;
0048         QSysInfo::Endian byteOrder() const;
0049 
0050         bool operator==(const AudioFormat &) const;
0051         inline bool operator!=(const AudioFormat &f) const { return !operator==(f); }
0052 
0053         /**
0054          * ess than operator for sorting:
0055          * A Format is considered smaller if
0056          * - smaller bit rate
0057          * - smaller sample rate
0058          * - less channels
0059          * - non-native byte order
0060          */
0061         bool operator<(const AudioFormat &) const;
0062 
0063         quint32 key() const;
0064 
0065     private:
0066         union
0067         {
0068             struct
0069             {
0070                 int m_sampleRate;
0071                 int m_channelCount;
0072                 Phonon::Experimental::BitRate m_bitRate;
0073                 QSysInfo::Endian m_byteOrder;
0074             } s;
0075             // for future use:
0076             AudioFormatPrivate *d_ptr;
0077         };
0078 };
0079 
0080 inline uint qHash(const AudioFormat &p)
0081 {
0082     return p.key();
0083 }
0084 
0085 } // namespace Experimental
0086 } // namespace Phonon
0087 
0088 #if defined(Q_CC_MSVC) && _MSC_VER <= 1300
0089 //this ensures that code outside Phonon can use the hash function
0090 //it also a workaround for some compilers
0091 inline uint qHash(const Phonon::Experimental::AudioFormat &p) { return Phonon::Experimental::qHash(p); } //krazy:exclude=inline
0092 #endif
0093 
0094 
0095 #endif // PHONON_X_AUDIOFORMAT_H