gnu: gstreamer: Fix buffer offset problem.
[jackhill/guix/guix.git] / gnu / packages / patches / gstreamer-buffer-reset-offset.patch
1 Fix a buffer offset problem in GStreamer 1.16. Initially reported by Mark H.
2 Weaver in <https://lists.gnu.org/archive/html/guix-devel/2019-06/msg00140.html>.
3
4 See also <https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/316>.
5
6 From 1734c9fc1a4f99b165383ae1eb02f04e0844a00c Mon Sep 17 00:00:00 2001
7 From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
8 Date: Sat, 29 Jun 2019 09:22:05 -0400
9 Subject: [PATCH] bufferpool: Fix the buffer size reset code
10
11 The offset in gst_buffer_resize() is additive. So to move back the
12 offset to zero, we need to pass the opposite of the current offset. This
13 was raised through the related unit test failingon 32bit as on 64bit
14 the alignment padding was enough to hide the issue. The test was
15 modified to also fail on 64bit. This patch will remove spurious
16 assertions like:
17
18 assertion 'bufmax >= bufoffs + offset + size' failed
19
20 Fixes #316
21 ---
22 gst/gstbufferpool.c | 7 +++++--
23 tests/check/gst/gstbufferpool.c | 2 +-
24 2 files changed, 6 insertions(+), 3 deletions(-)
25
26 diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c
27 index e5c7a5872..619860e63 100644
28 --- a/gst/gstbufferpool.c
29 +++ b/gst/gstbufferpool.c
30 @@ -1222,8 +1222,11 @@ default_reset_buffer (GstBufferPool * pool, GstBuffer * buffer)
31 GST_BUFFER_OFFSET_END (buffer) = GST_BUFFER_OFFSET_NONE;
32
33 /* if the memory is intact reset the size to the full size */
34 - if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY))
35 - gst_buffer_resize (buffer, 0, pool->priv->size);
36 + if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_TAG_MEMORY)) {
37 + gsize offset;
38 + gst_buffer_get_sizes (buffer, &offset, NULL);
39 + gst_buffer_resize (buffer, -offset, pool->priv->size);
40 + }
41
42 /* remove all metadata without the POOLED flag */
43 gst_buffer_foreach_meta (buffer, remove_meta_unpooled, pool);
44 diff --git a/tests/check/gst/gstbufferpool.c b/tests/check/gst/gstbufferpool.c
45 index f0c3c8d8e..dd9b2dc03 100644
46 --- a/tests/check/gst/gstbufferpool.c
47 +++ b/tests/check/gst/gstbufferpool.c
48 @@ -190,7 +190,7 @@ GST_START_TEST (test_buffer_modify_discard)
49 gst_buffer_pool_acquire_buffer (pool, &buf, NULL);
50 buffer_track_destroy (buf, &dcount);
51 /* do resize, as we didn't modify the memory, pool should reuse this buffer */
52 - gst_buffer_resize (buf, 5, 2);
53 + gst_buffer_resize (buf, 8, 2);
54 gst_buffer_unref (buf);
55
56 /* buffer should've gone back into pool */
57 --
58 2.22.0
59