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
@ -216,12 +216,24 @@ static gboolean
|
|||||||
gst_audio_rate_setcaps (GstAudioRate * audiorate, GstCaps * caps)
|
gst_audio_rate_setcaps (GstAudioRate * audiorate, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstAudioInfo info;
|
GstAudioInfo info;
|
||||||
|
gint prev_rate = 0;
|
||||||
|
|
||||||
if (!gst_audio_info_from_caps (&info, caps))
|
if (!gst_audio_info_from_caps (&info, caps))
|
||||||
goto wrong_caps;
|
goto wrong_caps;
|
||||||
|
|
||||||
|
prev_rate = audiorate->info.rate;
|
||||||
audiorate->info = info;
|
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;
|
return TRUE;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user