mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-19 12:58:35 +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
|
@ -31,12 +31,14 @@
|
||||||
#include "gstffmpegallcodecmap.h"
|
#include "gstffmpegallcodecmap.h"
|
||||||
|
|
||||||
typedef struct _GstFFMpegDecAll {
|
typedef struct _GstFFMpegDecAll {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
|
||||||
GstPad *srcpad, *sinkpad;
|
GstPad *srcpad,
|
||||||
|
*sinkpad;
|
||||||
|
|
||||||
AVCodecContext *context;
|
AVCodecContext *context;
|
||||||
AVFrame picture;
|
AVFrame picture;
|
||||||
|
gboolean opened;
|
||||||
} GstFFMpegDecAll;
|
} GstFFMpegDecAll;
|
||||||
|
|
||||||
typedef struct _GstFFMpegDecAllClass {
|
typedef struct _GstFFMpegDecAllClass {
|
||||||
|
@ -255,6 +257,7 @@ gst_ffmpegdecall_init(GstFFMpegDecAll *ffmpegdec)
|
||||||
ffmpegdec->srcpad);
|
ffmpegdec->srcpad);
|
||||||
|
|
||||||
ffmpegdec->context = avcodec_alloc_context();
|
ffmpegdec->context = avcodec_alloc_context();
|
||||||
|
ffmpegdec->opened = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -262,7 +265,10 @@ gst_ffmpegdecall_destroy (GObject *obj)
|
||||||
{
|
{
|
||||||
GstFFMpegDecAll *ffmpegdec = GST_FFMPEGDECALL(obj);
|
GstFFMpegDecAll *ffmpegdec = GST_FFMPEGDECALL(obj);
|
||||||
g_print ("ffmpeg: destroying codec\n");
|
g_print ("ffmpeg: destroying codec\n");
|
||||||
avcodec_close(ffmpegdec->context);
|
if (ffmpegdec->opened) {
|
||||||
|
avcodec_close(ffmpegdec->context);
|
||||||
|
ffmpegdec->opened = FALSE;
|
||||||
|
}
|
||||||
av_free(ffmpegdec->context);
|
av_free(ffmpegdec->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,8 +303,10 @@ gst_ffmpegdecall_connect (GstPad *pad, GstCaps *caps)
|
||||||
if (avcodec_open(ffmpegdec->context, plugin)) {
|
if (avcodec_open(ffmpegdec->context, plugin)) {
|
||||||
GST_DEBUG(GST_CAT_PLUGIN_INFO,
|
GST_DEBUG(GST_CAT_PLUGIN_INFO,
|
||||||
"Failed to open FFMPEG codec for id=%d", id);
|
"Failed to open FFMPEG codec for id=%d", id);
|
||||||
|
ffmpegdec->opened = FALSE;
|
||||||
return GST_PAD_LINK_REFUSED;
|
return GST_PAD_LINK_REFUSED;
|
||||||
}
|
}
|
||||||
|
ffmpegdec->opened = TRUE;
|
||||||
|
|
||||||
return GST_PAD_LINK_OK;
|
return GST_PAD_LINK_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue