mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:06:17 +00:00
audioaggregator: improve readability in offset calculation
Don't reuse the offset variables will contain a sample offset for an intermediate time value. Instead add a segment_pos variable of type GstClockTime for this. Use The clock-time macros to check if we got a valid time.
This commit is contained in:
parent
bd34243177
commit
023170e2f8
1 changed files with 9 additions and 8 deletions
|
@ -866,8 +866,9 @@ gst_audio_aggregator_queue_new_buffer (GstAudioAggregator * aagg,
|
||||||
if (pad->priv->output_offset == -1) {
|
if (pad->priv->output_offset == -1) {
|
||||||
GstClockTime start_running_time;
|
GstClockTime start_running_time;
|
||||||
GstClockTime end_running_time;
|
GstClockTime end_running_time;
|
||||||
guint64 start_output_offset;
|
GstClockTime segment_pos;
|
||||||
guint64 end_output_offset;
|
guint64 start_output_offset = -1;
|
||||||
|
guint64 end_output_offset = -1;
|
||||||
|
|
||||||
start_running_time =
|
start_running_time =
|
||||||
gst_segment_to_running_time (&aggpad->segment,
|
gst_segment_to_running_time (&aggpad->segment,
|
||||||
|
@ -877,20 +878,20 @@ gst_audio_aggregator_queue_new_buffer (GstAudioAggregator * aagg,
|
||||||
GST_FORMAT_TIME, end_time);
|
GST_FORMAT_TIME, end_time);
|
||||||
|
|
||||||
/* Convert to position in the output segment */
|
/* Convert to position in the output segment */
|
||||||
start_output_offset =
|
segment_pos =
|
||||||
gst_segment_position_from_running_time (&agg->segment, GST_FORMAT_TIME,
|
gst_segment_position_from_running_time (&agg->segment, GST_FORMAT_TIME,
|
||||||
start_running_time);
|
start_running_time);
|
||||||
if (start_output_offset != -1)
|
if (GST_CLOCK_TIME_IS_VALID (segment_pos))
|
||||||
start_output_offset =
|
start_output_offset =
|
||||||
gst_util_uint64_scale (start_output_offset - agg->segment.start, rate,
|
gst_util_uint64_scale (segment_pos - agg->segment.start, rate,
|
||||||
GST_SECOND);
|
GST_SECOND);
|
||||||
|
|
||||||
end_output_offset =
|
segment_pos =
|
||||||
gst_segment_position_from_running_time (&agg->segment, GST_FORMAT_TIME,
|
gst_segment_position_from_running_time (&agg->segment, GST_FORMAT_TIME,
|
||||||
end_running_time);
|
end_running_time);
|
||||||
if (end_output_offset != -1)
|
if (GST_CLOCK_TIME_IS_VALID (segment_pos))
|
||||||
end_output_offset =
|
end_output_offset =
|
||||||
gst_util_uint64_scale (end_output_offset - agg->segment.start, rate,
|
gst_util_uint64_scale (segment_pos - agg->segment.start, rate,
|
||||||
GST_SECOND);
|
GST_SECOND);
|
||||||
|
|
||||||
if (start_output_offset == -1 && end_output_offset == -1) {
|
if (start_output_offset == -1 && end_output_offset == -1) {
|
||||||
|
|
Loading…
Reference in a new issue