Skip to content

Commit 90e3e5d

Browse files
author
Clement Champetier
committed
FormatContext: fix close of AVFormatContext only if is open
The desctructor of the class will be called when throw exception in functions.
1 parent bde8526 commit 90e3e5d

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/AvTranscoder/file/FormatContext.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ FormatContext::~FormatContext()
3939
{
4040
if( ! _avFormatContext )
4141
return;
42-
42+
4343
if( _isOpen )
4444
avformat_close_input( &_avFormatContext );
4545
else
@@ -52,7 +52,6 @@ void FormatContext::findStreamInfo( AVDictionary** options )
5252
int err = avformat_find_stream_info( _avFormatContext, options );
5353
if( err < 0 )
5454
{
55-
avformat_close_input( &_avFormatContext );
5655
throw std::ios_base::failure( "unable to find stream informations" );
5756
}
5857
}
@@ -65,7 +64,6 @@ void FormatContext::openRessource( const std::string& url, int flags )
6564
int err = avio_open2( &_avFormatContext->pb, url.c_str(), flags, NULL, NULL );
6665
if( err < 0 )
6766
{
68-
avformat_close_input( &_avFormatContext );
6967
throw std::ios_base::failure( "error when opening output format" );
7068
}
7169
}
@@ -78,7 +76,6 @@ void FormatContext::closeRessource()
7876
int err = avio_close( _avFormatContext->pb );
7977
if( err < 0 )
8078
{
81-
avformat_close_input( &_avFormatContext );
8279
throw std::ios_base::failure( "error when close output format" );
8380
}
8481
}

0 commit comments

Comments
 (0)