@@ -1402,12 +1402,12 @@ UniqueAVFrame SingleStreamDecoder::convertAudioAVFrameSampleFormatAndSampleRate(
14021402 auto & streamInfo = streamInfos_[activeStreamIndex_];
14031403
14041404 if (!streamInfo.swrContext ) {
1405- createSwrContext (
1406- streamInfo,
1405+ streamInfo. swrContext . reset ( createSwrContext (
1406+ streamInfo. codecContext ,
14071407 sourceSampleFormat,
14081408 desiredSampleFormat,
14091409 sourceSampleRate,
1410- desiredSampleRate);
1410+ desiredSampleRate)) ;
14111411 }
14121412
14131413 UniqueAVFrame convertedAVFrame (av_frame_alloc ());
@@ -1735,14 +1735,14 @@ void SingleStreamDecoder::createSwsContext(
17351735 streamInfo.swsContext .reset (swsContext);
17361736}
17371737
1738- void SingleStreamDecoder::createSwrContext (
1739- StreamInfo& streamInfo ,
1738+ SwrContext* SingleStreamDecoder::createSwrContext (
1739+ UniqueAVCodecContext& avCodecContext ,
17401740 AVSampleFormat sourceSampleFormat,
17411741 AVSampleFormat desiredSampleFormat,
17421742 int sourceSampleRate,
17431743 int desiredSampleRate) {
17441744 auto swrContext = allocateSwrContext (
1745- streamInfo. codecContext ,
1745+ avCodecContext ,
17461746 sourceSampleFormat,
17471747 desiredSampleFormat,
17481748 sourceSampleRate,
@@ -1756,7 +1756,8 @@ void SingleStreamDecoder::createSwrContext(
17561756 " . If the error says 'Invalid argument', it's likely that you are using "
17571757 " a buggy FFmpeg version. FFmpeg4 is known to fail here in some "
17581758 " valid scenarios. Try to upgrade FFmpeg?" );
1759- streamInfo.swrContext .reset (swrContext);
1759+ // streamInfo.swrContext.reset(swrContext);
1760+ return swrContext;
17601761}
17611762
17621763// --------------------------------------------------------------------------
0 commit comments