mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 05:16:05 +00:00
Only close the codec if we opened it
Original commit message from CVS: Only close the codec if we opened it
This commit is contained in:
parent
10706fe9ee
commit
cb9f0ff232
1 changed files with 12 additions and 4 deletions
|
@ -33,10 +33,12 @@
|
|||
typedef struct _GstFFMpegDecAll {
|
||||
GstElement element;
|
||||
|
||||
GstPad *srcpad, *sinkpad;
|
||||
GstPad *srcpad,
|
||||
*sinkpad;
|
||||
|
||||
AVCodecContext *context;
|
||||
AVFrame picture;
|
||||
gboolean opened;
|
||||
} GstFFMpegDecAll;
|
||||
|
||||
typedef struct _GstFFMpegDecAllClass {
|
||||
|
@ -255,6 +257,7 @@ gst_ffmpegdecall_init(GstFFMpegDecAll *ffmpegdec)
|
|||
ffmpegdec->srcpad);
|
||||
|
||||
ffmpegdec->context = avcodec_alloc_context();
|
||||
ffmpegdec->opened = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -262,7 +265,10 @@ gst_ffmpegdecall_destroy (GObject *obj)
|
|||
{
|
||||
GstFFMpegDecAll *ffmpegdec = GST_FFMPEGDECALL(obj);
|
||||
g_print ("ffmpeg: destroying codec\n");
|
||||
if (ffmpegdec->opened) {
|
||||
avcodec_close(ffmpegdec->context);
|
||||
ffmpegdec->opened = FALSE;
|
||||
}
|
||||
av_free(ffmpegdec->context);
|
||||
}
|
||||
|
||||
|
@ -297,8 +303,10 @@ gst_ffmpegdecall_connect (GstPad *pad, GstCaps *caps)
|
|||
if (avcodec_open(ffmpegdec->context, plugin)) {
|
||||
GST_DEBUG(GST_CAT_PLUGIN_INFO,
|
||||
"Failed to open FFMPEG codec for id=%d", id);
|
||||
ffmpegdec->opened = FALSE;
|
||||
return GST_PAD_LINK_REFUSED;
|
||||
}
|
||||
ffmpegdec->opened = TRUE;
|
||||
|
||||
return GST_PAD_LINK_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue