source: trunk/src/3rdparty/phonon/mmf/utils.h

Last change on this file was 651, checked in by Dmitry A. Kuminov, 16 years ago

trunk: Merged in qt 4.6.2 sources.

  • Property svn:eol-style set to native
File size: 5.4 KB
Line 
1/* This file is part of the KDE project.
2
3Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5This library is free software: you can redistribute it and/or modify
6it under the terms of the GNU Lesser General Public License as published by
7the Free Software Foundation, either version 2.1 or 3 of the License.
8
9This library is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU Lesser General Public License for more details.
13
14You should have received a copy of the GNU Lesser General Public License
15along with this library. If not, see <http://www.gnu.org/licenses/>.
16
17*/
18
19#ifndef PHONON_MMF_UTILS_H
20#define PHONON_MMF_UTILS_H
21
22#include <private/qcore_symbian_p.h>
23#include <e32debug.h> // for RDebug
24#include <QtCore/QCoreApplication> // for Q_DECLARE_TR_FUNCTIONS
25#include <QColor>
26
27#include "defs.h"
28
29QT_BEGIN_NAMESPACE
30
31namespace Phonon
32{
33namespace MMF
34{
35/**
36 * Panic codes for fatal errors
37 */
38enum PanicCode {
39 InvalidStatePanic = 1,
40 InvalidMediaTypePanic = 2,
41 InvalidBackendInterfaceClass = 3,
42 AudioUtilityUrlNotSupported = 4
43};
44
45class Utils
46{
47 Q_DECLARE_TR_FUNCTIONS(Phonon::MMF)
48
49public:
50/**
51 * Raise a fatal exception
52 */
53static void panic(PanicCode code);
54
55/**
56 * Determines whether the provided MIME type is an audio or video
57 * type. If it is neither, the function returns MediaTypeUnknown.
58 */
59static MediaType mimeTypeToMediaType(const TDesC& mimeType);
60
61/**
62 * Translates a Symbian error code into a user-readable string.
63 */
64static QString symbianErrorToString(int errorCode);
65
66#ifndef QT_NO_DEBUG
67/**
68 * Retrieve color of specified pixel from the screen.
69 */
70static QColor getScreenPixel(const QPoint& pos);
71
72/**
73 * Samples a small number of pixels from the screen, and dumps their
74 * colors to the debug log.
75 */
76static void dumpScreenPixelSample();
77#endif
78};
79
80/**
81 * Available trace categories;
82 */
83enum TTraceCategory {
84 /**
85 * Backend
86 */
87 EBackend = 0x00000001,
88
89 /**
90 * Functions which map directly to the public Phonon audio API
91 */
92 EAudioApi = 0x00000010,
93
94 /**
95 * Internal functions in the audio implementation
96 */
97 EAudioInternal = 0x00000020,
98
99 /**
100 * Functions which map directly to the public Phonon video API
101 */
102 EVideoApi = 0x00010000,
103
104 /**
105 * Internal functions in the video implementation
106 */
107 EVideoInternal = 0x00020000
108};
109
110/**
111 * Mask indicating which trace categories are enabled
112 *
113 * Note that, at the moment, this is a compiled static constant. For
114 * runtime control over enabled trace categories, this could be replaced
115 * by a per-thread singleton object which owns the trace mask, and which
116 * exposes an API allowing it to be modified.
117 */
118static const TUint KTraceMask = 0xffffffff;
119
120/**
121 * Data structure used by tracing macros
122 */
123class TTraceContext
124{
125public:
126 TTraceContext(const TText* aFunction, const TUint aAddr,
127 const TUint aCategory = 0)
128 : iFunction(aFunction),
129 iAddr(aAddr),
130 iCategory(aCategory) { }
131
132 /**
133 * Check whether iCategory appears in the trace mask
134 */
135 TBool Enabled() const {
136 return (iCategory == 0) or(iCategory & KTraceMask);
137 }
138
139 const TText* iFunction; // Name of function
140 const TUint iAddr; // 'this' pointer
141 const TUint iCategory;
142};
143
144// Macros used internally by the trace system
145#define _TRACE_PRINT RDebug::Print
146#define _TRACE_TEXT(x) (TPtrC((const TText *)(x)))
147#define _TRACE_MODULE Phonon::MMF
148
149// Macros available for use by implementation code
150#ifndef QT_NO_DEBUG
151#define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat);
152#define TRACE_ENTRY_0() { if (_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); }
153#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); }
154#define TRACE_EXIT_0() { if (_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); }
155#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); }
156#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;
157#define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code);
158#define TRACE_0(string) { if (_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr); }
159#define TRACE(string, args...) { if (_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## " Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); }
160#else
161#define TRACE_CONTEXT(_fn, _cat)
162#define TRACE_ENTRY_0()
163#define TRACE_ENTRY(string, args...)
164#define TRACE_EXIT_0()
165#define TRACE_EXIT(string, args...)
166#define TRACE_RETURN(string, result) return result;
167#define TRACE_PANIC(code) Utils::panic(code);
168#define TRACE_0(string)
169#define TRACE(string, args...)
170#endif
171}
172}
173
174QT_END_NAMESPACE
175
176#endif
Note: See TracBrowser for help on using the repository browser.