From d04aad522d5980dd92c5aff1990e88a020900f0b Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 17 Jun 2016 23:59:25 +0800 Subject: [PATCH] io: no manually close input io closed by avformat_close_input. results in crash in 3.1 --- src/QtAV/MediaIO.h | 15 ++++++++++----- src/io/MediaIO.cpp | 14 ++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/QtAV/MediaIO.h b/src/QtAV/MediaIO.h index 2e5a3070b..3bfcb8d0f 100644 --- a/src/QtAV/MediaIO.h +++ b/src/QtAV/MediaIO.h @@ -1,8 +1,8 @@ /****************************************************************************** - QtAV: Media play library based on Qt and FFmpeg - Copyright (C) 2014-2015 Wang Bin + QtAV: Multimedia framework based on Qt and FFmpeg + Copyright (C) 2012-2016 Wang Bin -* This file is part of QtAV +* This file is part of QtAV (from 2014) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -70,7 +70,12 @@ class Q_AV_EXPORT MediaIO : public QObject virtual ~MediaIO(); virtual QString name() const = 0; - virtual void setUrl(const QString& url); + /*! + * \brief setUrl + * onUrlChange() will be called if url is different. onUrlChange() will close the old url and open the new url if it's not empty + * \param url + */ + void setUrl(const QString& url = QString()); QString url() const; /*! * \brief setAccessMode @@ -104,7 +109,7 @@ class Q_AV_EXPORT MediaIO : public QObject * \param from SEEK_SET, SEEK_CUR and SEEK_END from stdio.h * \return true if success */ - virtual bool seek(qint64 offset, int from) = 0; + virtual bool seek(qint64 offset, int from = SEEK_SET) = 0; /*! * \brief position * MUST implement this. Used in seek diff --git a/src/io/MediaIO.cpp b/src/io/MediaIO.cpp index e98c83b42..52aebd9d9 100644 --- a/src/io/MediaIO.cpp +++ b/src/io/MediaIO.cpp @@ -1,9 +1,9 @@ /****************************************************************************** - QtAV: Media play library based on Qt and FFmpeg - Copyright (C) 2014-2015 Wang Bin + QtAV: Multimedia framework based on Qt and FFmpeg + Copyright (C) 2012-2016 Wang Bin Initial QAVIOContext.cpp code is from Stefan Ladage -* This file is part of QtAV +* This file is part of QtAV (from 2014) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -193,10 +193,8 @@ void MediaIO::release() DPTR_D(MediaIO); if (!d.ctx) return; - d.ctx->opaque = 0; //in avio_close() opaque is URLContext* and will call ffurl_close() - //d.ctx->buffer = 0; //already released by ffio_rewind_with_probe_data; may be another context was freed - avio_close(d.ctx); //avio_closep defined since ffmpeg1.1 - d.ctx = 0; + // avio_close is called by avformat_close_input. here we only allocate but no open + av_freep(&d.ctx->buffer); + av_freep(&d.ctx); } - } //namespace QtAV