mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-28 20:05:38 +00:00
audiorate: Update next_offset per rate change
To support runtime audio samplerate change, re-calculate next target offset per caps. Calculating the next buffer offset using the previous offset seems to be tricky and rounding error prone. Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/693
This commit is contained in:
parent
b6bdff0c84
commit
fab2d6d60c
1 changed files with 12 additions and 0 deletions
|
@ -216,12 +216,24 @@ static gboolean
|
|||
gst_audio_rate_setcaps (GstAudioRate * audiorate, GstCaps * caps)
|
||||
{
|
||||
GstAudioInfo info;
|
||||
gint prev_rate = 0;
|
||||
|
||||
if (!gst_audio_info_from_caps (&info, caps))
|
||||
goto wrong_caps;
|
||||
|
||||
prev_rate = audiorate->info.rate;
|
||||
audiorate->info = info;
|
||||
|
||||
if (audiorate->next_offset >= 0 && prev_rate > 0 && prev_rate != info.rate) {
|
||||
GST_DEBUG_OBJECT (audiorate,
|
||||
"rate changed from %d to %d", prev_rate, info.rate);
|
||||
|
||||
/* calculate next_offset based on new rate value */
|
||||
audiorate->next_offset =
|
||||
gst_util_uint64_scale_int_round (audiorate->next_ts,
|
||||
info.rate, GST_SECOND);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
|
|
Loading…
Reference in a new issue