tests: cope with new GstVaapiMiniObject objects.

This commit is contained in:
Gwenole Beauchesne 2013-05-07 11:45:10 +02:00
parent 98bee4240f
commit da403b62d0
10 changed files with 59 additions and 97 deletions

View file

@ -62,18 +62,16 @@ find_codec_defs(const gchar *codec_str)
return NULL; return NULL;
} }
#define CODEC_DEFS_KEY "codec-defs"
static inline const CodecDefs * static inline const CodecDefs *
get_codec_defs(GstVaapiDecoder *decoder) get_codec_defs(GstVaapiDecoder *decoder)
{ {
return g_object_get_data(G_OBJECT(decoder), CODEC_DEFS_KEY); return gst_vaapi_decoder_get_user_data(decoder);
} }
static inline void static inline void
set_codec_defs(GstVaapiDecoder *decoder, const CodecDefs *c) set_codec_defs(GstVaapiDecoder *decoder, const CodecDefs *c)
{ {
g_object_set_data(G_OBJECT(decoder), CODEC_DEFS_KEY, (gpointer)c); gst_vaapi_decoder_set_user_data(decoder, (gpointer)c);
} }
GstVaapiDecoder * GstVaapiDecoder *

View file

@ -43,7 +43,7 @@ image_generate(
image_draw_rectangle(image, w/2, h/2, w/2, h/2, 0xff000000)) image_draw_rectangle(image, w/2, h/2, w/2, h/2, 0xff000000))
return image; return image;
g_object_unref(image); gst_vaapi_object_unref(image);
return NULL; return NULL;
} }
@ -355,6 +355,6 @@ image_upload(GstVaapiImage *image, GstVaapiSurface *surface)
g_error("could not associate subpicture to surface"); g_error("could not associate subpicture to surface");
/* The surface holds a reference to the subpicture. This is safe */ /* The surface holds a reference to the subpicture. This is safe */
g_object_unref(subpicture); gst_vaapi_object_unref(subpicture);
return TRUE; return TRUE;
} }

View file

@ -167,7 +167,7 @@ video_output_create_display(const gchar *display_name)
if (display) { if (display) {
if (gst_vaapi_display_get_display(display)) if (gst_vaapi_display_get_display(display))
break; break;
g_object_unref(display); gst_vaapi_display_unref(display);
display = NULL; display = NULL;
} }
} }

View file

@ -331,16 +331,13 @@ app_set_framerate(App *app, guint fps_n, guint fps_d)
} }
static void static void
handle_decoder_caps(GObject *obj, GParamSpec *pspec, void *user_data) handle_decoder_state_changes(GstVaapiDecoder *decoder,
const GstVideoCodecState *codec_state, gpointer user_data)
{ {
App * const app = user_data; App * const app = user_data;
GstVideoCodecState *codec_state;
g_assert(app->decoder == GST_VAAPI_DECODER(obj)); g_assert(app->decoder == decoder);
codec_state = gst_vaapi_decoder_get_codec_state(app->decoder);
app_set_framerate(app, codec_state->info.fps_n, codec_state->info.fps_d); app_set_framerate(app, codec_state->info.fps_n, codec_state->info.fps_d);
gst_video_codec_state_unref(codec_state);
} }
static gboolean static gboolean
@ -383,8 +380,8 @@ start_decoder(App *app)
if (!app->decoder) if (!app->decoder)
return FALSE; return FALSE;
g_signal_connect(G_OBJECT(app->decoder), "notify::caps", gst_vaapi_decoder_set_codec_state_changed_func(app->decoder,
G_CALLBACK(handle_decoder_caps), app); handle_decoder_state_changes, app);
g_timer_start(app->timer); g_timer_start(app->timer);
@ -538,9 +535,9 @@ app_free(App *app)
} }
g_free(app->file_name); g_free(app->file_name);
g_clear_object(&app->decoder); gst_vaapi_decoder_replace(&app->decoder, NULL);
g_clear_object(&app->window); gst_vaapi_window_replace(&app->window, NULL);
g_clear_object(&app->display); gst_vaapi_display_replace(&app->display, NULL);
if (app->decoder_queue) { if (app->decoder_queue) {
g_async_queue_unref(app->decoder_queue); g_async_queue_unref(app->decoder_queue);

View file

@ -68,7 +68,7 @@ main(int argc, char *argv[])
if (CHECK_DISPLAY_CACHE) if (CHECK_DISPLAY_CACHE)
display2 = video_output_create_display(NULL); display2 = video_output_create_display(NULL);
else else
display2 = g_object_ref(display); display2 = gst_vaapi_display_ref(display);
if (!display2) if (!display2)
g_error("could not create second VA display"); g_error("could not create second VA display");
@ -97,10 +97,10 @@ main(int argc, char *argv[])
pause(); pause();
g_object_unref(decoder); gst_vaapi_decoder_unref(decoder);
g_object_unref(window); gst_vaapi_window_unref(window);
g_object_unref(display); gst_vaapi_display_unref(display);
g_object_unref(display2); gst_vaapi_display_unref(display2);
g_free(g_codec_str); g_free(g_codec_str);
video_output_exit(); video_output_exit();
return 0; return 0;

View file

@ -179,17 +179,6 @@ free_property_cb(gpointer data, gpointer user_data)
gst_vaapi_display_property_free(data); gst_vaapi_display_property_free(data);
} }
static inline GParamSpec *
get_display_property(GstVaapiDisplay *display, const gchar *name)
{
GObjectClass *klass;
klass = G_OBJECT_CLASS(GST_VAAPI_DISPLAY_GET_CLASS(display));
if (!klass)
return NULL;
return g_object_class_find_property(klass, name);
}
static void static void
dump_properties(GstVaapiDisplay *display) dump_properties(GstVaapiDisplay *display)
{ {
@ -212,25 +201,21 @@ dump_properties(GstVaapiDisplay *display)
return; return;
for (i = 0; g_properties[i] != NULL; i++) { for (i = 0; g_properties[i] != NULL; i++) {
GParamSpec *pspec = get_display_property(display, g_properties[i]); const gchar * const name = g_properties[i];
if (!pspec) { if (!gst_vaapi_display_has_property(display, name))
GST_ERROR("failed to find GstVaapiDisplay property '%s'",
g_properties[i]);
goto end;
}
if (!gst_vaapi_display_has_property(display, pspec->name))
continue; continue;
prop = gst_vaapi_display_property_new(pspec->name); prop = gst_vaapi_display_property_new(name);
if (!prop) { if (!prop) {
GST_ERROR("failed to allocate GstVaapiDisplayProperty"); GST_ERROR("failed to allocate GstVaapiDisplayProperty");
goto end; goto end;
} }
g_value_init(&prop->value, pspec->value_type); if (!gst_vaapi_display_get_property(display, name, &prop->value)) {
g_object_get_property(G_OBJECT(display), pspec->name, &prop->value); GST_ERROR("failed to get property '%s'", name);
goto end;
}
g_ptr_array_add(properties, prop); g_ptr_array_add(properties, prop);
} }
@ -301,7 +286,7 @@ main(int argc, char *argv[])
g_error("could not create Gst/VA display"); g_error("could not create Gst/VA display");
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
} }
g_print("\n"); g_print("\n");
@ -320,7 +305,7 @@ main(int argc, char *argv[])
g_error("could not create Gst/VA display"); g_error("could not create Gst/VA display");
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
close(drm_device); close(drm_device);
} }
g_print("\n"); g_print("\n");
@ -345,7 +330,7 @@ main(int argc, char *argv[])
g_error("could not create Gst/VA display"); g_error("could not create Gst/VA display");
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
close(drm_device); close(drm_device);
} }
g_print("\n"); g_print("\n");
@ -367,7 +352,7 @@ main(int argc, char *argv[])
g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d); g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
} }
g_print("\n"); g_print("\n");
@ -386,7 +371,7 @@ main(int argc, char *argv[])
g_error("could not create Gst/VA display"); g_error("could not create Gst/VA display");
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
XCloseDisplay(x11_display); XCloseDisplay(x11_display);
} }
g_print("\n"); g_print("\n");
@ -411,7 +396,7 @@ main(int argc, char *argv[])
g_error("could not create Gst/VA display"); g_error("could not create Gst/VA display");
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
XCloseDisplay(x11_display); XCloseDisplay(x11_display);
} }
g_print("\n"); g_print("\n");
@ -433,7 +418,7 @@ main(int argc, char *argv[])
g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d); g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
} }
g_print("\n"); g_print("\n");
@ -452,7 +437,7 @@ main(int argc, char *argv[])
g_error("could not create Gst/VA display"); g_error("could not create Gst/VA display");
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
XCloseDisplay(x11_display); XCloseDisplay(x11_display);
} }
g_print("\n"); g_print("\n");
@ -478,7 +463,7 @@ main(int argc, char *argv[])
g_error("could not create Gst/VA display"); g_error("could not create Gst/VA display");
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
XCloseDisplay(x11_display); XCloseDisplay(x11_display);
} }
g_print("\n"); g_print("\n");
@ -501,7 +486,7 @@ main(int argc, char *argv[])
g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d); g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
dump_info(display); dump_info(display);
g_object_unref(display); gst_vaapi_display_unref(display);
} }
g_print("\n"); g_print("\n");
#endif #endif

View file

@ -171,9 +171,9 @@ main(int argc, char *argv[])
pause(); pause();
gst_video_overlay_composition_unref(compo); gst_video_overlay_composition_unref(compo);
g_object_unref(decoder); gst_vaapi_decoder_unref(decoder);
g_object_unref(window); gst_vaapi_window_unref(window);
g_object_unref(display); gst_vaapi_display_unref(display);
g_free(g_codec_str); g_free(g_codec_str);
video_output_exit(); video_output_exit();
return 0; return 0;

View file

@ -26,12 +26,6 @@
#define MAX_SURFACES 4 #define MAX_SURFACES 4
static void
gst_vaapi_object_destroy_cb(gpointer object, gpointer user_data)
{
g_print("destroying GstVaapiObject %p\n", object);
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@ -58,14 +52,11 @@ main(int argc, char *argv[])
if (!surface) if (!surface)
g_error("could not create Gst/VA surface"); g_error("could not create Gst/VA surface");
/* This also tests for the GstVaapiParamSpecID */ surface_id = gst_vaapi_surface_get_id(surface);
g_object_get(G_OBJECT(surface), "id", &surface_id, NULL);
if (surface_id != gst_vaapi_surface_get_id(surface))
g_error("could not retrieve the native surface ID");
g_print("created surface %" GST_VAAPI_ID_FORMAT "\n", g_print("created surface %" GST_VAAPI_ID_FORMAT "\n",
GST_VAAPI_ID_ARGS(surface_id)); GST_VAAPI_ID_ARGS(surface_id));
g_object_unref(surface); gst_vaapi_object_unref(surface);
caps = gst_caps_new_simple( caps = gst_caps_new_simple(
GST_VAAPI_SURFACE_CAPS_NAME, GST_VAAPI_SURFACE_CAPS_NAME,
@ -91,7 +82,7 @@ main(int argc, char *argv[])
} }
/* Check the pool doesn't return the last free'd surface */ /* Check the pool doesn't return the last free'd surface */
surface = g_object_ref(surfaces[1]); surface = gst_vaapi_object_ref(surfaces[1]);
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
gst_vaapi_video_pool_put_object(pool, surfaces[i]); gst_vaapi_video_pool_put_object(pool, surfaces[i]);
@ -114,20 +105,11 @@ main(int argc, char *argv[])
surfaces[i] = NULL; surfaces[i] = NULL;
} }
g_signal_connect(
G_OBJECT(surface),
"destroy",
G_CALLBACK(gst_vaapi_object_destroy_cb), NULL
);
/* Unref in random order to check objects are correctly refcounted */ /* Unref in random order to check objects are correctly refcounted */
g_print("unref display\n"); gst_vaapi_display_unref(display);
g_object_unref(display);
gst_caps_unref(caps); gst_caps_unref(caps);
g_print("unref pool\n"); gst_vaapi_video_pool_unref(pool);
g_object_unref(pool); gst_vaapi_object_unref(surface);
g_print("unref surface\n");
g_object_unref(surface);
video_output_exit(); video_output_exit();
return 0; return 0;
} }

View file

@ -182,12 +182,12 @@ main(int argc, char *argv[])
gst_vaapi_window_glx_swap_buffers(glx_window); gst_vaapi_window_glx_swap_buffers(glx_window);
pause(); pause();
g_object_unref(textures[0]); gst_vaapi_texture_unref(textures[0]);
g_object_unref(textures[1]); gst_vaapi_texture_unref(textures[1]);
glDeleteTextures(1, &texture_id); glDeleteTextures(1, &texture_id);
g_object_unref(window); gst_vaapi_window_unref(window);
g_object_unref(display); gst_vaapi_display_unref(display);
gst_deinit(); gst_deinit();
return 0; return 0;
} }

View file

@ -83,7 +83,7 @@ create_test_surface(GstVaapiDisplay *display, guint width, guint height)
if (!gst_vaapi_surface_sync(surface)) if (!gst_vaapi_surface_sync(surface))
g_error("could not complete image upload"); g_error("could not complete image upload");
g_object_unref(image); gst_vaapi_object_unref(image);
return surface; return surface;
} }
@ -125,11 +125,11 @@ main(int argc, char *argv[])
g_error("could not render surface"); g_error("could not render surface");
pause(); pause();
g_object_unref(window); gst_vaapi_window_unref(window);
} }
g_object_unref(surface); gst_vaapi_object_unref(surface);
g_object_unref(display); gst_vaapi_display_unref(display);
#endif #endif
#if USE_X11 #if USE_X11
@ -155,7 +155,7 @@ main(int argc, char *argv[])
g_error("could not render surface"); g_error("could not render surface");
pause(); pause();
g_object_unref(window); gst_vaapi_window_unref(window);
} }
g_print("#\n"); g_print("#\n");
@ -192,13 +192,13 @@ main(int argc, char *argv[])
g_error("could not render surface"); g_error("could not render surface");
pause(); pause();
g_object_unref(window); gst_vaapi_window_unref(window);
XUnmapWindow(dpy, win); XUnmapWindow(dpy, win);
XDestroyWindow(dpy, win); XDestroyWindow(dpy, win);
} }
g_object_unref(surface); gst_vaapi_object_unref(surface);
g_object_unref(display); gst_vaapi_display_unref(display);
#endif #endif
#if USE_WAYLAND #if USE_WAYLAND
@ -224,11 +224,11 @@ main(int argc, char *argv[])
g_error("could not render surface"); g_error("could not render surface");
pause(); pause();
g_object_unref(window); gst_vaapi_window_unref(window);
} }
g_object_unref(surface); gst_vaapi_object_unref(surface);
g_object_unref(display); gst_vaapi_display_unref(display);
#endif #endif
gst_deinit(); gst_deinit();