Skip to content

Commit f6fc8b7

Browse files
insert throw if cannot openning contexts
1 parent 9503a24 commit f6fc8b7

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/AvTranscoder/DatasStructures/AudioDesc.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ void AudioDesc::setAudioCodec( const AVCodecID codecId )
5252
void AudioDesc::initCodecContext( )
5353
{
5454
if( m_codec == NULL )
55-
return;
55+
{
56+
throw std::runtime_error( "unknown audio codec" );
57+
}
5658

5759
if( ( m_codecContext = avcodec_alloc_context3( m_codec ) ) == NULL )
58-
return;
60+
{
61+
throw std::runtime_error( "unable to create context for audio context" );
62+
}
5963

6064
// Set default codec parameters
6165
if( avcodec_get_context_defaults3( m_codecContext, m_codec ) != 0 )
6266
{
63-
m_codecContext = NULL;
64-
return;
67+
throw std::runtime_error( "unable to find audio codec default values" );
6568
}
6669
}
6770

src/AvTranscoder/DatasStructures/VideoDesc.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,19 @@ std::pair< size_t, size_t > VideoDesc::getTimeBase() const
9494
void VideoDesc::initCodecContext( )
9595
{
9696
if( m_codec == NULL )
97-
return;
97+
{
98+
throw std::runtime_error( "unknown audio codec" );
99+
}
98100

99101
if( ( m_codecContext = avcodec_alloc_context3( m_codec ) ) == NULL )
100-
return;
102+
{
103+
throw std::runtime_error( "unable to create context for video context" );
104+
}
101105

102106
// Set default codec parameters
103107
if( avcodec_get_context_defaults3( m_codecContext, m_codec ) != 0 )
104108
{
105-
m_codecContext = NULL;
106-
return;
109+
throw std::runtime_error( "unable to find video codec default values" );
107110
}
108111
}
109112

0 commit comments

Comments
 (0)