[haiku-commits] haiku: hrev46028 - src/add-ons/media/plugins/ffmpeg

  • From: korli@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 6 Sep 2013 23:39:52 +0200 (CEST)

hrev46028 adds 1 changeset to branch 'master'
old head: ba654b1b91e2b920d212976e5bee8109c002564e
new head: 8a1f3038407f37a3e212c77e86630533dce8c705
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=8a1f303+%5Eba654b1

----------------------------------------------------------------------------

8a1f303: ffmpeg: release the reader context on destruction.
  
  * avformat_open_input() is to be balanced with a avformat_close_input().
  * should help with #9945.

                                   [ Jérôme Duval <jerome.duval@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46028
Commit:      8a1f3038407f37a3e212c77e86630533dce8c705
URL:         http://cgit.haiku-os.org/haiku/commit/?id=8a1f303
Author:      Jérôme Duval <jerome.duval@xxxxxxxxx>
Date:        Fri Sep  6 21:36:58 2013 UTC

Ticket:      https://dev.haiku-os.org/ticket/9945

----------------------------------------------------------------------------

1 file changed, 8 insertions(+), 4 deletions(-)
src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp | 12 ++++++++----

----------------------------------------------------------------------------

diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp 
b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
index 23b0b66..7531060 100644
--- a/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/AVFormatReader.cpp
@@ -238,10 +238,12 @@ StreamBase::StreamBase(BPositionIO* source, BLocker* 
sourceLock,
 
 StreamBase::~StreamBase()
 {
-       av_free(fIOContext->buffer);
-       av_free(fIOContext);
+       if (fContext != NULL)
+               avformat_close_input(&fContext);
        av_free_packet(&fPacket);
        av_free(fContext);
+       av_free(fIOContext->buffer);
+       av_free(fIOContext);
 }
 
 
@@ -263,6 +265,7 @@ StreamBase::Open()
                _Seek);
        if (fIOContext == NULL) {
                TRACE("StreamBase::Open() - avio_alloc_context() failed!\n");
+               av_free(buffer);
                return B_ERROR;
        }
 
@@ -273,6 +276,9 @@ StreamBase::Open()
        if (avformat_open_input(&fContext, "", NULL, NULL) < 0) {
                TRACE("StreamBase::Open() - avformat_open_input() failed!\n");
                // avformat_open_input() frees the context in case of failure
+               fContext = NULL;
+               av_free(fIOContext);
+               fIOContext = NULL;
                return B_NOT_SUPPORTED;
        }
 
@@ -1772,5 +1778,3 @@ AVFormatReader::GetNextChunk(void* _cookie, const void** 
chunkBuffer,
        Stream* cookie = reinterpret_cast<Stream*>(_cookie);
        return cookie->GetNextChunk(chunkBuffer, chunkSize, mediaHeader);
 }
-
-


Other related posts:

  • » [haiku-commits] haiku: hrev46028 - src/add-ons/media/plugins/ffmpeg - korli