diff --git a/examples/player/main.cpp b/examples/player/main.cpp index b406f98b..d5b29d6c 100644 --- a/examples/player/main.cpp +++ b/examples/player/main.cpp @@ -75,6 +75,8 @@ void Logger(QtMsgType type, const QMessageLogContext &, const QString& qmsg) int main(int argc, char *argv[]) { + // has no effect if qInstallMessageHandler() called + //qSetMessagePattern("%{function} @%{line}: %{message}"); QApplication a(argc, argv); if (a.arguments().contains("-h") || a.arguments().contains("--help")) { qDebug("Usage: %s [-vo qt/gl/d2d/gdi] [url/path]filename", a.applicationFilePath().section(QDir::separator(), -1).toUtf8().constData()); @@ -184,10 +186,9 @@ int main(int argc, char *argv[]) if (!vd.isEmpty()) window.setVideoDecoderNames(vd); - idx = a.arguments().indexOf("--no-ffmpeg-log"); idxmax = qMax(idx, idxmax); - if (idx < 0) + if (idx > 0) setFFmpegLogHandler(0); bool opt_has_file = argc > idxmax+1; if (opt_has_file) { diff --git a/qml/QmlAV/QQuickItemRenderer.h b/qml/QmlAV/QQuickItemRenderer.h index 19811a9f..88628cf0 100644 --- a/qml/QmlAV/QQuickItemRenderer.h +++ b/qml/QmlAV/QQuickItemRenderer.h @@ -27,8 +27,7 @@ #include #include -namespace QtAV -{ +namespace QtAV { extern QMLAV_EXPORT VideoRendererId VideoRendererId_QQuickItem; class QQuickItemRendererPrivate; @@ -85,5 +84,6 @@ private: }; typedef QQuickItemRenderer VideoRendererQQuickItem; } +QML_DECLARE_TYPE(QtAV::QQuickItemRenderer) #endif // QTAV_QML_QQUICKRENDERER_H diff --git a/src/AVClock.cpp b/src/AVClock.cpp index b54273e4..f97da911 100644 --- a/src/AVClock.cpp +++ b/src/AVClock.cpp @@ -22,6 +22,7 @@ #include #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/AVCompat.cpp b/src/AVCompat.cpp index 47bd4180..c8e5dd46 100644 --- a/src/AVCompat.cpp +++ b/src/AVCompat.cpp @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ******************************************************************************/ -#include +#include "QtAV/private/AVCompat.h" #include "QtAV/version.h" #include "QtAV/prepost.h" @@ -68,7 +68,7 @@ void ffmpeg_version_print() fflush(0); } -PRE_FUNC_ADD(ffmpeg_version_print); +//PRE_FUNC_ADD(ffmpeg_version_print); //move to Internal::Logger #ifndef av_err2str diff --git a/src/AVDemuxThread.cpp b/src/AVDemuxThread.cpp index b48326a6..0f4bb77d 100644 --- a/src/AVDemuxThread.cpp +++ b/src/AVDemuxThread.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/AVDemuxer.cpp b/src/AVDemuxer.cpp index 629ca90a..ec66aed7 100644 --- a/src/AVDemuxer.cpp +++ b/src/AVDemuxer.cpp @@ -27,6 +27,7 @@ #include "QtAV/Packet.h" #include "QAVIOContext.h" #include "QtAV/private/AVCompat.h" +#include "utils/Logger.h" namespace QtAV { @@ -165,7 +166,7 @@ AVDemuxer::AVDemuxer(const QString& fileName, QObject *parent) class AVInitializer { public: AVInitializer() { - qDebug("av_register_all, avcodec_register_all, avformat_network_init"); + //qDebug("av_register_all, avcodec_register_all, avformat_network_init"); avcodec_register_all(); #if QTAV_HAVE(AVDEVICE) avdevice_register_all(); diff --git a/src/AVPlayer.cpp b/src/AVPlayer.cpp index 8bc18062..fded4f30 100644 --- a/src/AVPlayer.cpp +++ b/src/AVPlayer.cpp @@ -48,6 +48,7 @@ #include "output/OutputSet.h" #include "output/video/VideoOutputEventFilter.h" #include "QtAV/private/AVCompat.h" +#include "utils/Logger.h" namespace QtAV { @@ -103,7 +104,6 @@ AVPlayer::AVPlayer(QObject *parent) : mpVOSet = new OutputSet(this); mpAOSet = new OutputSet(this); - qDebug("%s", aboutQtAV_PlainText().toUtf8().constData()); /* * call stop() before the window(_renderer) closed to stop the waitcondition * If close the _renderer widget, the the _renderer may destroy before waking up. diff --git a/src/AVThread.cpp b/src/AVThread.cpp index 10499654..a94e65de 100644 --- a/src/AVThread.cpp +++ b/src/AVThread.cpp @@ -24,6 +24,7 @@ #include "QtAV/AVOutput.h" #include "QtAV/Filter.h" #include "output/OutputSet.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/AudioFormat.cpp b/src/AudioFormat.cpp index bd51e61c..3fee28fd 100644 --- a/src/AudioFormat.cpp +++ b/src/AudioFormat.cpp @@ -20,9 +20,10 @@ ******************************************************************************/ #include "QtAV/AudioFormat.h" -#include #include "QtAV/private/AVCompat.h" - +#ifndef QT_NO_DEBUG_STREAM +#include +#endif //QT_NO_DEBUG_STREAM //FF_API_OLD_SAMPLE_FMT. e.g. FFmpeg 0.9 #ifdef SampleFormat #undef SampleFormat diff --git a/src/AudioResamplerFF.cpp b/src/AudioResamplerFF.cpp index 232bc266..5ef1ea7f 100644 --- a/src/AudioResamplerFF.cpp +++ b/src/AudioResamplerFF.cpp @@ -24,6 +24,7 @@ #include "QtAV/private/AudioResampler_p.h" #include "QtAV/private/AVCompat.h" #include "QtAV/prepost.h" +#include "utils/Logger.h" namespace QtAV { @@ -223,6 +224,7 @@ bool AudioResamplerFF::prepare() int ret = swr_init(d.context); if (ret < 0) { qWarning("swr_init failed: %s", av_err2str(ret)); + swr_free(&d.context); return false; } return true; diff --git a/src/AudioResamplerLibav.cpp b/src/AudioResamplerLibav.cpp index 332907ee..bb15421a 100644 --- a/src/AudioResamplerLibav.cpp +++ b/src/AudioResamplerLibav.cpp @@ -25,6 +25,7 @@ #include "QtAV/private/AudioResampler_p.h" #include "QtAV/private/AVCompat.h" #include "QtAV/prepost.h" +#include "utils/Logger.h" namespace QtAV { @@ -257,6 +258,7 @@ bool AudioResamplerLibav::prepare() int ret = swr_init(d.context); if (ret < 0) { qWarning("swr_init failed: %s", av_err2str(ret)); + swr_free(&d.context); return false; } return true; diff --git a/src/AudioThread.cpp b/src/AudioThread.cpp index 1fb2a0df..a121f388 100644 --- a/src/AudioThread.cpp +++ b/src/AudioThread.cpp @@ -30,6 +30,7 @@ #include "output/OutputSet.h" #include "QtAV/private/AVCompat.h" #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/Frame.cpp b/src/Frame.cpp index 11a37cf5..5fa5ba1b 100644 --- a/src/Frame.cpp +++ b/src/Frame.cpp @@ -21,6 +21,7 @@ #include "QtAV/Frame.h" #include "QtAV/private/Frame_p.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/ImageConverterFF.cpp b/src/ImageConverterFF.cpp index 222f874f..e72f5b17 100644 --- a/src/ImageConverterFF.cpp +++ b/src/ImageConverterFF.cpp @@ -24,6 +24,7 @@ #include "QtAV/private/AVCompat.h" #include "QtAV/private/mkid.h" #include "QtAV/prepost.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/ImageConverterIPP.cpp b/src/ImageConverterIPP.cpp index ef8288ce..5d5f8aa7 100644 --- a/src/ImageConverterIPP.cpp +++ b/src/ImageConverterIPP.cpp @@ -30,6 +30,7 @@ #else #endif +#include "utils/Logger.h" namespace QtAV { diff --git a/src/OpenGLVideo.cpp b/src/OpenGLVideo.cpp index d14cc187..b9337833 100644 --- a/src/OpenGLVideo.cpp +++ b/src/OpenGLVideo.cpp @@ -34,6 +34,7 @@ #include "QtAV/SurfaceInterop.h" #include "QtAV/VideoShader.h" #include "ShaderManager.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/Packet.cpp b/src/Packet.cpp index 97118075..05dc1b08 100644 --- a/src/Packet.cpp +++ b/src/Packet.cpp @@ -20,6 +20,7 @@ ******************************************************************************/ #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/QAVIOContext.cpp b/src/QAVIOContext.cpp index 42033961..d3b7556d 100644 --- a/src/QAVIOContext.cpp +++ b/src/QAVIOContext.cpp @@ -23,6 +23,7 @@ #include "QAVIOContext.h" #include "QtAV/private/AVCompat.h" #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/QtAV/AVClock.h b/src/QtAV/AVClock.h index cf63e412..aedd3d2d 100644 --- a/src/QtAV/AVClock.h +++ b/src/QtAV/AVClock.h @@ -136,7 +136,7 @@ double AVClock::value() const if (timer.isValid()) { pts_ += double(timer.restart()) * kThousandth; } else {//timer is paused - qDebug("clock is paused. return the last value %f", pts_); + //qDebug("clock is paused. return the last value %f", pts_); } return pts_ * speed() + value0; } diff --git a/src/QtAV/QtAV_Global.h b/src/QtAV/QtAV_Global.h index 8c51563a..dd5b671b 100644 --- a/src/QtAV/QtAV_Global.h +++ b/src/QtAV/QtAV_Global.h @@ -44,12 +44,11 @@ Q_AV_EXPORT QString QtAV_Version_String_Long(); namespace QtAV { enum LogLevel { - LogOff = -1, - LogDefault = 0, - LogDebug, - LogWarning, - LogCritical, - LogFatal, + LogOff, + LogDebug, // log all + LogWarning, // log warning, critical, fatal + LogCritical, // log critical, fatal + LogFatal, // log fatal LogAll }; @@ -61,6 +60,11 @@ Q_AV_EXPORT void aboutQtAV(); Q_AV_EXPORT QString aboutQtAV_PlainText(); Q_AV_EXPORT QString aboutQtAV_HTML(); +/*! + * The level can also be changed at runtime by setting the QTAV_LOG_LEVEL environment variable; + * QTAV_LOG_LEVEL can be: off, debug, warning, critical, fatal, all. Or use their enum values + * if both setLogLevel() is called and QTAV_LOG_LEVEL is set, the environment variable takes preceden. +*/ Q_AV_EXPORT void setLogLevel(LogLevel value); Q_AV_EXPORT LogLevel logLevel(); @@ -104,10 +108,5 @@ Q_AV_EXPORT void setFFmpegLogHandler(void(*)(void *, int, const char *, va_list) #define Q_FUNC_INFO __FUNCTION__ #endif -#if defined(BUILD_QTAV_LIB) -#include "utils/Logger.h" -//#undef qDebug() -#endif //BUILD_QTAV_LIB - #endif // QTAV_GLOBAL_H diff --git a/src/QtAV/Statistics.h b/src/QtAV/Statistics.h index f20e5e25..df152aba 100644 --- a/src/QtAV/Statistics.h +++ b/src/QtAV/Statistics.h @@ -116,6 +116,7 @@ public: qreal pts() const; // last pts // compute from pts history qreal currentDisplayFPS() const; + //http://ffmpeg.org/faq.html#AVStream_002er_005fframe_005frate-is-wrong_002c-it-is-much-larger-than-the-frame-rate_002e //AVStream.avg_frame_rate may be 0, then use AVStream.r_frame_rate //http://libav-users.943685.n4.nabble.com/Libav-user-Reading-correct-frame-rate-fps-of-input-video-td4657666.html qreal fps_guess; diff --git a/src/QtAV_Global.cpp b/src/QtAV_Global.cpp index 5c393d9f..ca5cb003 100644 --- a/src/QtAV_Global.cpp +++ b/src/QtAV_Global.cpp @@ -22,7 +22,6 @@ #include "QtAV/QtAV_Global.h" #include #include -#include #if QTAV_HAVE(WIDGETS) #include #include @@ -32,13 +31,7 @@ #endif //QTAV_HAVE(WIDGETS) #include "QtAV/version.h" #include "QtAV/private/AVCompat.h" - -// disable logging for release. you can manually enable it. -#ifdef QT_NO_DEBUG -static QtAV::LogLevel gLogLevel = QtAV::LogOff; -#else -static QtAV::LogLevel gLogLevel = QtAV::LogAll; -#endif +#include "utils/Logger.h" unsigned QtAV_Version() { @@ -57,6 +50,17 @@ QString QtAV_Version_String_Long() namespace QtAV { +namespace Internal { +// disable logging for release. you can manually enable it. +#ifdef QT_NO_DEBUG +static QtAV::LogLevel gLogLevel = QtAV::LogOff; +#else +static QtAV::LogLevel gLogLevel = QtAV::LogAll; +#endif +static bool gLogLevelSet = false; +bool isLogLevelSet() { return gLogLevelSet;} +} //namespace Internal + //TODO: auto add new depend libraries information void about() { @@ -183,12 +187,13 @@ QString aboutQtAV_HTML() void setLogLevel(LogLevel value) { - gLogLevel = value; + Internal::gLogLevelSet = true; + Internal::gLogLevel = value; } LogLevel logLevel() { - return (LogLevel)gLogLevel; + return (LogLevel)Internal::gLogLevel; } void setFFmpegLogHandler(void (*callback)(void *, int, const char *, va_list)) @@ -203,19 +208,14 @@ static void qtav_ffmpeg_log_callback(void* , int level,const char* fmt, va_list { QString qmsg = "{FFmpeg} " + QString().vsprintf(fmt, vl); qmsg = qmsg.trimmed(); - QtMsgType mt = QtDebugMsg; if (level == AV_LOG_WARNING || level == AV_LOG_ERROR) - mt = QtWarningMsg; + qWarning() << qmsg; else if (level == AV_LOG_FATAL) - mt = QtCriticalMsg; + qFatal("%s", qmsg.toUtf8().constData()); else if (level == AV_LOG_PANIC) - mt = QtFatalMsg; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - QMessageLogContext ctx; - qt_message_output(mt, ctx, qmsg); -#else - qt_message_output(mt, qPrintable(qmsg)); -#endif //QT_VERSION + qFatal("%s", qmsg.toUtf8().constData()); + else + qDebug() << qmsg; } // TODO: static link. move all into 1 diff --git a/src/VideoCapture.cpp b/src/VideoCapture.cpp index 30bb6ed9..2c0b1c74 100644 --- a/src/VideoCapture.cpp +++ b/src/VideoCapture.cpp @@ -28,6 +28,7 @@ #include #include #include +#include "utils/Logger.h" #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #include diff --git a/src/VideoFormat.cpp b/src/VideoFormat.cpp index fbc5077a..3839d425 100644 --- a/src/VideoFormat.cpp +++ b/src/VideoFormat.cpp @@ -20,9 +20,10 @@ ******************************************************************************/ #include "QtAV/VideoFormat.h" -#include #include - +#ifndef QT_NO_DEBUG_STREAM +#include +#endif #include "QtAV/private/AVCompat.h" extern "C" { #include diff --git a/src/VideoShader.cpp b/src/VideoShader.cpp index aca777e6..dd9494ac 100644 --- a/src/VideoShader.cpp +++ b/src/VideoShader.cpp @@ -26,6 +26,7 @@ #include #include #include +#include "utils/Logger.h" /* * TODO: glActiveTexture for Qt4 diff --git a/src/VideoThread.cpp b/src/VideoThread.cpp index c42c85fa..e43f6828 100644 --- a/src/VideoThread.cpp +++ b/src/VideoThread.cpp @@ -34,6 +34,7 @@ #include "output/OutputSet.h" #include "QtAV/private/AVCompat.h" #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/codec/AVDecoder.cpp b/src/codec/AVDecoder.cpp index 32d69700..c31ae9ca 100644 --- a/src/codec/AVDecoder.cpp +++ b/src/codec/AVDecoder.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include "utils/Logger.h" namespace QtAV { AVDecoder::AVDecoder() diff --git a/src/codec/audio/AudioDecoder.cpp b/src/codec/audio/AudioDecoder.cpp index 6496b741..f3be58b7 100644 --- a/src/codec/audio/AudioDecoder.cpp +++ b/src/codec/audio/AudioDecoder.cpp @@ -24,6 +24,7 @@ #include "QtAV/private/AVCompat.h" #include "QtAV/AudioResampler.h" #include "QtAV/AudioResamplerTypes.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/codec/video/VideoDecoder.cpp b/src/codec/video/VideoDecoder.cpp index 29102986..5029451f 100644 --- a/src/codec/video/VideoDecoder.cpp +++ b/src/codec/video/VideoDecoder.cpp @@ -23,6 +23,7 @@ #include #include #include "QtAV/private/factory.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/codec/video/VideoDecoderCUDA.cpp b/src/codec/video/VideoDecoderCUDA.cpp index 9ecf2705..4dca23c3 100644 --- a/src/codec/video/VideoDecoderCUDA.cpp +++ b/src/codec/video/VideoDecoderCUDA.cpp @@ -41,6 +41,7 @@ #include "cuda/helper_cuda.h" #include "cuda/cuda_api.h" +#include "utils/Logger.h" //decode error if not floating context @@ -554,7 +555,9 @@ bool VideoDecoderCUDAPrivate::createCUVIDParser() { cudaVideoCodec cudaCodec = mapCodecFromFFmpeg(codec_ctx->codec_id); if (cudaCodec == -1) { - qWarning("CUVID does not support the codec"); + QString es(QObject::tr("Codec %1 is not supported by CUDA").arg(avcodec_get_name(codec_ctx->codec_id))); + //emit error(AVError::CodecError, es); + qWarning() << es; available = false; return false; } diff --git a/src/codec/video/VideoDecoderCedarv.cpp b/src/codec/video/VideoDecoderCedarv.cpp index 9138def3..7c57c981 100644 --- a/src/codec/video/VideoDecoderCedarv.cpp +++ b/src/codec/video/VideoDecoderCedarv.cpp @@ -24,14 +24,12 @@ #include "QtAV/Packet.h" #include "QtAV/private/AVCompat.h" #include "QtAV/prepost.h" - -#include - #include extern "C" { #include } +#include "utils/Logger.h" #ifdef NO_NEON_OPT //Don't HAVE_NEON static void map32x32_to_yuv_Y(unsigned char* srcY, unsigned char* tarY, unsigned int coded_width, unsigned int coded_height) diff --git a/src/codec/video/VideoDecoderDXVA.cpp b/src/codec/video/VideoDecoderDXVA.cpp index 0d53c762..da83b649 100644 --- a/src/codec/video/VideoDecoderDXVA.cpp +++ b/src/codec/video/VideoDecoderDXVA.cpp @@ -26,6 +26,7 @@ #include "QtAV/private/AVCompat.h" #include "QtAV/prepost.h" #include "utils/GPUMemCopy.h" +#include "utils/Logger.h" // TODO: add to QtAV_Compat.h? // FF_API_PIX_FMT diff --git a/src/codec/video/VideoDecoderFFmpeg.cpp b/src/codec/video/VideoDecoderFFmpeg.cpp index 59fd4d8a..0ab84cac 100644 --- a/src/codec/video/VideoDecoderFFmpeg.cpp +++ b/src/codec/video/VideoDecoderFFmpeg.cpp @@ -24,6 +24,7 @@ #include "QtAV/Packet.h" #include "QtAV/private/AVCompat.h" #include "QtAV/prepost.h" +#include "utils/Logger.h" /*! * options (properties) are from libavcodec/options_table.h diff --git a/src/codec/video/VideoDecoderFFmpegHW.cpp b/src/codec/video/VideoDecoderFFmpegHW.cpp index a517a382..cd924335 100644 --- a/src/codec/video/VideoDecoderFFmpegHW.cpp +++ b/src/codec/video/VideoDecoderFFmpegHW.cpp @@ -21,6 +21,7 @@ #include "QtAV/VideoDecoderFFmpegHW.h" #include "QtAV/private/VideoDecoderFFmpegHW_p.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/codec/video/VideoDecoderVAAPI.cpp b/src/codec/video/VideoDecoderVAAPI.cpp index 45a257e0..1c79fec1 100644 --- a/src/codec/video/VideoDecoderVAAPI.cpp +++ b/src/codec/video/VideoDecoderVAAPI.cpp @@ -39,6 +39,7 @@ extern "C" { #include "QtAV/prepost.h" #include "vaapi/vaapi_helper.h" #include "vaapi/SurfaceInteropVAAPI.h" +#include "utils/Logger.h" // TODO: add to AVCompat.h? // FF_API_PIX_FMT diff --git a/src/codec/video/VideoDecoderVDA.cpp b/src/codec/video/VideoDecoderVDA.cpp index c9167481..0c40c9b2 100755 --- a/src/codec/video/VideoDecoderVDA.cpp +++ b/src/codec/video/VideoDecoderVDA.cpp @@ -34,6 +34,7 @@ extern "C" { } #endif //__cplusplus #include +#include "utils/Logger.h" // TODO: add to QtAV_Compat.h? // FF_API_PIX_FMT diff --git a/src/filter/Filter.cpp b/src/filter/Filter.cpp index 699ff8c1..fbddc831 100644 --- a/src/filter/Filter.cpp +++ b/src/filter/Filter.cpp @@ -25,6 +25,7 @@ #include "QtAV/AVOutput.h" #include "QtAV/AVPlayer.h" #include "filter/FilterManager.h" +#include "utils/Logger.h" /* * 1. parent == target (QObject): diff --git a/src/filter/FilterContext.cpp b/src/filter/FilterContext.cpp index df1a1c41..3425ff0e 100644 --- a/src/filter/FilterContext.cpp +++ b/src/filter/FilterContext.cpp @@ -24,6 +24,7 @@ #include #include #include "QtAV/VideoFrame.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/filter/LibAVFilter.cpp b/src/filter/LibAVFilter.cpp index 3275fcd3..def5d47d 100644 --- a/src/filter/LibAVFilter.cpp +++ b/src/filter/LibAVFilter.cpp @@ -25,6 +25,7 @@ #include "QtAV/Statistics.h" #include "QtAV/VideoFrame.h" #include "QtAV/private/AVCompat.h" +#include "utils/Logger.h" /* * libav10.x, ffmpeg2.x: av_buffersink_read deprecated diff --git a/src/filter/SubtitleFilter.cpp b/src/filter/SubtitleFilter.cpp index 145fad45..25f0484f 100644 --- a/src/filter/SubtitleFilter.cpp +++ b/src/filter/SubtitleFilter.cpp @@ -25,7 +25,7 @@ #include "QtAV/Subtitle.h" #include "QtAV/VideoFrame.h" #include -#include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/AVOutput.cpp b/src/output/AVOutput.cpp index efa53e69..8d535fe5 100644 --- a/src/output/AVOutput.cpp +++ b/src/output/AVOutput.cpp @@ -25,6 +25,7 @@ #include "QtAV/FilterContext.h" #include "filter/FilterManager.h" #include "output/OutputSet.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/audio/AudioOutput.cpp b/src/output/audio/AudioOutput.cpp index 093d7238..2012b3ef 100644 --- a/src/output/audio/AudioOutput.cpp +++ b/src/output/audio/AudioOutput.cpp @@ -21,6 +21,7 @@ #include "QtAV/AudioOutput.h" #include "QtAV/private/AudioOutput_p.h" +#include "utils/Logger.h" namespace QtAV { AudioOutput::AudioOutput() diff --git a/src/output/audio/AudioOutputDSound.cpp b/src/output/audio/AudioOutputDSound.cpp index 22fb159b..7cfbd848 100644 --- a/src/output/audio/AudioOutputDSound.cpp +++ b/src/output/audio/AudioOutputDSound.cpp @@ -27,6 +27,7 @@ #define DIRECTSOUND_VERSION 0x0600 #include #include "QtAV/private/AVCompat.h" +#include "utils/Logger.h" namespace QtAV { class AudioOutputDSoundPrivate; diff --git a/src/output/audio/AudioOutputOpenAL.cpp b/src/output/audio/AudioOutputOpenAL.cpp index 9b589e66..c7d88d5e 100644 --- a/src/output/audio/AudioOutputOpenAL.cpp +++ b/src/output/audio/AudioOutputOpenAL.cpp @@ -29,6 +29,7 @@ #include #include #endif +#include "utils/Logger.h" #define UNQUEUE_QUICK 0 diff --git a/src/output/audio/AudioOutputOpenSL.cpp b/src/output/audio/AudioOutputOpenSL.cpp index 29400bfe..f3f83f83 100644 --- a/src/output/audio/AudioOutputOpenSL.cpp +++ b/src/output/audio/AudioOutputOpenSL.cpp @@ -21,6 +21,7 @@ #include #include #include "QtAV/prepost.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/audio/AudioOutputPortAudio.cpp b/src/output/audio/AudioOutputPortAudio.cpp index eda3da44..cbb93728 100644 --- a/src/output/audio/AudioOutputPortAudio.cpp +++ b/src/output/audio/AudioOutputPortAudio.cpp @@ -25,6 +25,7 @@ #include "QtAV/prepost.h" #include #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/Direct2DRenderer.cpp b/src/output/video/Direct2DRenderer.cpp index c362b309..42a41cdd 100644 --- a/src/output/video/Direct2DRenderer.cpp +++ b/src/output/video/Direct2DRenderer.cpp @@ -43,6 +43,7 @@ //performance: http://msdn.microsoft.com/en-us/library/windows/desktop/dd372260(v=vs.85).aspx //vlc is helpful //layer(opacity): http://www.cnblogs.com/graphics/archive/2013/04/15/2781969.html +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/GDIRenderer.cpp b/src/output/video/GDIRenderer.cpp index 2bdb8def..07432c10 100644 --- a/src/output/video/GDIRenderer.cpp +++ b/src/output/video/GDIRenderer.cpp @@ -26,6 +26,7 @@ #include #include #include "QtAV/prepost.h" +#include "utils/Logger.h" #define USE_GRAPHICS 0 diff --git a/src/output/video/GLWidgetRenderer.cpp b/src/output/video/GLWidgetRenderer.cpp index 57468202..31c53ec9 100644 --- a/src/output/video/GLWidgetRenderer.cpp +++ b/src/output/video/GLWidgetRenderer.cpp @@ -44,6 +44,7 @@ #include "QtAV/ColorTransform.h" #include "QtAV/FilterContext.h" +#include "utils/Logger.h" #define UPLOAD_ROI 0 #define ROI_TEXCOORDS 1 diff --git a/src/output/video/GraphicsItemRenderer.cpp b/src/output/video/GraphicsItemRenderer.cpp index d0718da5..79a102d6 100644 --- a/src/output/video/GraphicsItemRenderer.cpp +++ b/src/output/video/GraphicsItemRenderer.cpp @@ -31,6 +31,7 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include #endif +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/OpenGLRendererBase.cpp b/src/output/video/OpenGLRendererBase.cpp index 7e536f9d..0a583578 100644 --- a/src/output/video/OpenGLRendererBase.cpp +++ b/src/output/video/OpenGLRendererBase.cpp @@ -31,6 +31,7 @@ #define QOpenGLShaderProgram QGLShaderProgram #define initializeOpenGLFunctions() initializeGLFunctions() #endif +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/OpenGLWidgetRenderer.cpp b/src/output/video/OpenGLWidgetRenderer.cpp index a9ac7969..86f66173 100644 --- a/src/output/video/OpenGLWidgetRenderer.cpp +++ b/src/output/video/OpenGLWidgetRenderer.cpp @@ -22,6 +22,7 @@ #include "QtAV/OpenGLWidgetRenderer.h" #include "QtAV/private/OpenGLRendererBase_p.h" #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/OpenGLWindowRenderer.cpp b/src/output/video/OpenGLWindowRenderer.cpp index d5a7dd9e..54b39dca 100644 --- a/src/output/video/OpenGLWindowRenderer.cpp +++ b/src/output/video/OpenGLWindowRenderer.cpp @@ -22,6 +22,7 @@ #include "QtAV/OpenGLWindowRenderer.h" #include "QtAV/private/OpenGLRendererBase_p.h" #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/VideoOutputEventFilter.cpp b/src/output/video/VideoOutputEventFilter.cpp index 453ff9e1..5042649c 100644 --- a/src/output/video/VideoOutputEventFilter.cpp +++ b/src/output/video/VideoOutputEventFilter.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/VideoRenderer.cpp b/src/output/video/VideoRenderer.cpp index b1aad2d2..a29178b9 100644 --- a/src/output/video/VideoRenderer.cpp +++ b/src/output/video/VideoRenderer.cpp @@ -30,6 +30,7 @@ #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include #endif +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/WidgetRenderer.cpp b/src/output/video/WidgetRenderer.cpp index c6f36060..091e8d28 100644 --- a/src/output/video/WidgetRenderer.cpp +++ b/src/output/video/WidgetRenderer.cpp @@ -26,6 +26,7 @@ #include #include #include "QtAV/Filter.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/output/video/XVRenderer.cpp b/src/output/video/XVRenderer.cpp index 35e2d780..c74c5d65 100644 --- a/src/output/video/XVRenderer.cpp +++ b/src/output/video/XVRenderer.cpp @@ -27,11 +27,15 @@ #include #include #include +//#error qtextstream.h must be included before any header file that defines Status. Xlib.h defines Status +#include //build error #include #include #include #include "QtAV/prepost.h" +#include "utils/Logger.h" + //http://huangbster.i.sohu.com/blog/view/256490057.htm namespace QtAV { diff --git a/src/subtitle/CharsetDetector.cpp b/src/subtitle/CharsetDetector.cpp index c1fd501a..0deb9509 100644 --- a/src/subtitle/CharsetDetector.cpp +++ b/src/subtitle/CharsetDetector.cpp @@ -23,7 +23,7 @@ #include "QtAV/QtAV_Global.h" #include #include -#include +#include "utils/Logger.h" #if QTAV_HAVE(CHARDET) #include diff --git a/src/subtitle/Subtitle.cpp b/src/subtitle/Subtitle.cpp index 5c098dca..54feeb02 100644 --- a/src/subtitle/Subtitle.cpp +++ b/src/subtitle/Subtitle.cpp @@ -22,7 +22,6 @@ #include "QtAV/Subtitle.h" #include "QtAV/private/SubtitleProcessor.h" #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include "subtitle/CharsetDetector.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/subtitle/SubtitleProcessor.cpp b/src/subtitle/SubtitleProcessor.cpp index bcdccce7..b2709739 100644 --- a/src/subtitle/SubtitleProcessor.cpp +++ b/src/subtitle/SubtitleProcessor.cpp @@ -23,7 +23,7 @@ #include "QtAV/FactoryDefine.h" #include "QtAV/private/factory.h" #include -#include +#include "utils/Logger.h" namespace QtAV { diff --git a/src/subtitle/SubtitleProcessorFFmpeg.cpp b/src/subtitle/SubtitleProcessorFFmpeg.cpp index e8cf99b9..f18a2cc8 100644 --- a/src/subtitle/SubtitleProcessorFFmpeg.cpp +++ b/src/subtitle/SubtitleProcessorFFmpeg.cpp @@ -20,13 +20,13 @@ ******************************************************************************/ #include -#include #include "QtAV/private/SubtitleProcessor.h" #include "QtAV/prepost.h" #include "QtAV/AVDemuxer.h" #include "QtAV/Packet.h" #include "QtAV/private/AVCompat.h" #include "PlainText.h" +#include "utils/Logger.h" namespace QtAV { diff --git a/src/subtitle/SubtitleProcessorLibASS.cpp b/src/subtitle/SubtitleProcessorLibASS.cpp index e4ad201c..061e50a6 100644 --- a/src/subtitle/SubtitleProcessorLibASS.cpp +++ b/src/subtitle/SubtitleProcessorLibASS.cpp @@ -24,11 +24,11 @@ extern "C" { #include } -#include #include "QtAV/private/SubtitleProcessor.h" #include "QtAV/prepost.h" #include "QtAV/Packet.h" #include "PlainText.h" +#include "utils/Logger.h" namespace QtAV { @@ -76,14 +76,24 @@ void RegisterSubtitleProcessorLibASS_Man() FACTORY_REGISTER_ID_MAN(SubtitleProcessor, LibASS, kName) } +// log level from ass_utils.h +#define MSGL_FATAL 0 +#define MSGL_ERR 1 +#define MSGL_WARN 2 +#define MSGL_INFO 4 +#define MSGL_V 6 +#define MSGL_DBG2 7 + static void msg_callback(int level, const char *fmt, va_list va, void *data) { Q_UNUSED(data) - if (level > 6) - return; - printf("libass: "); - vprintf(fmt, va); - printf("\n"); + QString msg("{libass} " + QString().vsprintf(fmt, va)); + if (level == MSGL_FATAL) + qFatal("%s", msg.toUtf8().constData()); + else if (level <= 2) + qWarning() << msg; + else if (level <= MSGL_INFO) + qDebug() << msg; } SubtitleProcessorLibASS::SubtitleProcessorLibASS() @@ -180,7 +190,7 @@ bool SubtitleProcessorLibASS::process(const QString &path) } m_track = ass_read_file(m_ass, (char*)path.toUtf8().constData(), NULL); if (!m_track) { - qWarning("ass_read_memory error, ass track init failed!"); + qWarning("ass_read_file error, ass track init failed!"); return false; } processTrack(m_track); diff --git a/src/utils/BlockingQueue.h b/src/utils/BlockingQueue.h index f750e41c..1c79afdc 100644 --- a/src/utils/BlockingQueue.h +++ b/src/utils/BlockingQueue.h @@ -89,7 +89,7 @@ BlockingQueue::BlockingQueue() template class Container> void BlockingQueue::setCapacity(int max) { - qDebug("queue capacity==>>%d", max); + //qDebug("queue capacity==>>%d", max); QWriteLocker locker(&lock); Q_UNUSED(locker); cap = max; @@ -98,7 +98,7 @@ void BlockingQueue::setCapacity(int max) template class Container> void BlockingQueue::setThreshold(int min) { - qDebug("queue threshold==>>%d", min); + //qDebug("queue threshold==>>%d", min); QWriteLocker locker(&lock); Q_UNUSED(locker); thres = min; diff --git a/src/utils/Logger.cpp b/src/utils/Logger.cpp index 37ccba8a..9035dfe4 100644 --- a/src/utils/Logger.cpp +++ b/src/utils/Logger.cpp @@ -22,58 +22,78 @@ /*! * DO NOT appear qDebug, qWanring etc in Logger.cpp! They are undefined and redefined to QtAV:Internal::Logger.xxx */ -//#include "Logger.h" // we need LogLevel so must include QtAV_Global.h +#include #include "QtAV/QtAV_Global.h" +#include "Logger.h" +#ifdef HACK_QT_LOG + +void ffmpeg_version_print(); namespace QtAV { namespace Internal { +static QString gQtAVLogTag(""); + #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) typedef Logger::Context QMessageLogger; #endif static void log_helper(QtMsgType msgType, const QMessageLogger *qlog, const char* msg, va_list ap) { - QString qmsg; + QString qmsg(gQtAVLogTag); if (msg) - qmsg = " " + QString().vsprintf(msg, ap); + qmsg += QString().vsprintf(msg, ap); // qt_message_output is a public api -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - if (qlog) { - qlog->debug() << qmsg; - } else { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + qt_message_output(msgType, qmsg.toUtf8().constData()); + return; +#else + if (!qlog) { QMessageLogContext ctx; qt_message_output(msgType, ctx, qmsg); + return; } +#endif +#ifndef QT_NO_DEBUG_STREAM + if (msgType == QtWarningMsg) + qlog->warning() << qmsg; + else if (msgType == QtCriticalMsg) + qlog->critical() << qmsg; + else if (msgType == QtFatalMsg) + qlog->fatal("%s", qmsg.toUtf8().constData()); + else + qlog->debug() << qmsg; #else - qt_message_output(msgType, qPrintable(qmsg)); -#endif //QT_VERSION + if (msgType == QtFatalMsg) + qlog->fatal("%s", qmsg.toUtf8().constData()); +#endif // } // macro does not support A::##X void Logger::debug(const char *msg, ...) const { - QtAVDebug d(QtDebugMsg); // initialize something. e.g. environment check + QtAVDebug d; // initialize something. e.g. environment check Q_UNUSED(d); const int v = (int)logLevel(); - if (v < (int)LogDebug) + if (v <= (int)LogOff) return; - if (v > (int)LogDebug && v != (int)LogAll) + if (v > (int)LogDebug && v < (int)LogAll) return; va_list ap; va_start(ap, msg); + // can not use ctx.debug() <<... because QT_NO_DEBUG_STREAM maybe defined log_helper(QtDebugMsg, &ctx, msg, ap); va_end(ap); } void Logger::warning(const char *msg, ...) const { - QtAVDebug d(QtWarningMsg); // initialize something. e.g. environment check + QtAVDebug d; // initialize something. e.g. environment check Q_UNUSED(d); const int v = (int)logLevel(); - if (v < (int)LogWarning) + if (v <= (int)LogOff) return; - if (v > (int)LogWarning && v != (int)LogAll) + if (v > (int)LogWarning && v < (int)LogAll) return; va_list ap; va_start(ap, msg); @@ -83,12 +103,12 @@ void Logger::warning(const char *msg, ...) const void Logger::critical(const char *msg, ...) const { - QtAVDebug d(QtCriticalMsg); // initialize something. e.g. environment check + QtAVDebug d; // initialize something. e.g. environment check Q_UNUSED(d); const int v = (int)logLevel(); - if (v < (int)LogCritical) + if (v <= (int)LogOff) return; - if (v > (int)LogCritical && v != (int)LogAll) + if (v > (int)LogCritical && v < (int)LogAll) return; va_list ap; va_start(ap, msg); @@ -98,62 +118,93 @@ void Logger::critical(const char *msg, ...) const void Logger::fatal(const char *msg, ...) const { - QtAVDebug d(QtFatalMsg); // initialize something. e.g. environment check + QtAVDebug d; // initialize something. e.g. environment check Q_UNUSED(d); const int v = (int)logLevel(); - if (v < (int)LogFatal) - return; - if (v > (int)LogFatal && v != (int)LogAll) - return; - va_list ap; - va_start(ap, msg); - log_helper(QtFatalMsg, &ctx, msg, ap); - va_end(ap); + /* + if (v <= (int)LogOff) + abort(); + if (v > (int)LogFatal && v < (int)LogAll) + abort(); + */ + if (v > (int)LogOff) { + va_list ap; + va_start(ap, msg); + log_helper(QtFatalMsg, &ctx, msg, ap); + va_end(ap); + } + abort(); } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #ifndef QT_NO_DEBUG_STREAM +// internal used by Logger::fatal(const char*,...) with log level checked, so always do things here +void Logger::Context::fatal(const char *msg, ...) const +{ + va_list ap; + va_start(ap, msg); + QString qmsg; + if (msg) + qmsg += QString().vsprintf(msg, ap); + qt_message_output(QtFatalMsg, qmsg.toUtf8().constData()); + va_end(ap); + abort(); +} +#endif //QT_NO_DEBUG_STREAM +#endif //QT_VERSION + +#ifndef QT_NO_DEBUG_STREAM +// will print message in ~QDebug() +// can not use QDebug on stack. It must lives in QtAVDebug QtAVDebug Logger::debug() const { - if ((int)logLevel() < (int)LogDebug) - return QtAVDebug(QtDebugMsg); - // will print message in ~QDebug() - // can not use QDebug on stack. It must lives in QtAVDebug - return QtAVDebug(QtDebugMsg, new QDebug(ctx.debug())); + QtAVDebug d(QtDebugMsg); //// initialize something. e.g. environment check + const int v = (int)logLevel(); + if (v <= (int)LogOff) + return d; + if (v <= (int)LogDebug || v >= (int)LogAll) + d.setQDebug(new QDebug(ctx.debug())); + return d; } QtAVDebug Logger::warning() const { - if ((int)logLevel() < (int)LogWarning) - return QtAVDebug(QtWarningMsg); - return QtAVDebug(QtWarningMsg, new QDebug(ctx.warning())); + QtAVDebug d(QtWarningMsg); + const int v = (int)logLevel(); + if (v <= (int)LogOff) + return d; + if (v <= (int)LogWarning || v >= (int)LogAll) + d.setQDebug(new QDebug(ctx.warning())); + return d; } QtAVDebug Logger::critical() const { - if ((int)logLevel() < (int)LogCritical) - return QtAVDebug(QtCriticalMsg); - return QtAVDebug(QtCriticalMsg, new QDebug(ctx.critical())); + QtAVDebug d(QtCriticalMsg); + const int v = (int)logLevel(); + if (v <= (int)LogOff) + return d; + if (v <= (int)LogCritical || v >= (int)LogAll) + d.setQDebug(new QDebug(ctx.critical())); + return d; } // no QMessageLogger::fatal() -/* -QtAVDebug Logger::fatal() const -{ - if ((int)logLevel() < (int)LogFatal) - return QtAVDebug(QtFatalMsg); - return QtAVDebug(QtFatalMsg, new QDebug(ctx.fatal())); -}*/ #endif //QT_NO_DEBUG_STREAM +bool isLogLevelSet(); + QtAVDebug::QtAVDebug(QtMsgType t, QDebug *d) : type(t) - , dbg(d) + , dbg(0) { + setQDebug(d); // call *dbg << gQtAVLogTag static bool sFirstRun = true; if (!sFirstRun) return; sFirstRun = false; //printf("Qt Logging first run........\n"); // check environment var and call other functions at first Qt logging call + // always override setLogLevel() QByteArray env = qgetenv("QTAV_LOG_LEVEL"); if (!env.isEmpty()) { bool ok = false; @@ -181,13 +232,31 @@ QtAVDebug::QtAVDebug(QtMsgType t, QDebug *d) setLogLevel(LogAll); } } + env = qgetenv("QTAV_LOG_TAG"); + if (!env.isEmpty()) { + gQtAVLogTag = env; + } + + if ((int)logLevel() > (int)LogOff) { + ffmpeg_version_print(); + printf("%s\n", aboutQtAV_PlainText().toUtf8().constData()); + fflush(0); + } } QtAVDebug::~QtAVDebug() +{ + setQDebug(0); +} + +void QtAVDebug::setQDebug(QDebug *d) { if (dbg) { delete dbg; - dbg = 0; + } + dbg = d; + if (dbg && !gQtAVLogTag.isEmpty()) { + *dbg << gQtAVLogTag; } } @@ -208,3 +277,5 @@ QtAVDebug debug(const char *msg, ...) } //namespace Internal } // namespace QtAV + +#endif //HACK_QT_LOG diff --git a/src/utils/Logger.h b/src/utils/Logger.h index fb7be5b8..06183afa 100644 --- a/src/utils/Logger.h +++ b/src/utils/Logger.h @@ -21,12 +21,25 @@ /* * Qt Logging Hack + * in qmacdefines_mac.h, if qDebug is defined, then if will be defined as QT_NO_QDEBUG_MACRO, don't know why + * So you have to include this only as the last #include in cpp file! + * DO NOT use qDebug in public header! */ #ifndef QTAV_LOGGER_H #define QTAV_LOGGER_H +/*! + Environment var + QTAV_LOG_TAG: prefix the value to log message + QTAV_LOG_LEVEL: set log level, can be "off", "debug", "warning", "critical", "fatal", "all" + */ + +#define HACK_QT_LOG +#ifdef HACK_QT_LOG + #include +#include #ifndef Q_DECL_CONSTEXPR #define Q_DECL_CONSTEXPR @@ -53,34 +66,54 @@ public: */ QtAVDebug(QtMsgType t = QtDebugMsg, QDebug *d = 0); ~QtAVDebug(); + void setQDebug(QDebug* d); + // QDebug api + inline QtAVDebug &space() { + if (dbg) + dbg->space(); + return *this; + } + inline QtAVDebug &nospace() { + if (dbg) + dbg->nospace(); + return *this; + } + inline QtAVDebug &maybeSpace() { + if (dbg) + dbg->maybeSpace(); + return *this; + } + template QtAVDebug &operator<<(T t) { if (!dbg) return *this; - if ((int)logLevel() < LogDebug) + const int l = (int)logLevel(); + if (l <= (int)LogOff) return *this; - if ((int)logLevel() >= LogAll) { + if (l >= (int)LogAll) { *dbg << t; return *this; } - if ((int)logLevel() <= LogDebug) { + if (l == (int)LogDebug) { *dbg << t; return *this; } - if (logLevel() == LogWarning) { - if ((int)type <= (int)QtWarningMsg) + if (l == (int)LogWarning) { + if ((int)type >= (int)QtWarningMsg) *dbg << t; return *this; } - if (logLevel() == LogCritical) { - if ((int)type <= (int)QtCriticalMsg) + if (l == (int)LogCritical) { + if ((int)type >= (int)QtCriticalMsg) *dbg << t; return *this; } - if (logLevel() == LogFatal) { - if ((int)type <= (int)QtFatalMsg) + if (l == (int)LogFatal) { + if ((int)type >= (int)QtFatalMsg) *dbg << t; return *this; } + return *this; } private: QtMsgType type; @@ -92,7 +125,7 @@ class Logger { public:Q_DECL_CONSTEXPR Logger(const char *file = "unknown", int line = 0, const char *function = "unknown", const char *category = "default") : ctx(file, line, function, category) {} void debug(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); - void noDebug(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3) + void noDebug(const char *, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3) {} void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); @@ -105,7 +138,7 @@ public:Q_DECL_CONSTEXPR Logger(const char *file = "unknown", int line = 0, const #ifndef QT_NO_DEBUG_STREAM //TODO: QLoggingCategory - QtAVDebug debug() const ; + QtAVDebug debug() const; QtAVDebug warning() const; QtAVDebug critical() const; //QtAVDebug fatal() const; @@ -118,6 +151,10 @@ public: //public can typedef outside public: Q_DECL_CONSTEXPR Context(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) : version(1), line(lineNumber), file(fileName), function(functionName), category(categoryName) {} +#ifndef Q_CC_MSVC + Q_NORETURN +#endif + void fatal(const char *msg, ...) const Q_DECL_NOTHROW Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); #ifndef QT_NO_DEBUG_STREAM inline QDebug debug() const { return QDebug(QtDebugMsg);} inline QDebug warning() const { return QDebug(QtWarningMsg);} @@ -159,12 +196,32 @@ QNoDebug debug(const char *msg, ...); /* print debug message */ #undef qWarning #undef qCritical #undef qFatal +// debug and warning output can be disabled at build time in Qt +// from qdebug.h + +#ifdef QT_NO_DEBUG_OUTPUT +#define QT_NO_WARNING_OUTPUT ////FIXME. qWarning() => Logger.warning() not declared +#undef qDebug +inline QNoDebug qDebug() { return QNoDebug(); } +#define qDebug QT_NO_QDEBUG_MACRO +#else +inline QtAVDebug qDebug() { return QtAVDebug(QtDebugMsg); } #define qDebug QtAV::Internal::Logger(__FILE__, __LINE__, Q_FUNC_INFO).debug +#endif //QT_NO_DEBUG_OUTPUT + +#ifdef QT_NO_WARNING_OUTPUT +#undef qWarning +inline QNoDebug qWarning() { return QNoDebug(); } +#define qWarning QT_NO_QWARNING_MACRO +#else +inline QtAVDebug qWarning() { return QtAVDebug(QtWarningMsg); } #define qWarning QtAV::Internal::Logger(__FILE__, __LINE__, Q_FUNC_INFO).warning +#endif //QT_NO_WARNING_OUTPUT #define qCritical QtAV::Internal::Logger(__FILE__, __LINE__, Q_FUNC_INFO).critical #define qFatal QtAV::Internal::Logger(__FILE__, __LINE__, Q_FUNC_INFO).fatal } // namespace Internal } // namespace QtAV +#endif //HACK_QT_LOG #endif // QTAV_LOGGER_H diff --git a/src/utils/OpenGLHelper.cpp b/src/utils/OpenGLHelper.cpp index 4a474622..7fba19a8 100644 --- a/src/utils/OpenGLHelper.cpp +++ b/src/utils/OpenGLHelper.cpp @@ -23,10 +23,11 @@ #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #include #endif +#include "utils/Logger.h" + namespace QtAV { namespace OpenGLHelper { - // glActiveTexture in Qt4 on windows release mode crash for me #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #ifndef QT_OPENGL_ES diff --git a/src/vaapi/vaapi_helper.cpp b/src/vaapi/vaapi_helper.cpp index 25359243..75fef7b4 100644 --- a/src/vaapi/vaapi_helper.cpp +++ b/src/vaapi/vaapi_helper.cpp @@ -1,4 +1,5 @@ #include "vaapi_helper.h" +#include "utils/Logger.h" namespace QtAV { namespace vaapi { diff --git a/src/vaapi/vaapi_helper.h b/src/vaapi/vaapi_helper.h index 04be3cdd..fbb4deeb 100644 --- a/src/vaapi/vaapi_helper.h +++ b/src/vaapi/vaapi_helper.h @@ -203,7 +203,7 @@ public: , m_height(h) {} ~surface_t() { - qDebug("VAAPI - destroying surface 0x%x", (int)m_id); + //qDebug("VAAPI - destroying surface 0x%x", (int)m_id); if (m_id != VA_INVALID_SURFACE) VAWARN(vaDestroySurfaces(m_display->get(), &m_id, 1)) }