Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

aubuf: prevent faulty timestamps #75

Merged
merged 4 commits into from
Jul 29, 2022

Conversation

cspiel1
Copy link
Collaborator

@cspiel1 cspiel1 commented Jul 27, 2022

If the application does not set the timestamps of the pushed audio frames, then during a partial read faulty timestamps had been set.

  • aubuf: prevent faulty timestamps for partial read
    --> This seems to be a simple fix. But is wrong for a partial read if the application sets correct timestamps and the first frame has timestamp zero.

The following commits sets timestamps automatically for pushed audio frames, if not given by the application.

  • aubuf: set correct timestamps if app provides zero
  • aubuf,auframe: move auframe_bytes_to_timestamp() to auframe
  • aubuf: reset also written_sz in aubuf_flush()

This baresip/retest#104 adds unit tests for partial read with automatic timestamps.

There are applications where a useful timestamp is not available. E.g. if audio
files are read and decoded. Then audio frames are written to aubuf with
`timestamp == 0`. In such cases a partial read with `aubuf_read_auframe()` set
a wrong timestamp to the rest frame.
For partial read timestamps are changed for the rest frames. This works only
if the timestamps are already set correctly during writing.

This commit handles also the case correct if the application provides
timestamps and the first frame has timestamp zero and the first read is
partial.
@cspiel1 cspiel1 changed the title aubuf timestamp optional aubuf: prevent faulty timestamps Jul 29, 2022
@cspiel1 cspiel1 marked this pull request as ready for review July 29, 2022 05:57
@cspiel1
Copy link
Collaborator Author

cspiel1 commented Jul 29, 2022

So from my side this PR is ready for merge. The new retests should check the correct behavior and this PR fixes a bug for partial reading.

@sreimers sreimers merged commit 7eb6d16 into baresip:main Jul 29, 2022
@cspiel1 cspiel1 deleted the aubuf_timestamp_optional branch August 2, 2022 09:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants