After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752116 - adapter: failure of gst_adapter_get_(buffer_)list
adapter: failure of gst_adapter_get_(buffer_)list
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other All
: Normal blocker
: 1.5.90
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-08 11:15 UTC by Hyunjun Ko
Modified: 2015-08-16 13:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adapter: unit test for new get_(buffer_)list (3.62 KB, patch)
2015-07-08 11:18 UTC, Hyunjun Ko
committed Details | Review
adapter: fix to get valid (buffer_)list (3.26 KB, patch)
2015-07-08 14:40 UTC, Hyunjun Ko
none Details | Review
adapter: fix to get valid (buffer_)list (3.29 KB, patch)
2015-07-08 15:24 UTC, Hyunjun Ko
committed Details | Review
adapter: change log message properly (1.93 KB, patch)
2015-07-10 02:04 UTC, Hyunjun Ko
committed Details | Review

Description Hyunjun Ko 2015-07-08 11:15:02 UTC
I made new test unit for these new apis.
But it's failed.
Unless this is wrong test code, it should succeed.
Comment 1 Hyunjun Ko 2015-07-08 11:18:07 UTC
Created attachment 307067 [details] [review]
adapter: unit test for new get_(buffer_)list

IMHO, in gst_adapter_get_buffer_list, in while loop,

cur = adapter->buflist->data;

But cur always points out to the first buffer. Because gst_adapter_get_buffer doesn't flush anything and not update any index(something like adapter->skip)

Does this need to fix?
Comment 2 Sebastian Dröge (slomo) 2015-07-08 11:39:00 UTC
Yes, the test is correct and the adapter code is wrong. Want to provide a patch?
Comment 3 Sebastian Dröge (slomo) 2015-07-08 11:43:10 UTC
Instead of get_buffer(), these functions should iterate over the buffer list themselves I guess. The problem is that the current code assumes that get_buffer() removes the buffer, but that's obviously not correct.
Comment 4 Sebastian Dröge (slomo) 2015-07-08 11:57:03 UTC
Basically it should replicate must of the code in gst_adapter_get_buffer() and iterate longer over the to accumulate all buffers needed.
Comment 5 Hyunjun Ko 2015-07-08 14:40:26 UTC
Created attachment 307076 [details] [review]
adapter: fix to get valid (buffer_)list

get_list/get_buffer_list should be done with buffers in adapter remaining
while take_list/take_buffer_list flushes each buffer one by one.
Comment 6 Sebastian Dröge (slomo) 2015-07-08 14:55:14 UTC
Review of attachment 307076 [details] [review]:

::: libs/gst/base/gstadapter.c
@@ +1101,3 @@
 
+  g = adapter->buflist;
+  skip = adapter->skip;

IIRC skip should be set to 0 after the first buffer is done. It is the number of bytes to skip from the first buffer IIRC.
Comment 7 Hyunjun Ko 2015-07-08 15:24:24 UTC
Created attachment 307084 [details] [review]
adapter: fix to get valid (buffer_)list

Yes. I should've considered the case that skip is non-0. :)
Comment 8 Sebastian Dröge (slomo) 2015-07-08 16:00:57 UTC
commit af62e2874fb2d84b91a6f5510a4ca5a8a0e72139
Author: Hyunjun Ko <zzoon.ko@samsung.com>
Date:   Thu Jul 9 00:21:42 2015 +0900

    adapter: fix to get valid (buffer_)list
    
    get_list/get_buffer_list should be done with buffers in adapter remaining
    while take_list/take_buffer_list flushes each buffer one by one.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=752116

commit 9338f93494c96f810c3abe1b478b59066397275a
Author: Hyunjun Ko <zzoon.ko@samsung.com>
Date:   Wed Jul 8 20:06:27 2015 +0900

    adapter: unit test for new get_(buffer_)list
Comment 9 Olivier Crête 2015-07-08 18:39:02 UTC
Review of attachment 307084 [details] [review]:

::: libs/gst/base/gstadapter.c
@@ +1108,3 @@
     hsize = MIN (nbytes, cur_size - skip);
 
+    if (skip == 0 && cur_size == hsize) {

I think you wan to gst_buffer_ref the buffer ic cur_size <= to hsize, otherwise it will create a new buffer to every buffer except the last one.

@@ +1232,3 @@
     hsize = MIN (nbytes, cur_size - skip);
 
+    if (skip == 0 && cur_size == hsize) {

same here
Comment 10 Hyunjun Ko 2015-07-09 04:49:51 UTC
(In reply to Olivier Crête from comment #9)
> Review of attachment 307084 [details] [review] [review]:
> 
> I think you wan to gst_buffer_ref the buffer ic cur_size <= to hsize,
> otherwise it will create a new buffer to every buffer except the last one.

I want to get ref-buffer only if current gst buffer size equuals hsize.
Otherwise, it will call buffer_copy_region, yes, which is creating new gst buffer.

I don't understand the case that it creates new buffers to all except the last one. If you help me understanding, I'll look into this carefully. :)
Comment 11 Sebastian Dröge (slomo) 2015-07-09 14:17:05 UTC
What Olivier means is that for all buffers except for the last and first you can just return a ref and don't need to copy. We will always take the full buffer for all those. Only the first and last might be partial and might require a gst_buffer_copy_region()
Comment 12 Hyunjun Ko 2015-07-10 02:04:55 UTC
Created attachment 307192 [details] [review]
adapter: change log message properly

Oh. it's about wrong log message.
I think it should be changed.
Thanks for help, Oliver and Sebastian!
Comment 13 Sebastian Dröge (slomo) 2015-07-10 07:46:21 UTC
Actually it's not about the log message, just that Olivier and I were confused :) cur_size is the size of the current buffer, hsize the size of what we have to return from the current buffer. So hsize==cur_size whenever we take the complete buffer, also for middle buffers.