From cbd6e5f074b26718dcd1bc3e35f8d5172d7135ed Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Thu, 28 May 2009 07:01:14 +0200 Subject: [PATCH] Added closing of the FFmpeg output stream. Resources are correctly released now. Signed-off-by: Pavel Pisa --- output.c | 6 ++++++ output.h | 2 ++ streamer.c | 3 +++ 3 files changed, 11 insertions(+) diff --git a/output.c b/output.c index 260d58f..b5d60e6 100644 --- a/output.c +++ b/output.c @@ -49,6 +49,12 @@ AVFormatContext *open_output_stream(const char *dst, int port, enum CodecType co return s; } +int close_output_stream(AVFormatContext *s) +{ + url_fclose(s->pb); + return 0; +} + int pkt_send(AVFormatContext *ctx, AVPacket *pkt) { static int inited; /* FIXME: HACK! */ diff --git a/output.h b/output.h index 8ece7a9..d035ef8 100644 --- a/output.h +++ b/output.h @@ -5,4 +5,6 @@ */ int pkt_send(AVFormatContext *ctx, AVPacket *pkt); AVFormatContext *open_output_stream(const char *dst, int port, enum CodecType codec_type); +int close_output_stream(AVFormatContext *s); + diff --git a/streamer.c b/streamer.c index 1f85ce4..e794e9a 100644 --- a/streamer.c +++ b/streamer.c @@ -263,6 +263,7 @@ int main(int argc, char *argv[]) printf("Finishing\n"); + close_output_stream(os); #else pthread_attr_t attr; pthread_t streamer_th; @@ -280,6 +281,8 @@ int main(int argc, char *argv[]) pthread_join(streamer_th, (void**) NULL); printf("Finishing\n"); + + close_output_stream(os); #endif return 0; -- 2.39.2