baseparse: Fix upstream read caching
authorJan Schmidt <jan@centricular.com>
Tue, 31 Mar 2020 15:36:40 +0000 (02:36 +1100)
committerJan Schmidt <jan@centricular.com>
Wed, 1 Apr 2020 07:36:19 +0000 (18:36 +1100)
commite906197c622725e48b6250a71a922d45b006fb14
tree7c518ce2b7f5f60ad9d08967a3d838c53488dfb5
parent35136dc91ae226bf6b0c602a4ceedc1541a6aeff
baseparse: Fix upstream read caching

When running in pull mode (for e.g. mp3 reading),
baseparse currently reads 64KB from upstream, then mp3parse
consumes typically around 417/418 bytes of it. Then
on the next loop, it will read a full fresh 64KB again,
which is a big waste.

Fix the read loop to use the available cache buffer first
before going for more data, until the cache drops to < 1KB.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/518
libs/gst/base/gstbaseparse.c
tests/check/libs/baseparse.c