Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing methods to Linux Clock implementation. #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcel303
Copy link

No description provided.

@fgo-ableton
Copy link
Collaborator

What is the reason you want to add this?
The reason those exist in the darwin is to allow convenient conversion from/to core audio timestamps. There is no such "native" linux timestamp format. As far as I can tell any necessary conversions should be doable using std::chrono.

@marcel303
Copy link
Author

What is the reason you want to add this?
The reason those exist in the darwin is to allow convenient conversion from/to core audio timestamps. There is no such "native" linux timestamp format. As far as I can tell any necessary conversions should be doable using std::chrono.

Hm, I was under the impression somehow I should use ticks for time stamps. Not sure where I got that idea (maybe I copy-pasted some example code). I've used ticks through out the code base before I began porting to Linux. But if I understand you correctly, I should be using micros for the cross-platform code, and use ticksToMicros to convert mHostTime on macOS to micros?

@fgo-ableton
Copy link
Collaborator

ticks() just calls mach_absolute_time(). mach_absolute_time() should be used with caution. I.e. it behaves differently on arm and x86. So I would not recommend to use this as the general time unit for an app that is supposed to support multiple platforms. I.e. if you want to do some calculations using a sample rate value and time value, you will have to know the unit.
You can use mach_timebase_info to convert the result of mach_absolute_time() to nanoseconds.
In Link we use microseconds as a unit for time as this makes sense regarding accuracy and data being transmitted over the network.
If microseconds makes sense for your application you could use that. If you have other requirements something else might make more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants