mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:36:20 +00:00
use the rate of the logical stream to calculate duration instead of current rate.
Original commit message from CVS: use the rate of the logical stream to calculate duration instead of current rate.
This commit is contained in:
parent
dc446a0fa1
commit
f0ceb74eb2
1 changed files with 24 additions and 13 deletions
|
@ -721,26 +721,37 @@ gst_vorbisfile_src_convert (GstPad *pad,
|
||||||
gint i;
|
gint i;
|
||||||
gint64 count = 0;
|
gint64 count = 0;
|
||||||
|
|
||||||
if (src_value >= vorbisfile->vf.links) {
|
|
||||||
count = ov_pcm_total (&vorbisfile->vf, -1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (i = 0; i < src_value; i++) {
|
|
||||||
count += ov_pcm_total (&vorbisfile->vf, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (*dest_format) {
|
switch (*dest_format) {
|
||||||
case GST_FORMAT_BYTES:
|
case GST_FORMAT_BYTES:
|
||||||
scale = bytes_per_sample;
|
res = FALSE;
|
||||||
|
break;
|
||||||
case GST_FORMAT_UNITS:
|
case GST_FORMAT_UNITS:
|
||||||
*dest_value = count *scale;
|
if (src_value > vorbisfile->vf.links) {
|
||||||
|
src_value = vorbisfile->vf.links;
|
||||||
|
}
|
||||||
|
for (i = 0; i < src_value; i++) {
|
||||||
|
vi = ov_info (&vorbisfile->vf, i);
|
||||||
|
|
||||||
|
count += ov_pcm_total (&vorbisfile->vf, i);
|
||||||
|
}
|
||||||
|
*dest_value = count;
|
||||||
break;
|
break;
|
||||||
case GST_FORMAT_TIME:
|
case GST_FORMAT_TIME:
|
||||||
if (vi->rate == 0)
|
{
|
||||||
return FALSE;
|
if (src_value > vorbisfile->vf.links) {
|
||||||
|
src_value = vorbisfile->vf.links;
|
||||||
|
}
|
||||||
|
for (i = 0; i < src_value; i++) {
|
||||||
|
vi = ov_info (&vorbisfile->vf, i);
|
||||||
|
if (vi->rate)
|
||||||
|
count += ov_pcm_total (&vorbisfile->vf, i) * GST_SECOND / vi->rate;
|
||||||
|
else
|
||||||
|
count += ov_time_total (&vorbisfile->vf, i) * GST_SECOND;
|
||||||
|
}
|
||||||
/* we use the pcm totals to get the total time, it's more accurate */
|
/* we use the pcm totals to get the total time, it's more accurate */
|
||||||
*dest_value = count * GST_SECOND / vi->rate;
|
*dest_value = count;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue