From: Hyunil Date: Fri, 18 Dec 2015 06:58:45 +0000 (+0900) Subject: Waylandsink : fix tearing issue X-Git-Tag: accepted/tizen/unified/20220217.153506~2^2~10^2~9^2~12^2~2^2~223 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6dfe540d396258c93f1b39228444cfa03877ae9c;p=platform%2Fupstream%2Fgstreamer.git Waylandsink : fix tearing issue Change-Id: I46e3428840c5f5886e0b327ba3c09ce4601add24 Signed-off-by: Hyunil --- diff --git a/ext/wayland/gstwaylandsink.c b/ext/wayland/gstwaylandsink.c index d36f802..a51facb 100755 --- a/ext/wayland/gstwaylandsink.c +++ b/ext/wayland/gstwaylandsink.c @@ -827,14 +827,12 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) goto no_window_size; #ifdef GST_WLSINK_ENHANCEMENT - sink->display->tbm_need_limit_idx = FALSE; wlbuffer = gst_buffer_get_wl_buffer (buffer); if (G_LIKELY (wlbuffer && wlbuffer->display == sink->display)) { - GST_LOG_OBJECT (sink, "buffer %p has a wl_buffer from our display, " "writing directly", buffer); // s/w codec case + GST_LOG_OBJECT (sink, "buffer %p has a wl_buffer from our display, " "writing directly", buffer); //buffer is from our pool and have wl_buffer GST_INFO ("wl_buffer (%p)", wlbuffer->wlbuffer); to_render = buffer; - #ifdef DUMP_BUFFER GstMemory *mem; GstMapInfo mem_info = GST_MAP_INFO_INIT; @@ -859,25 +857,25 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) GstMemory *mem; struct wl_buffer *wbuf = NULL; - GST_LOG_OBJECT (sink, "buffer %p does not have a wl_buffer from our " "display, creating it", buffer); //videotestsrc case , s/w codec too + GST_LOG_OBJECT (sink, "buffer %p does not have a wl_buffer from our " "display, creating it", buffer); //buffer is from our pool but have not wl_buffer mem = gst_buffer_peek_memory (buffer, 0); if (gst_is_wl_shm_memory (mem)) { FUNCTION; wbuf = gst_wl_shm_memory_construct_wl_buffer (mem, sink->display, &sink->video_info); - } - if (wbuf) { - gst_buffer_add_wl_buffer (buffer, wbuf, sink->display); //careat GstWlBuffer and add gstbuffer, wlbuffer, display and etc - to_render = buffer; - - } else { + if (wbuf) { + gst_buffer_add_wl_buffer (buffer, wbuf, sink->display); //careat GstWlBuffer and add gstbuffer, wlbuffer, display and etc + to_render = buffer; + } + } else { //buffer is not from our pool and have not wl_buffer GstMapInfo src; /* we don't know how to create a wl_buffer directly from the provided * memory, so we have to copy the data to a memory that we know how * to handle... */ GST_LOG_OBJECT (sink, "buffer %p is not from our pool", buffer); - GST_LOG_OBJECT (sink, "buffer %p cannot have a wl_buffer, " "copying", buffer); //omx codec case + GST_LOG_OBJECT (sink, "buffer %p cannot have a wl_buffer, " "copying", + buffer); if (sink->USE_TBM && sink->display->is_native_format) { /* in case of SN12 or ST12 */ @@ -925,9 +923,9 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) gst_buffer_add_wl_buffer (buffer, wbuf, sink->display); } - } else if (sink->USE_TBM && !sink->display->is_native_format) { + } - sink->display->tbm_need_limit_idx = TRUE; + else if (sink->USE_TBM && !sink->display->is_native_format) { /* sink->pool always exists (created in set_caps), but it may not * be active if upstream is not using it */ @@ -980,6 +978,7 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) goto no_wl_buffer; gst_buffer_add_wl_buffer (to_render, wbuf, sink->display); + } gst_buffer_map (buffer, &src, GST_MAP_READ); @@ -1048,7 +1047,8 @@ gst_wayland_sink_render (GstBaseSink * bsink, GstBuffer * buffer) * to handle... */ GST_LOG_OBJECT (sink, "buffer %p is not from our pool", buffer); - GST_LOG_OBJECT (sink, "buffer %p cannot have a wl_buffer, " "copying", buffer); //omx codec case + GST_LOG_OBJECT (sink, "buffer %p cannot have a wl_buffer, " "copying", + buffer); /* sink->pool always exists (created in set_caps), but it may not * be active if upstream is not using it */ if (!gst_buffer_pool_is_active (sink->pool) && diff --git a/ext/wayland/wlbuffer.c b/ext/wayland/wlbuffer.c index 6cb4dfd..e089794 100644 --- a/ext/wayland/wlbuffer.c +++ b/ext/wayland/wlbuffer.c @@ -196,7 +196,6 @@ gst_buffer_add_wl_buffer (GstBuffer * gstbuffer, struct wl_buffer *wlbuffer, gst_mini_object_set_qdata ((GstMiniObject *) gstbuffer, gst_wl_buffer_qdata_quark (), self, (GDestroyNotify) gstbuffer_disposed); - GST_INFO ("GstWlBuffer (%p)", self); return self; } @@ -256,5 +255,6 @@ gst_wl_buffer_attach (GstWlBuffer * self, struct wl_surface *surface) * the compositor is using the buffer and it should not return * back to the pool and be re-used until the compositor releases it. */ gst_buffer_ref (self->gstbuffer); + self->used_by_compositor = TRUE; } diff --git a/ext/wayland/wldisplay.c b/ext/wayland/wldisplay.c index 372d28e..4b7916e 100644 --- a/ext/wayland/wldisplay.c +++ b/ext/wayland/wldisplay.c @@ -80,10 +80,7 @@ gst_wl_display_init (GstWlDisplay * self) self->buffers = g_hash_table_new (g_direct_hash, g_direct_equal); g_mutex_init (&self->buffers_mutex); #ifdef GST_WLSINK_ENHANCEMENT - self->tbm_bo_c_idx = 0; - self->tbm_bo_u_idx = 0; - self->tbm_need_limit_idx = FALSE; - self->tbm_bo_max_idx = TBM_BO_MAX_IDX; + self->tbm_bo_idx = 0; #endif } diff --git a/ext/wayland/wldisplay.h b/ext/wayland/wldisplay.h index f11e2bd..363d714 100644 --- a/ext/wayland/wldisplay.h +++ b/ext/wayland/wldisplay.h @@ -80,10 +80,7 @@ struct _GstWlDisplay struct wayland_tbm_client *tbm_client; tbm_bufmgr tbm_bufmgr; tbm_bo tbm_bo[TBM_BO_NUM]; - int tbm_bo_c_idx; - int tbm_bo_u_idx; - gboolean tbm_need_limit_idx; - int tbm_bo_max_idx; + int tbm_bo_idx; tbm_surface_h tsurface; gboolean USE_TBM; diff --git a/ext/wayland/wlshmallocator.c b/ext/wayland/wlshmallocator.c index ded64b9..5522762 100644 --- a/ext/wayland/wlshmallocator.c +++ b/ext/wayland/wlshmallocator.c @@ -57,11 +57,8 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size, #ifdef GST_WLSINK_ENHANCEMENT if (self->display->USE_TBM) { tbm_bo_handle virtual_addr; - if (self->display->tbm_need_limit_idx - && self->display->tbm_bo_c_idx == self->display->tbm_bo_max_idx) - self->display->tbm_bo_c_idx = 0; - idx = self->display->tbm_bo_c_idx++; + idx = self->display->tbm_bo_idx++; self->display->tbm_bufmgr = wayland_tbm_client_get_bufmgr (self->display->tbm_client); @@ -82,7 +79,7 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size, GST_ERROR_OBJECT (self, "get tbm bo handle failed: %s", strerror (errno)); tbm_bo_unref (self->display->tbm_bo[idx]); self->display->tbm_bo[idx] = NULL; - self->display->tbm_bo_c_idx--; + self->display->tbm_bo_idx--; return FALSE; } @@ -90,6 +87,7 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size, gst_memory_init ((GstMemory *) mem, GST_MEMORY_FLAG_NO_SHARE, allocator, NULL, size, 0, 0, size); mem->data = virtual_addr.ptr; + mem->tbm_bo_ptr = self->display->tbm_bo[idx]; GST_INFO ("mem(%p) mem->data(%p) virtual_addr.ptr(%p) size(%d)", mem, mem->data, virtual_addr.ptr, size); @@ -97,7 +95,7 @@ gst_wl_shm_allocator_alloc (GstAllocator * allocator, gsize size, } else { /* USE SHM */ /* TODO: make use of the allocation params, if necessary */ - GST_ERROR ("1"); + /* allocate shm pool */ snprintf (filename, 1024, "%s/%s-%d-%s", g_get_user_runtime_dir (), "wayland-shm", init++, "XXXXXX"); @@ -309,12 +307,7 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display, wayland_tbm_client_create_buffer (display->tbm_client, display->tsurface); } else { - int idx; - if (display->tbm_need_limit_idx - && display->tbm_bo_u_idx == display->tbm_bo_max_idx) - display->tbm_bo_u_idx = 0; - idx = display->tbm_bo_u_idx++; width = GST_VIDEO_INFO_WIDTH (info); height = GST_VIDEO_INFO_HEIGHT (info); stride = GST_VIDEO_INFO_PLANE_STRIDE (info, 0); @@ -330,7 +323,7 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display, height, stride, gst_wl_tbm_format_to_string (format)); #ifdef DUMP_BUFFER - virtual_addr = tbm_bo_get_handle (display->tbm_bo[idx], TBM_DEVICE_CPU); + virtual_addr = tbm_bo_get_handle (shm_mem->tbm_bo_ptr, TBM_DEVICE_CPU); if (!virtual_addr.ptr) { GST_ERROR ("get tbm bo handle failed: %s", strerror (errno)); return FALSE; @@ -359,10 +352,10 @@ gst_wl_shm_memory_construct_wl_buffer (GstMemory * mem, GstWlDisplay * display, ts_info.planes[1].offset = GST_VIDEO_INFO_PLANE_OFFSET (info, 1); ts_info.planes[2].offset = GST_VIDEO_INFO_PLANE_OFFSET (info, 2); - GST_INFO ("display->tbm_bo (%p)", display->tbm_bo[idx]); + GST_INFO ("tbm_bo (%p)", shm_mem->tbm_bo_ptr); display->tsurface = - tbm_surface_internal_create_with_bos (&ts_info, &display->tbm_bo[idx], + tbm_surface_internal_create_with_bos (&ts_info, &shm_mem->tbm_bo_ptr, 1); wbuffer = wayland_tbm_client_create_buffer (display->tbm_client, diff --git a/ext/wayland/wlshmallocator.h b/ext/wayland/wlshmallocator.h index 2739371..1a5ed27 100644 --- a/ext/wayland/wlshmallocator.h +++ b/ext/wayland/wlshmallocator.h @@ -45,6 +45,9 @@ struct _GstWlShmMemory gpointer data; gint fd; +#ifdef GST_WLSINK_ENHANCEMENT + gpointer tbm_bo_ptr; +#endif }; struct _GstWlShmAllocator