| 1 |
/* This file is part of the KDE project. |
| 2 |
|
| 3 |
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 |
|
| 5 |
This library is free software: you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU Lesser General Public License as published by |
| 7 |
the Free Software Foundation, either version 2.1 or 3 of the License. |
| 8 |
|
| 9 |
This library is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU Lesser General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU Lesser General Public License |
| 15 |
along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#ifndef Phonon_QT7_BACKENDHEADER_H |
| 19 |
#define Phonon_QT7_BACKENDHEADER_H |
| 20 |
|
| 21 |
#include <QtCore/QString> |
| 22 |
#import <Foundation/NSAutoreleasePool.h> |
| 23 |
#include <CoreFoundation/CFBase.h> |
| 24 |
|
| 25 |
#ifndef Q_WS_MAC64 |
| 26 |
#define QUICKTIME_C_API_AVAILABLE |
| 27 |
#endif |
| 28 |
|
| 29 |
QT_BEGIN_NAMESPACE |
| 30 |
|
| 31 |
namespace Phonon |
| 32 |
{ |
| 33 |
namespace QT7 |
| 34 |
{ |
| 35 |
|
| 36 |
// Implemented in error.cpp: |
| 37 |
void gSetErrorString(const QString &errorString); |
| 38 |
QString gGetErrorString(); |
| 39 |
void gSetErrorLocation(const QString &errorLocation); |
| 40 |
void gSetErrorType(int type); |
| 41 |
int gGetErrorType(); |
| 42 |
void gClearError(); |
| 43 |
|
| 44 |
#define NO_ERROR 0 |
| 45 |
#define NORMAL_ERROR 1 |
| 46 |
#define FATAL_ERROR 2 |
| 47 |
|
| 48 |
#define ERROR_LOCATION \ |
| 49 |
QLatin1String("Function: ") + QLatin1String(__FUNCTION__) \ |
| 50 |
+ QLatin1String(", File: ") + QLatin1String(__FILE__) \ |
| 51 |
+ QLatin1String(", Line: ") + QString::number(__LINE__) |
| 52 |
|
| 53 |
#define SET_ERROR(string, type){ \ |
| 54 |
Phonon::QT7::gSetErrorString(string); \ |
| 55 |
Phonon::QT7::gSetErrorType(type); \ |
| 56 |
Phonon::QT7::gSetErrorLocation(ERROR_LOCATION); } |
| 57 |
|
| 58 |
#define BACKEND_ASSERT(test, string, type) \ |
| 59 |
bool fail = !test; \ |
| 60 |
if (fail) \ |
| 61 |
SET_ERROR(QLatin1String(string), type) \ |
| 62 |
if (fail) |
| 63 |
|
| 64 |
#define BACKEND_ASSERT2(test, string, type) \ |
| 65 |
if (!(test)) { \ |
| 66 |
SET_ERROR(QLatin1String(string), type) \ |
| 67 |
return; \ |
| 68 |
} |
| 69 |
|
| 70 |
#define BACKEND_ASSERT3(test, string, type, ret) \ |
| 71 |
if (!(test)) { \ |
| 72 |
SET_ERROR(QLatin1String(string), type) \ |
| 73 |
return ret; \ |
| 74 |
} |
| 75 |
|
| 76 |
#define ARGUMENT_UNSUPPORTED(a, x, type, ret) \ |
| 77 |
if ((a) == (x)) { \ |
| 78 |
SET_ERROR("Argument value not supported: "#a" == "#x, type); \ |
| 79 |
return ret; \ |
| 80 |
} |
| 81 |
|
| 82 |
#define CASE_UNSUPPORTED(string, type) SET_ERROR(string, type) |
| 83 |
|
| 84 |
#ifdef SET_DEBUG_IMPLEMENTED |
| 85 |
#define IMPLEMENTED qDebug() << "QT7:" << __FUNCTION__ << "(" << __FILE__ << "):" |
| 86 |
#else |
| 87 |
#define IMPLEMENTED if (1); else qDebug() |
| 88 |
#endif |
| 89 |
|
| 90 |
#ifdef SET_DEBUG_HALF_IMPLEMENTED |
| 91 |
#define HALF_IMPLEMENTED qDebug() << "QT7: --- HALF IMPLEMENTED:" << __FUNCTION__ << "(" << __FILE__ << "," << __LINE__ << "):" |
| 92 |
#else |
| 93 |
#define HALF_IMPLEMENTED if (1); else qDebug() |
| 94 |
#endif |
| 95 |
|
| 96 |
#ifdef SET_DEBUG_NOT_IMPLEMENTED |
| 97 |
#define NOT_IMPLEMENTED qDebug() << "QT7: *** NOT IMPLEMENTED:" << __FUNCTION__ << "(" << __FILE__ << "," << __LINE__ << "):" |
| 98 |
#else |
| 99 |
#define NOT_IMPLEMENTED if (1); else qDebug() |
| 100 |
#endif |
| 101 |
|
| 102 |
#ifdef SET_DEBUG_IMPLEMENTED_SILENT |
| 103 |
#define IMPLEMENTED_SILENT qDebug() << "QT7: (silent)" << __FUNCTION__ << "(" << __FILE__ << "," << __LINE__ << "):" |
| 104 |
#else |
| 105 |
#define IMPLEMENTED_SILENT if (1); else qDebug() |
| 106 |
#endif |
| 107 |
|
| 108 |
#ifdef SET_DEBUG_AUDIO_GRAPH |
| 109 |
#define DEBUG_AUDIO_GRAPH(x) qDebug() << "QT7 DEBUG GRAPH:" << x; |
| 110 |
#else |
| 111 |
#define DEBUG_AUDIO_GRAPH(x) {} |
| 112 |
#endif |
| 113 |
|
| 114 |
#ifdef SET_DEBUG_AUDIO_STREAM |
| 115 |
#define DEBUG_AUDIO_STREAM(x) qDebug() << "QT7 DEBUG STREAM:" << x; |
| 116 |
#else |
| 117 |
#define DEBUG_AUDIO_STREAM(x) {} |
| 118 |
#endif |
| 119 |
|
| 120 |
///////////////////////////////////////////////////////////////////////////////////////// |
| 121 |
|
| 122 |
class PhononAutoReleasePool |
| 123 |
{ |
| 124 |
private: |
| 125 |
void *pool; |
| 126 |
public: |
| 127 |
PhononAutoReleasePool(); |
| 128 |
~PhononAutoReleasePool(); |
| 129 |
}; |
| 130 |
|
| 131 |
///////////////////////////////////////////////////////////////////////////////////////// |
| 132 |
|
| 133 |
template <typename T> |
| 134 |
class PhononCFType |
| 135 |
{ |
| 136 |
public: |
| 137 |
inline PhononCFType(const T &t = 0) : type(t) {} |
| 138 |
inline PhononCFType(const PhononCFType &helper) : type(helper.type) { if (type) CFRetain(type); } |
| 139 |
inline ~PhononCFType() { if (type) CFRelease(type); } |
| 140 |
inline operator T() { return type; } |
| 141 |
inline PhononCFType operator =(const PhononCFType &helper) |
| 142 |
{ |
| 143 |
if (helper.type) |
| 144 |
CFRetain(helper.type); |
| 145 |
CFTypeRef type2 = type; |
| 146 |
type = helper.type; |
| 147 |
if (type2) |
| 148 |
CFRelease(type2); |
| 149 |
return *this; |
| 150 |
} |
| 151 |
inline T *operator&() { return &type; } |
| 152 |
static PhononCFType constructFromGet(const T &t) |
| 153 |
{ |
| 154 |
CFRetain(t); |
| 155 |
return PhononCFType<T>(t); |
| 156 |
} |
| 157 |
protected: |
| 158 |
T type; |
| 159 |
}; |
| 160 |
|
| 161 |
///////////////////////////////////////////////////////////////////////////////////////// |
| 162 |
|
| 163 |
class PhononCFString : public PhononCFType<CFStringRef> |
| 164 |
{ |
| 165 |
public: |
| 166 |
inline PhononCFString(const QString &str) : PhononCFType<CFStringRef>(0), string(str) {} |
| 167 |
inline PhononCFString(const CFStringRef cfstr = 0) : PhononCFType<CFStringRef>(cfstr) {} |
| 168 |
inline PhononCFString(const PhononCFType<CFStringRef> &other) : PhononCFType<CFStringRef>(other) {} |
| 169 |
operator QString() const; |
| 170 |
operator CFStringRef() const; |
| 171 |
static QString toQString(CFStringRef cfstr); |
| 172 |
static CFStringRef toCFStringRef(const QString &str); |
| 173 |
private: |
| 174 |
QString string; |
| 175 |
}; |
| 176 |
}} //namespace Phonon::QT7 |
| 177 |
|
| 178 |
QT_END_NAMESPACE |
| 179 |
|
| 180 |
#ifdef Q_CC_INTEL |
| 181 |
#pragma warning (disable : 1899) // mute icc warning for the use of 4cc |
| 182 |
#endif |
| 183 |
|
| 184 |
#endif // Phonon_QT7_BACKENDHEADER_H |