diff options
Diffstat (limited to 'src/3rdparty/phonon/mmf/utils.h')
-rw-r--r-- | src/3rdparty/phonon/mmf/utils.h | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/src/3rdparty/phonon/mmf/utils.h b/src/3rdparty/phonon/mmf/utils.h new file mode 100644 index 0000000..4b967fc --- /dev/null +++ b/src/3rdparty/phonon/mmf/utils.h @@ -0,0 +1,134 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#ifndef PHONON_MMF_UTILS_H +#define PHONON_MMF_UTILS_H + +#include <private/qcore_symbian_p.h> + +namespace Phonon +{ + namespace MMF + { + /** + * Panic codes for fatal errors + */ + enum PanicCode + { + InvalidStatePanic, + InvalidMediaTypePanic + }; + + namespace Utils + { + /** + * Raise a fatal exception + */ + void panic(PanicCode code); + + /** + * Translate forward slashes to backslashes + * + * \note This function is a temporary measure, for use until the + * responsibility for constructing valid file paths is + * determined. + */ + QHBufC symbianFilename(const QString& qtFilename); + } + + /** + * Available trace categories; + */ + enum TTraceCategory + { + /** + * Functions which map directly to the public Phonon audio API + */ + EAudioApi = 0x00000001, + + /** + * Internal functions in the audio implementation + */ + EAudioInternal = 0x00000002 + }; + + /** + * Mask indicating which trace categories are enabled + * + * Note that, at the moment, this is a compiled static constant. For + * runtime control over enabled trace categories, this could be replaced + * by a per-thread singleton object which owns the trace mask, and which + * exposes an API allowing it to be modified. + */ + static const TUint KTraceMask = 0xffffffff; + + /** + * Data structure used by tracing macros + */ + class TTraceContext + { + public: + TTraceContext(const TText* aFunction, const TUint aAddr, + const TUint aCategory=0) + : iFunction(aFunction), + iAddr(aAddr), + iCategory(aCategory) + { } + + /** + * Check whether iCategory appears in the trace mask + */ + TBool Enabled() const + { + return (iCategory == 0) or (iCategory & KTraceMask); + } + + const TText* iFunction; // Name of function + const TUint iAddr; // 'this' pointer + const TUint iCategory; + }; + + // Macros used internally by the trace system + #define _TRACE_PRINT RDebug::Print + #define _TRACE_TEXT(x) (TPtrC((const TText *)(x))) + #define _TRACE_MODULE Phonon::MMF + + // Macros available for use by implementation code +#ifdef _DEBUG + #define TRACE_CONTEXT(_fn, _cat) const ::Phonon::MMF::TTraceContext _tc((TText*)L ## #_fn, (TUint)this, _cat); + #define TRACE_ENTRY_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "+ Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } + #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); } + #define TRACE_EXIT_0() { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "- Phonon::MMF::%s [0x%08x]"), _tc.iFunction, _tc.iAddr); } + #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); } + #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; + #define TRACE_PANIC(code) { _TRACE_PRINT(_TRACE_TEXT(L ## "! Phonon::MMF::%s [0x%08x] panic %d"), _tc.iFunction, _tc.iAddr, code); } Utils::panic(code); + #define TRACE(string, args...) { if(_tc.Enabled()) _TRACE_PRINT(_TRACE_TEXT(L ## "Phonon::MMF::%s [0x%08x] " L ## string), _tc.iFunction, _tc.iAddr, args); } +#else + #define TRACE_CONTEXT(_fn, _cat) + #define TRACE_ENTRY_0() + #define TRACE_ENTRY(string, args...) + #define TRACE_EXIT_0() + #define TRACE_EXIT(string, args...) + #define TRACE_RETURN(string, result) return result; + #define TRACE_PANIC(code) Utils::panic(code); + #define TRACE(string, args...) +#endif + } +} + +#endif |