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/>.
19
#ifndef PHONON_MMF_UTILS_H
20
#define PHONON_MMF_UTILS_H
22
#include <private/qcore_symbian_p.h>
23
#include <e32debug.h> // for RDebug
36
* Panic codes for fatal errors
39
InvalidStatePanic = 1,
40
InvalidMediaTypePanic = 2,
41
InvalidBackendInterfaceClass = 3
47
* Raise a fatal exception
49
void panic(PanicCode code);
52
* Determines whether the provided MIME type is an audio or video
53
* type. If it is neither, the function returns MediaTypeUnknown.
55
MediaType mimeTypeToMediaType(const TDesC& mimeType);
59
* Retrieve color of specified pixel from the screen.
61
QColor getScreenPixel(const QPoint& pos);
64
* Samples a small number of pixels from the screen, and dumps their
65
* colors to the debug log.
67
void dumpScreenPixelSample();
72
* Available trace categories;
78
EBackend = 0x00000001,
81
* Functions which map directly to the public Phonon audio API
83
EAudioApi = 0x00000010,
86
* Internal functions in the audio implementation
88
EAudioInternal = 0x00000020,
91
* Functions which map directly to the public Phonon video API
93
EVideoApi = 0x00010000,
96
* Internal functions in the video implementation
98
EVideoInternal = 0x00020000
102
* Mask indicating which trace categories are enabled
104
* Note that, at the moment, this is a compiled static constant. For
105
* runtime control over enabled trace categories, this could be replaced
106
* by a per-thread singleton object which owns the trace mask, and which
107
* exposes an API allowing it to be modified.
109
static const TUint KTraceMask = 0xffffffff;
112
* Data structure used by tracing macros
117
TTraceContext(const TText* aFunction, const TUint aAddr,
118
const TUint aCategory = 0)
119
: iFunction(aFunction),
121
iCategory(aCategory) { }
124
* Check whether iCategory appears in the trace mask
126
TBool Enabled() const {
127
return (iCategory == 0) or(iCategory & KTraceMask);
130
const TText* iFunction; // Name of function
131
const TUint iAddr; // 'this' pointer
132
const TUint iCategory;
135
// Macros used internally by the trace system
136
#define _TRACE_PRINT RDebug::Print
137
#define _TRACE_TEXT(x) (TPtrC((const TText *)(x)))
138
#define _TRACE_MODULE Phonon::MMF
140
// Macros available for use by implementation code
142
#define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat);
143
#define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); }
144
#define TRACE_ENTRY(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); }
145
#define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); }
146
#define TRACE_EXIT(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); }
147
#define TRACE_RETURN(string, result) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "r Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, result); } return result;
148
#define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code);
149
#define TRACE_0(string) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); }
150
#define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); }
152
#define TRACE_CONTEXT(_fn, _cat)
153
#define TRACE_ENTRY_0()
154
#define TRACE_ENTRY(string, args...)
155
#define TRACE_EXIT_0()
156
#define TRACE_EXIT(string, args...)
157
#define TRACE_RETURN(string, result) return result;
158
#define TRACE_PANIC(code) Utils::panic(code);
159
#define TRACE_0(string)
160
#define TRACE(string, args...)