Skip to content

Commit

Permalink
io: no manually close input io
Browse files Browse the repository at this point in the history
closed by avformat_close_input. results in crash in 3.1
  • Loading branch information
wang-bin committed Jun 17, 2016
1 parent b08f2dd commit d04aad5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
15 changes: 10 additions & 5 deletions src/QtAV/MediaIO.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014-2015 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 6 additions & 8 deletions src/io/MediaIO.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014-2015 Wang Bin <[email protected]>
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Initial QAVIOContext.cpp code is from Stefan Ladage <[email protected]>
* 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
Expand Down Expand Up @@ -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

0 comments on commit d04aad5

Please sign in to comment.