link icon indicating copy to clipboard operation
link copied to clipboard

Add missing methods to Linux Clock implementation.

Open marcel303 opened this issue 4 years ago • 3 comments

marcel303 avatar Apr 15 '21 16:04 marcel303

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.

fgo-ableton avatar Apr 19 '21 18:04 fgo-ableton

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?

marcel303 avatar May 17 '21 17:05 marcel303

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.

fgo-ableton avatar May 21 '21 13:05 fgo-ableton