From 0489f5277649826d1b38213c234fb0fe27206c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 2 Jan 2013 10:26:04 +0100 Subject: [PATCH] mfc: Check if the hardware is available in GstVideoDecoder::open() --- sys/mfc/gstmfcdec.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sys/mfc/gstmfcdec.c b/sys/mfc/gstmfcdec.c index 7530f3c076..ec12192d82 100644 --- a/sys/mfc/gstmfcdec.c +++ b/sys/mfc/gstmfcdec.c @@ -30,6 +30,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_mfc_dec_debug); #define GST_CAT_DEFAULT gst_mfc_dec_debug +static gboolean gst_mfc_dec_open (GstVideoDecoder * decoder); static gboolean gst_mfc_dec_start (GstVideoDecoder * decoder); static gboolean gst_mfc_dec_stop (GstVideoDecoder * decoder); static gboolean gst_mfc_dec_set_format (GstVideoDecoder * decoder, @@ -109,6 +110,7 @@ gst_mfc_dec_class_init (GstMFCDecClass * klass) "Decode video streams via Samsung Exynos", "Sebastian Dröge "); + video_decoder_class->open = GST_DEBUG_FUNCPTR (gst_mfc_dec_open); video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_mfc_dec_start); video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_mfc_dec_stop); video_decoder_class->finish = GST_DEBUG_FUNCPTR (gst_mfc_dec_finish); @@ -132,6 +134,28 @@ gst_mfc_dec_init (GstMFCDec * self) gst_video_decoder_set_packetized (decoder, TRUE); } +static gboolean +gst_mfc_dec_open (GstVideoDecoder * decoder) +{ + GstMFCDec *self = GST_MFC_DEC (decoder); + + GST_DEBUG_OBJECT (self, "Opening"); + + /* Just check here once if we can create a MFC context, i.e. + * if the hardware is available + */ + self->context = mfc_dec_create (CODEC_TYPE_H264, 1); + if (!self->context) { + GST_ELEMENT_ERROR (self, LIBRARY, INIT, + ("Failed to initialize MFC decoder context"), (NULL)); + return FALSE; + } + mfc_dec_destroy (self->context); + self->context = NULL; + + return TRUE; +} + static gboolean gst_mfc_dec_start (GstVideoDecoder * decoder) {