mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
wavparse: tune output max buffer size to material
... to avoid ending up with tons of short time buffers for e.g. high sample rate audio.
This commit is contained in:
parent
89914439b7
commit
b69c605c2c
2 changed files with 17 additions and 3 deletions
|
@ -1156,6 +1156,8 @@ gst_waveparse_ignore_chunk (GstWavParse * wav, GstBuffer * buf, guint32 tag,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#define MAX_BUFFER_SIZE 4096
|
||||
|
||||
static GstFlowReturn
|
||||
gst_wavparse_stream_headers (GstWavParse * wav)
|
||||
{
|
||||
|
@ -1578,6 +1580,19 @@ gst_wavparse_stream_headers (GstWavParse * wav)
|
|||
|
||||
wav->state = GST_WAVPARSE_DATA;
|
||||
|
||||
/* determine reasonable max buffer size,
|
||||
* that is, buffers not too small either size or time wise
|
||||
* so we do not end up with too many of them */
|
||||
/* var abuse */
|
||||
upstream_size = 0;
|
||||
gst_wavparse_time_to_bytepos (wav, 40 * GST_MSECOND, &upstream_size);
|
||||
wav->max_buf_size = upstream_size;
|
||||
wav->max_buf_size = MAX (wav->max_buf_size, MAX_BUFFER_SIZE);
|
||||
if (wav->blockalign > 0)
|
||||
wav->max_buf_size -= (wav->max_buf_size % wav->blockalign);
|
||||
|
||||
GST_DEBUG_OBJECT (wav, "max buffer size %d", wav->max_buf_size);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
||||
/* ERROR */
|
||||
|
@ -1802,8 +1817,6 @@ gst_wavparse_add_src_pad (GstWavParse * wav, GstBuffer * buf)
|
|||
}
|
||||
}
|
||||
|
||||
#define MAX_BUFFER_SIZE 4096
|
||||
|
||||
static GstFlowReturn
|
||||
gst_wavparse_stream_data (GstWavParse * wav)
|
||||
{
|
||||
|
@ -1826,7 +1839,7 @@ iterate_adapter:
|
|||
* amounts of data regardless of the playback rate */
|
||||
desired =
|
||||
MIN (gst_guint64_to_gdouble (wav->dataleft),
|
||||
MAX_BUFFER_SIZE * wav->segment.abs_rate);
|
||||
wav->max_buf_size * wav->segment.abs_rate);
|
||||
|
||||
if (desired >= wav->blockalign && wav->blockalign > 0)
|
||||
desired -= (desired % wav->blockalign);
|
||||
|
|
|
@ -90,6 +90,7 @@ struct _GstWavParse {
|
|||
gboolean vbr;
|
||||
|
||||
guint bytes_per_sample;
|
||||
guint max_buf_size;
|
||||
|
||||
/* position in data part */
|
||||
guint64 offset;
|
||||
|
|
Loading…
Reference in a new issue