Skip to content

Commit d5d633f

Browse files
author
Clement Champetier
committed
ICodec: fix how to close the codec
* The decoder can open the codec (and so there is a flag _isSetup to check this). * If the codec was open by the decoder, it should close it at the end of its life. * So the codec itself is not responsible to close its context.
1 parent bcc0b08 commit d5d633f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/AvTranscoder/codec/ICodec.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ ICodec::ICodec(const ECodecType type, AVCodecContext& avCodecContext)
4444

4545
ICodec::~ICodec()
4646
{
47-
closeCodec();
48-
4947
if(!_isCodecContextAllocated)
5048
return;
5149

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ AudioDecoder::AudioDecoder(InputStream& inputStream)
2727

2828
AudioDecoder::~AudioDecoder()
2929
{
30+
if(_isSetup)
31+
_inputStream->getAudioCodec().closeCodec();
3032
}
3133

3234
void AudioDecoder::setupDecoder(const ProfileLoader::Profile& profile)
@@ -73,7 +75,7 @@ void AudioDecoder::setupDecoder(const ProfileLoader::Profile& profile)
7375
}
7476

7577
// open decoder
76-
_inputStream->getAudioCodec().openCodec();
78+
codec.openCodec();
7779
_isSetup = true;
7880
}
7981

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ VideoDecoder::VideoDecoder(InputStream& inputStream)
2424

2525
VideoDecoder::~VideoDecoder()
2626
{
27+
if(_isSetup)
28+
_inputStream->getVideoCodec().closeCodec();
2729
}
2830

2931
void VideoDecoder::setupDecoder(const ProfileLoader::Profile& profile)
@@ -70,7 +72,7 @@ void VideoDecoder::setupDecoder(const ProfileLoader::Profile& profile)
7072
}
7173

7274
// open decoder
73-
_inputStream->getVideoCodec().openCodec();
75+
codec.openCodec();
7476
_isSetup = true;
7577
}
7678

0 commit comments

Comments
 (0)