vdpaumpegdec: destroy the VdpDecoder and reset the decoder on state change

This commit is contained in:
Carl-Anton Ingmarsson 2009-04-27 20:50:11 +02:00 committed by Jan Schmidt
parent fb70c1e7b5
commit e737b9a916
2 changed files with 38 additions and 27 deletions

View file

@ -75,28 +75,6 @@ gst_vdp_decoder_push_video_buffer (GstVdpDecoder * dec,
return gst_pad_push (dec->src, GST_BUFFER (buffer));
}
static GstStateChangeReturn
gst_vdp_decoder_change_state (GstElement * element, GstStateChange transition)
{
GstVdpDecoder *dec;
dec = GST_VDP_DECODER (element);
switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
dec->device = gst_vdp_get_device (dec->display_name);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
g_object_unref (dec->device);
dec->device = NULL;
break;
default:
break;
}
return GST_STATE_CHANGE_SUCCESS;
}
static gboolean
gst_vdp_decoder_sink_set_caps (GstPad * pad, GstCaps * caps)
{
@ -182,8 +160,6 @@ gst_vdp_decoder_class_init (GstVdpDecoderClass * klass)
g_object_class_install_property (gobject_class, PROP_DISPLAY,
g_param_spec_string ("display", "Display", "X Display name",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
gstelement_class->change_state = gst_vdp_decoder_change_state;
}
static void
@ -214,9 +190,6 @@ gst_vdp_decoder_finalize (GObject * object)
{
GstVdpDecoder *dec = (GstVdpDecoder *) object;
if (dec->device)
g_object_unref (dec->device);
g_free (dec->display_name);
}

View file

@ -120,6 +120,12 @@ gst_vdp_mpeg_decoder_set_caps (GstVdpDecoder * dec, GstCaps * caps)
&hdr.non_intra_quantizer_matrix, 64);
device = dec->device;
if (mpeg_dec->decoder != VDP_INVALID_HANDLE) {
device->vdp_decoder_destroy (mpeg_dec->decoder);
mpeg_dec->decoder = VDP_INVALID_HANDLE;
}
status = device->vdp_decoder_create (device->device, profile, dec->width,
dec->height, 2, &mpeg_dec->decoder);
if (status != VDP_STATUS_OK) {
@ -499,6 +505,36 @@ gst_vdp_mpeg_decoder_sink_event (GstPad * pad, GstEvent * event)
return res;
}
static GstStateChangeReturn
gst_vdp_mpeg_decoder_change_state (GstElement * element,
GstStateChange transition)
{
GstVdpMpegDecoder *mpeg_dec;
GstVdpDecoder *dec;
mpeg_dec = GST_VDP_MPEG_DECODER (element);
dec = GST_VDP_DECODER (mpeg_dec);
switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
dec->device = gst_vdp_get_device (dec->display_name);
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_vdp_mpeg_decoder_reset (mpeg_dec);
dec->device->vdp_decoder_destroy (mpeg_dec->decoder);
mpeg_dec->decoder = VDP_INVALID_HANDLE;
g_object_unref (dec->device);
dec->device = NULL;
break;
default:
break;
}
return GST_STATE_CHANGE_SUCCESS;
}
/* GObject vmethod implementations */
static void
@ -533,6 +569,8 @@ gst_vdp_mpeg_decoder_class_init (GstVdpMpegDecoderClass * klass)
gobject_class->get_property = gst_vdp_mpeg_decoder_get_property;
vdpaudec_class->set_caps = gst_vdp_mpeg_decoder_set_caps;
gstelement_class->change_state = gst_vdp_mpeg_decoder_change_state;
}
static void