Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
a9edb4de
Commit
a9edb4de
authored
Jul 29, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: use AtScopeExit() for safe cleanup
parent
a076ddf3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+23
-14
No files found.
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
a9edb4de
...
...
@@ -35,6 +35,7 @@
#include "tag/TagHandler.hxx"
#include "input/InputStream.hxx"
#include "CheckAudioFormat.hxx"
#include "util/ScopeExit.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Error.hxx"
#include "LogV.hxx"
...
...
@@ -473,6 +474,10 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
return
;
}
AtScopeExit
(
codec_context
)
{
avcodec_close
(
codec_context
);
};
const
SignedSongTime
total_time
=
FromFfmpegTimeChecked
(
av_stream
.
duration
,
av_stream
.
time_base
);
...
...
@@ -489,6 +494,16 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
return
;
}
AtScopeExit
(
&
frame
)
{
#if LIBAVUTIL_VERSION_MAJOR >= 53
av_frame_free
(
&
frame
);
#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
avcodec_free_frame
(
&
frame
);
#else
av_free
(
frame
);
#endif
};
FfmpegBuffer
interleaved_buffer
;
uint64_t
min_frame
=
0
;
...
...
@@ -537,16 +552,6 @@ FfmpegDecode(Decoder &decoder, InputStream &input,
av_free_packet
(
&
packet
);
#endif
}
#if LIBAVUTIL_VERSION_MAJOR >= 53
av_frame_free
(
&
frame
);
#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
avcodec_free_frame
(
&
frame
);
#else
av_free
(
frame
);
#endif
avcodec_close
(
codec_context
);
}
static
void
...
...
@@ -572,9 +577,11 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
return
;
}
FfmpegDecode
(
decoder
,
input
,
*
format_context
);
AtScopeExit
(
&
format_context
)
{
avformat_close_input
(
&
format_context
);
};
FfmpegDecode
(
decoder
,
input
,
*
format_context
);
}
static
bool
...
...
@@ -619,9 +626,11 @@ ffmpeg_scan_stream(InputStream &is,
if
(
f
==
nullptr
)
return
false
;
bool
result
=
FfmpegScanStream
(
*
f
,
*
handler
,
handler_ctx
);
AtScopeExit
(
&
f
)
{
avformat_close_input
(
&
f
);
return
result
;
};
return
FfmpegScanStream
(
*
f
,
*
handler
,
handler_ctx
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment