diff options
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpdecoder.c | 7 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpdevice.c | 147 | ||||
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpdevice.h | 2 | ||||
-rw-r--r-- | sys/vdpau/gstvdpau.c | 6 | ||||
-rw-r--r-- | sys/vdpau/gstvdpsink.c | 32 | ||||
-rw-r--r-- | sys/vdpau/gstvdpvideopostprocess.c | 7 |
6 files changed, 102 insertions, 99 deletions
diff --git a/sys/vdpau/gstvdp/gstvdpdecoder.c b/sys/vdpau/gstvdp/gstvdpdecoder.c index 8870398b2..5e14fac44 100644 --- a/sys/vdpau/gstvdp/gstvdpdecoder.c +++ b/sys/vdpau/gstvdp/gstvdpdecoder.c | |||
@@ -186,9 +186,11 @@ gst_vdp_decoder_start (GstBaseVideoDecoder * base_video_decoder) | |||
186 | { | 186 | { |
187 | GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (base_video_decoder); | 187 | GstVdpDecoder *vdp_decoder = GST_VDP_DECODER (base_video_decoder); |
188 | 188 | ||
189 | GError *err; | ||
189 | GstVdpVideoSrcPad *vdp_pad; | 190 | GstVdpVideoSrcPad *vdp_pad; |
190 | 191 | ||
191 | vdp_decoder->device = gst_vdp_get_device (vdp_decoder->display); | 192 | err = NULL; |
193 | vdp_decoder->device = gst_vdp_get_device (vdp_decoder->display, &err); | ||
192 | if (G_UNLIKELY (!vdp_decoder->device)) | 194 | if (G_UNLIKELY (!vdp_decoder->device)) |
193 | goto device_error; | 195 | goto device_error; |
194 | 196 | ||
@@ -201,8 +203,7 @@ gst_vdp_decoder_start (GstBaseVideoDecoder * base_video_decoder) | |||
201 | return TRUE; | 203 | return TRUE; |
202 | 204 | ||
203 | device_error: | 205 | device_error: |
204 | GST_ELEMENT_ERROR (vdp_decoder, RESOURCE, OPEN_READ, | 206 | gst_vdp_decoder_post_error (vdp_decoder, err); |
205 | ("Couldn't create GstVdpDevice"), (NULL)); | ||
206 | return FALSE; | 207 | return FALSE; |
207 | } | 208 | } |
208 | 209 | ||
diff --git a/sys/vdpau/gstvdp/gstvdpdevice.c b/sys/vdpau/gstvdp/gstvdpdevice.c index 8867e4e34..2e441b93c 100644 --- a/sys/vdpau/gstvdp/gstvdpdevice.c +++ b/sys/vdpau/gstvdp/gstvdpdevice.c | |||
@@ -37,39 +37,9 @@ enum | |||
37 | G_DEFINE_TYPE_WITH_CODE (GstVdpDevice, gst_vdp_device, G_TYPE_OBJECT, | 37 | G_DEFINE_TYPE_WITH_CODE (GstVdpDevice, gst_vdp_device, G_TYPE_OBJECT, |
38 | DEBUG_INIT ()); | 38 | DEBUG_INIT ()); |
39 | 39 | ||
40 | static void | 40 | static gboolean |
41 | gst_vdp_device_init (GstVdpDevice * device) | 41 | gst_vdp_device_open (GstVdpDevice * device, GError ** error) |
42 | { | ||
43 | device->display_name = NULL; | ||
44 | device->display = NULL; | ||
45 | device->device = VDP_INVALID_HANDLE; | ||
46 | |||
47 | device->constructed = FALSE; | ||
48 | } | ||
49 | |||
50 | static void | ||
51 | gst_vdp_device_finalize (GObject * object) | ||
52 | { | 42 | { |
53 | GstVdpDevice *device = (GstVdpDevice *) object; | ||
54 | |||
55 | if (device->device != VDP_INVALID_HANDLE) { | ||
56 | device->vdp_device_destroy (device->device); | ||
57 | device->device = VDP_INVALID_HANDLE; | ||
58 | } | ||
59 | if (device->display) { | ||
60 | XCloseDisplay (device->display); | ||
61 | device->display = NULL; | ||
62 | } | ||
63 | g_free (device->display_name); | ||
64 | device->display_name = NULL; | ||
65 | |||
66 | G_OBJECT_CLASS (gst_vdp_device_parent_class)->finalize (object); | ||
67 | } | ||
68 | |||
69 | static void | ||
70 | gst_vdp_device_constructed (GObject * object) | ||
71 | { | ||
72 | GstVdpDevice *device = (GstVdpDevice *) object; | ||
73 | gint screen; | 43 | gint screen; |
74 | VdpStatus status; | 44 | VdpStatus status; |
75 | gint i; | 45 | gint i; |
@@ -135,55 +105,96 @@ gst_vdp_device_constructed (GObject * object) | |||
135 | }; | 105 | }; |
136 | 106 | ||
137 | device->display = XOpenDisplay (device->display_name); | 107 | device->display = XOpenDisplay (device->display_name); |
138 | if (!device->display) { | 108 | if (!device->display) |
139 | GST_ERROR_OBJECT (device, "Could not open X display with name: %s", | 109 | goto create_display_error; |
140 | device->display_name); | ||
141 | return; | ||
142 | } | ||
143 | 110 | ||
144 | screen = DefaultScreen (device->display); | 111 | screen = DefaultScreen (device->display); |
145 | status = | 112 | status = |
146 | vdp_device_create_x11 (device->display, screen, &device->device, | 113 | vdp_device_create_x11 (device->display, screen, &device->device, |
147 | &device->vdp_get_proc_address); | 114 | &device->vdp_get_proc_address); |
148 | if (status != VDP_STATUS_OK) { | 115 | if (status != VDP_STATUS_OK) |
149 | GST_ERROR_OBJECT (device, "Could not create VDPAU device"); | 116 | goto create_device_error; |
150 | device->device = VDP_INVALID_HANDLE; | ||
151 | XCloseDisplay (device->display); | ||
152 | device->display = NULL; | ||
153 | |||
154 | return; | ||
155 | } | ||
156 | 117 | ||
157 | status = device->vdp_get_proc_address (device->device, | 118 | status = device->vdp_get_proc_address (device->device, |
158 | VDP_FUNC_ID_GET_ERROR_STRING, (void **) &device->vdp_get_error_string); | 119 | VDP_FUNC_ID_GET_ERROR_STRING, (void **) &device->vdp_get_error_string); |
159 | if (status != VDP_STATUS_OK) { | 120 | if (status != VDP_STATUS_OK) |
160 | GST_ERROR_OBJECT (device, | 121 | goto get_error_string_error; |
161 | "Could not get vdp_get_error_string function pointer from VDPAU"); | ||
162 | goto error; | ||
163 | } | ||
164 | 122 | ||
165 | for (i = 0; i < G_N_ELEMENTS (vdp_function); i++) { | 123 | for (i = 0; i < G_N_ELEMENTS (vdp_function); i++) { |
166 | status = device->vdp_get_proc_address (device->device, | 124 | status = device->vdp_get_proc_address (device->device, |
167 | vdp_function[i].id, vdp_function[i].func); | 125 | vdp_function[i].id, vdp_function[i].func); |
168 | 126 | ||
169 | if (status != VDP_STATUS_OK) { | 127 | if (status != VDP_STATUS_OK) |
170 | GST_ERROR_OBJECT (device, "Could not get function pointer from VDPAU," | 128 | goto function_error; |
171 | " error returned was: %s", device->vdp_get_error_string (status)); | ||
172 | goto error; | ||
173 | } | ||
174 | } | 129 | } |
175 | 130 | ||
176 | device->constructed = TRUE; | 131 | return TRUE; |
177 | return; | 132 | |
133 | create_display_error: | ||
134 | g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, | ||
135 | "Could not open X display with name: %s", device->display_name); | ||
136 | return FALSE; | ||
178 | 137 | ||
179 | error: | 138 | create_device_error: |
180 | XCloseDisplay (device->display); | 139 | XCloseDisplay (device->display); |
140 | g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, | ||
141 | "Could not create VDPAU device for display: %s", device->display_name); | ||
142 | return FALSE; | ||
143 | |||
144 | get_error_string_error: | ||
145 | XCloseDisplay (device->display); | ||
146 | g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, | ||
147 | "Could not get vdp_get_error_string function pointer from VDPAU"); | ||
148 | return FALSE; | ||
149 | |||
150 | function_error: | ||
151 | XCloseDisplay (device->display); | ||
152 | g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_OPEN_READ, | ||
153 | "Could not get function pointer from VDPAU, error returned was: %s", | ||
154 | device->vdp_get_error_string (status)); | ||
155 | return FALSE; | ||
156 | } | ||
157 | |||
158 | static GstVdpDevice * | ||
159 | gst_vdp_device_new (const gchar * display_name, GError ** error) | ||
160 | { | ||
161 | GstVdpDevice *device; | ||
162 | |||
163 | device = g_object_new (GST_TYPE_VDP_DEVICE, "display", display_name, NULL); | ||
164 | |||
165 | if (!gst_vdp_device_open (device, error)) { | ||
166 | g_object_unref (device); | ||
167 | return NULL; | ||
168 | } | ||
169 | |||
170 | return device; | ||
171 | } | ||
172 | |||
173 | static void | ||
174 | gst_vdp_device_init (GstVdpDevice * device) | ||
175 | { | ||
176 | device->display_name = NULL; | ||
181 | device->display = NULL; | 177 | device->display = NULL; |
178 | device->device = VDP_INVALID_HANDLE; | ||
179 | } | ||
180 | |||
181 | static void | ||
182 | gst_vdp_device_finalize (GObject * object) | ||
183 | { | ||
184 | GstVdpDevice *device = (GstVdpDevice *) object; | ||
182 | 185 | ||
183 | if (device->device != VDP_INVALID_HANDLE) { | 186 | if (device->device != VDP_INVALID_HANDLE) { |
184 | device->vdp_device_destroy (device->device); | 187 | device->vdp_device_destroy (device->device); |
185 | device->device = VDP_INVALID_HANDLE; | 188 | device->device = VDP_INVALID_HANDLE; |
186 | } | 189 | } |
190 | if (device->display) { | ||
191 | XCloseDisplay (device->display); | ||
192 | device->display = NULL; | ||
193 | } | ||
194 | g_free (device->display_name); | ||
195 | device->display_name = NULL; | ||
196 | |||
197 | G_OBJECT_CLASS (gst_vdp_device_parent_class)->finalize (object); | ||
187 | } | 198 | } |
188 | 199 | ||
189 | static void | 200 | static void |
@@ -231,7 +242,6 @@ gst_vdp_device_class_init (GstVdpDeviceClass * klass) | |||
231 | { | 242 | { |
232 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | 243 | GObjectClass *object_class = G_OBJECT_CLASS (klass); |
233 | 244 | ||
234 | object_class->constructed = gst_vdp_device_constructed; | ||
235 | object_class->finalize = gst_vdp_device_finalize; | 245 | object_class->finalize = gst_vdp_device_finalize; |
236 | object_class->get_property = gst_vdp_device_get_property; | 246 | object_class->get_property = gst_vdp_device_get_property; |
237 | object_class->set_property = gst_vdp_device_set_property; | 247 | object_class->set_property = gst_vdp_device_set_property; |
@@ -244,21 +254,6 @@ gst_vdp_device_class_init (GstVdpDeviceClass * klass) | |||
244 | "", G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); | 254 | "", G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); |
245 | } | 255 | } |
246 | 256 | ||
247 | static GstVdpDevice * | ||
248 | gst_vdp_device_new (const gchar * display_name) | ||
249 | { | ||
250 | GstVdpDevice *device; | ||
251 | |||
252 | device = g_object_new (GST_TYPE_VDP_DEVICE, "display", display_name, NULL); | ||
253 | |||
254 | if (!device->constructed) { | ||
255 | g_object_unref (device); | ||
256 | return NULL; | ||
257 | } | ||
258 | |||
259 | return device; | ||
260 | } | ||
261 | |||
262 | typedef struct | 257 | typedef struct |
263 | { | 258 | { |
264 | GHashTable *hash_table; | 259 | GHashTable *hash_table; |
@@ -288,7 +283,7 @@ device_destroyed_cb (gpointer data, GObject * object) | |||
288 | } | 283 | } |
289 | 284 | ||
290 | GstVdpDevice * | 285 | GstVdpDevice * |
291 | gst_vdp_get_device (const gchar * display_name) | 286 | gst_vdp_get_device (const gchar * display_name, GError ** error) |
292 | { | 287 | { |
293 | static gsize once = 0; | 288 | static gsize once = 0; |
294 | static GstVdpDeviceCache device_cache; | 289 | static GstVdpDeviceCache device_cache; |
@@ -310,7 +305,7 @@ gst_vdp_get_device (const gchar * display_name) | |||
310 | device = g_hash_table_lookup (device_cache.hash_table, ""); | 305 | device = g_hash_table_lookup (device_cache.hash_table, ""); |
311 | 306 | ||
312 | if (!device) { | 307 | if (!device) { |
313 | device = gst_vdp_device_new (display_name); | 308 | device = gst_vdp_device_new (display_name, error); |
314 | if (device) { | 309 | if (device) { |
315 | g_object_weak_ref (G_OBJECT (device), device_destroyed_cb, &device_cache); | 310 | g_object_weak_ref (G_OBJECT (device), device_destroyed_cb, &device_cache); |
316 | if (display_name) | 311 | if (display_name) |
diff --git a/sys/vdpau/gstvdp/gstvdpdevice.h b/sys/vdpau/gstvdp/gstvdpdevice.h index df1367524..6010e7554 100644 --- a/sys/vdpau/gstvdp/gstvdpdevice.h +++ b/sys/vdpau/gstvdp/gstvdpdevice.h | |||
@@ -96,7 +96,7 @@ struct _GstVdpDevice | |||
96 | 96 | ||
97 | GType gst_vdp_device_get_type (void); | 97 | GType gst_vdp_device_get_type (void); |
98 | 98 | ||
99 | GstVdpDevice *gst_vdp_get_device (const gchar *display_name); | 99 | GstVdpDevice *gst_vdp_get_device (const gchar *display_name, GError **error); |
100 | 100 | ||
101 | G_END_DECLS | 101 | G_END_DECLS |
102 | 102 | ||
diff --git a/sys/vdpau/gstvdpau.c b/sys/vdpau/gstvdpau.c index 7e47e85a1..2ec57afb4 100644 --- a/sys/vdpau/gstvdpau.c +++ b/sys/vdpau/gstvdpau.c | |||
@@ -22,11 +22,11 @@ vdpau_init (GstPlugin * vdpau_plugin) | |||
22 | gst_element_register (vdpau_plugin, "vdpaumpegdec", | 22 | gst_element_register (vdpau_plugin, "vdpaumpegdec", |
23 | GST_RANK_NONE, GST_TYPE_VDP_MPEG_DEC); | 23 | GST_RANK_NONE, GST_TYPE_VDP_MPEG_DEC); |
24 | gst_element_register (vdpau_plugin, "vdpauh264dec", | 24 | gst_element_register (vdpau_plugin, "vdpauh264dec", |
25 | GST_RANK_NONE, GST_TYPE_VDP_H264_DEC); | 25 | GST_RANK_PRIMARY, GST_TYPE_VDP_H264_DEC); |
26 | gst_element_register (vdpau_plugin, "vdpauvideopostprocess", | 26 | gst_element_register (vdpau_plugin, "vdpauvideopostprocess", |
27 | GST_RANK_MARGINAL, GST_TYPE_VDP_VIDEO_POST_PROCESS); | 27 | GST_RANK_PRIMARY, GST_TYPE_VDP_VIDEO_POST_PROCESS); |
28 | gst_element_register (vdpau_plugin, "vdpausink", | 28 | gst_element_register (vdpau_plugin, "vdpausink", |
29 | GST_RANK_NONE, GST_TYPE_VDP_SINK); | 29 | GST_RANK_PRIMARY, GST_TYPE_VDP_SINK); |
30 | 30 | ||
31 | return TRUE; | 31 | return TRUE; |
32 | } | 32 | } |
diff --git a/sys/vdpau/gstvdpsink.c b/sys/vdpau/gstvdpsink.c index 70bcd6bfe..2f7c5d059 100644 --- a/sys/vdpau/gstvdpsink.c +++ b/sys/vdpau/gstvdpsink.c | |||
@@ -569,14 +569,26 @@ gst_vdp_sink_get_allowed_caps (GstVdpDevice * device, GValue * par) | |||
569 | return caps; | 569 | return caps; |
570 | } | 570 | } |
571 | 571 | ||
572 | static void | ||
573 | gst_vdp_sink_post_error (VdpSink * vdp_sink, GError * error) | ||
574 | { | ||
575 | GstMessage *message; | ||
576 | |||
577 | message = gst_message_new_error (GST_OBJECT (vdp_sink), error, NULL); | ||
578 | gst_element_post_message (GST_ELEMENT (vdp_sink), message); | ||
579 | g_error_free (error); | ||
580 | } | ||
581 | |||
572 | static gboolean | 582 | static gboolean |
573 | gst_vdp_sink_open_device (VdpSink * vdp_sink) | 583 | gst_vdp_sink_open_device (VdpSink * vdp_sink) |
574 | { | 584 | { |
575 | GstVdpDevice *device; | 585 | GstVdpDevice *device; |
586 | GError *err; | ||
576 | 587 | ||
577 | vdp_sink->device = device = gst_vdp_get_device (vdp_sink->display_name); | 588 | err = NULL; |
578 | if (!vdp_sink->device) | 589 | vdp_sink->device = device = gst_vdp_get_device (vdp_sink->display_name, &err); |
579 | return FALSE; | 590 | if (!device) |
591 | goto device_error; | ||
580 | 592 | ||
581 | vdp_sink->bpool = gst_vdp_output_buffer_pool_new (device); | 593 | vdp_sink->bpool = gst_vdp_output_buffer_pool_new (device); |
582 | 594 | ||
@@ -594,6 +606,10 @@ gst_vdp_sink_open_device (VdpSink * vdp_sink) | |||
594 | (GThreadFunc) gst_vdp_sink_event_thread, vdp_sink, TRUE, NULL); | 606 | (GThreadFunc) gst_vdp_sink_event_thread, vdp_sink, TRUE, NULL); |
595 | 607 | ||
596 | return TRUE; | 608 | return TRUE; |
609 | |||
610 | device_error: | ||
611 | gst_vdp_sink_post_error (vdp_sink, err); | ||
612 | return FALSE; | ||
597 | } | 613 | } |
598 | 614 | ||
599 | static gboolean | 615 | static gboolean |
@@ -898,16 +914,6 @@ gst_vdp_sink_event (GstBaseSink * sink, GstEvent * event) | |||
898 | return TRUE; | 914 | return TRUE; |
899 | } | 915 | } |
900 | 916 | ||
901 | static void | ||
902 | gst_vdp_sink_post_error (VdpSink * vdp_sink, GError * error) | ||
903 | { | ||
904 | GstMessage *message; | ||
905 | |||
906 | message = gst_message_new_error (GST_OBJECT (vdp_sink), error, NULL); | ||
907 | gst_element_post_message (GST_ELEMENT (vdp_sink), message); | ||
908 | g_error_free (error); | ||
909 | } | ||
910 | |||
911 | /* Buffer management | 917 | /* Buffer management |
912 | * | 918 | * |
913 | * The buffer_alloc function must either return a buffer with given size and | 919 | * The buffer_alloc function must either return a buffer with given size and |
diff --git a/sys/vdpau/gstvdpvideopostprocess.c b/sys/vdpau/gstvdpvideopostprocess.c index 4658f901d..adaabf4bc 100644 --- a/sys/vdpau/gstvdpvideopostprocess.c +++ b/sys/vdpau/gstvdpvideopostprocess.c | |||
@@ -596,6 +596,7 @@ static gboolean | |||
596 | gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) | 596 | gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) |
597 | { | 597 | { |
598 | gint i; | 598 | gint i; |
599 | GError *err; | ||
599 | 600 | ||
600 | vpp->interlaced = FALSE; | 601 | vpp->interlaced = FALSE; |
601 | vpp->field_duration = GST_CLOCK_TIME_NONE; | 602 | vpp->field_duration = GST_CLOCK_TIME_NONE; |
@@ -613,7 +614,8 @@ gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) | |||
613 | vpp->n_future_pictures = 0; | 614 | vpp->n_future_pictures = 0; |
614 | vpp->n_past_pictures = 0; | 615 | vpp->n_past_pictures = 0; |
615 | 616 | ||
616 | vpp->device = gst_vdp_get_device (vpp->display); | 617 | err = NULL; |
618 | vpp->device = gst_vdp_get_device (vpp->display, &err); | ||
617 | if (G_UNLIKELY (!vpp->device)) | 619 | if (G_UNLIKELY (!vpp->device)) |
618 | goto device_error; | 620 | goto device_error; |
619 | 621 | ||
@@ -622,8 +624,7 @@ gst_vdp_vpp_start (GstVdpVideoPostProcess * vpp) | |||
622 | return TRUE; | 624 | return TRUE; |
623 | 625 | ||
624 | device_error: | 626 | device_error: |
625 | GST_ELEMENT_ERROR (vpp, RESOURCE, OPEN_READ, | 627 | gst_vdp_vpp_post_error (vpp, err); |
626 | ("Couldn't create GstVdpDevice"), (NULL)); | ||
627 | return FALSE; | 628 | return FALSE; |
628 | } | 629 | } |
629 | 630 | ||