diff mbox

[FFmpeg-devel,1/4] avformat/ttaenc: add a deinit function

Message ID 20191021024934.1624-1-jamrial@gmail.com
State Accepted
Commit b46cdd9d23703f4976d2504055ccc86741013f4b
Headers show

Commit Message

James Almer Oct. 21, 2019, 2:49 a.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/ttaenc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Andreas Rheinhardt Oct. 21, 2019, 4:19 a.m. UTC | #1
James Almer:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavformat/ttaenc.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
> index d8e1136ead..73c29ae936 100644
> --- a/libavformat/ttaenc.c
> +++ b/libavformat/ttaenc.c
> @@ -147,6 +147,7 @@ static int tta_write_trailer(AVFormatContext *s)
>      avio_wl32(tta->seek_table, crc);
>      size = avio_close_dyn_buf(tta->seek_table, &ptr);
>      avio_write(s->pb, ptr, size);
> +    tta->seek_table = NULL;
>      av_free(ptr);
>  
>      /* Write audio data */
> @@ -158,6 +159,14 @@ static int tta_write_trailer(AVFormatContext *s)
>      return 0;
>  }
>  
> +static void tta_deinit(AVFormatContext *s)
> +{
> +    TTAMuxContext *tta = s->priv_data;
> +
> +    ffio_free_dyn_buf(&tta->seek_table);
> +    ff_packet_list_free(&tta->queue, &tta->queue_end);
> +}
> +
>  AVOutputFormat ff_tta_muxer = {
>      .name              = "tta",
>      .long_name         = NULL_IF_CONFIG_SMALL("TTA (True Audio)"),
> @@ -167,6 +176,7 @@ AVOutputFormat ff_tta_muxer = {
>      .audio_codec       = AV_CODEC_ID_TTA,
>      .video_codec       = AV_CODEC_ID_NONE,
>      .init              = tta_init,
> +    .deinit            = tta_deinit,
>      .write_header      = tta_write_header,
>      .write_packet      = tta_write_packet,
>      .write_trailer     = tta_write_trailer,
> 

LGTM

- Andreas
diff mbox

Patch

diff --git a/libavformat/ttaenc.c b/libavformat/ttaenc.c
index d8e1136ead..73c29ae936 100644
--- a/libavformat/ttaenc.c
+++ b/libavformat/ttaenc.c
@@ -147,6 +147,7 @@  static int tta_write_trailer(AVFormatContext *s)
     avio_wl32(tta->seek_table, crc);
     size = avio_close_dyn_buf(tta->seek_table, &ptr);
     avio_write(s->pb, ptr, size);
+    tta->seek_table = NULL;
     av_free(ptr);
 
     /* Write audio data */
@@ -158,6 +159,14 @@  static int tta_write_trailer(AVFormatContext *s)
     return 0;
 }
 
+static void tta_deinit(AVFormatContext *s)
+{
+    TTAMuxContext *tta = s->priv_data;
+
+    ffio_free_dyn_buf(&tta->seek_table);
+    ff_packet_list_free(&tta->queue, &tta->queue_end);
+}
+
 AVOutputFormat ff_tta_muxer = {
     .name              = "tta",
     .long_name         = NULL_IF_CONFIG_SMALL("TTA (True Audio)"),
@@ -167,6 +176,7 @@  AVOutputFormat ff_tta_muxer = {
     .audio_codec       = AV_CODEC_ID_TTA,
     .video_codec       = AV_CODEC_ID_NONE,
     .init              = tta_init,
+    .deinit            = tta_deinit,
     .write_header      = tta_write_header,
     .write_packet      = tta_write_packet,
     .write_trailer     = tta_write_trailer,