1
/* This file is part of the KDE project.
3
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
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.
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.
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/>.
18
#ifndef Phonon_QT7_BACKENDHEADER_H
19
#define Phonon_QT7_BACKENDHEADER_H
21
#include <QtCore/QString>
22
#import <Foundation/NSAutoreleasePool.h>
23
#include <CoreFoundation/CFBase.h>
26
#define QUICKTIME_C_API_AVAILABLE
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);
45
#define NORMAL_ERROR 1
48
#define ERROR_LOCATION \
49
QLatin1String("Function: ") + QLatin1String(__FUNCTION__) \
50
+ QLatin1String(", File: ") + QLatin1String(__FILE__) \
51
+ QLatin1String(", Line: ") + QString::number(__LINE__)
53
#define SET_ERROR(string, type){ \
54
Phonon::QT7::gSetErrorString(string); \
55
Phonon::QT7::gSetErrorType(type); \
56
Phonon::QT7::gSetErrorLocation(ERROR_LOCATION); }
58
#define BACKEND_ASSERT(test, string, type) \
61
SET_ERROR(QLatin1String(string), type) \
64
#define BACKEND_ASSERT2(test, string, type) \
66
SET_ERROR(QLatin1String(string), type) \
70
#define BACKEND_ASSERT3(test, string, type, ret) \
72
SET_ERROR(QLatin1String(string), type) \
76
#define ARGUMENT_UNSUPPORTED(a, x, type, ret) \
78
SET_ERROR("Argument value not supported: "#a" == "#x, type); \
82
#define CASE_UNSUPPORTED(string, type) SET_ERROR(string, type)
84
#ifdef SET_DEBUG_IMPLEMENTED
85
#define IMPLEMENTED qDebug() << "QT7:" << __FUNCTION__ << "(" << __FILE__ << "):"
87
#define IMPLEMENTED if (1); else qDebug()
90
#ifdef SET_DEBUG_HALF_IMPLEMENTED
91
#define HALF_IMPLEMENTED qDebug() << "QT7: --- HALF IMPLEMENTED:" << __FUNCTION__ << "(" << __FILE__ << "," << __LINE__ << "):"
93
#define HALF_IMPLEMENTED if (1); else qDebug()
96
#ifdef SET_DEBUG_NOT_IMPLEMENTED
97
#define NOT_IMPLEMENTED qDebug() << "QT7: *** NOT IMPLEMENTED:" << __FUNCTION__ << "(" << __FILE__ << "," << __LINE__ << "):"
99
#define NOT_IMPLEMENTED if (1); else qDebug()
102
#ifdef SET_DEBUG_IMPLEMENTED_SILENT
103
#define IMPLEMENTED_SILENT qDebug() << "QT7: (silent)" << __FUNCTION__ << "(" << __FILE__ << "," << __LINE__ << "):"
105
#define IMPLEMENTED_SILENT if (1); else qDebug()
108
#ifdef SET_DEBUG_AUDIO_GRAPH
109
#define DEBUG_AUDIO_GRAPH(x) qDebug() << "QT7 DEBUG GRAPH:" << x;
111
#define DEBUG_AUDIO_GRAPH(x) {}
114
#ifdef SET_DEBUG_AUDIO_STREAM
115
#define DEBUG_AUDIO_STREAM(x) qDebug() << "QT7 DEBUG STREAM:" << x;
117
#define DEBUG_AUDIO_STREAM(x) {}
120
/////////////////////////////////////////////////////////////////////////////////////////
122
class PhononAutoReleasePool
127
PhononAutoReleasePool();
128
~PhononAutoReleasePool();
131
/////////////////////////////////////////////////////////////////////////////////////////
133
template <typename T>
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)
144
CFRetain(helper.type);
145
CFTypeRef type2 = type;
151
inline T *operator&() { return &type; }
152
static PhononCFType constructFromGet(const T &t)
155
return PhononCFType<T>(t);
161
/////////////////////////////////////////////////////////////////////////////////////////
163
class PhononCFString : public PhononCFType<CFStringRef>
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);
176
}} //namespace Phonon::QT7
181
#pragma warning (disable : 1899) // mute icc warning for the use of 4cc
184
#endif // Phonon_QT7_BACKENDHEADER_H