mrRay / vvopensource

OSC and MIDI frameworks for OS X and iOS, a framework for managing and rendering to GL textures in OS X, and a functional ISF (interactive shader format) implementation for OS X.
232 stars 33 forks source link

OSCBundle:TimeTag - iOS 10 problem #24

Open Enigma644 opened 8 years ago

Enigma644 commented 8 years ago

Something weird is going on with iOS 10 with these two lines in OSCBundle (lines 218, 219):

long time_s = NSSwapHostLongToBig(floor(interval));
long time_us = NSSwapHostLongToBig((long)(floor((double)1000000.0 * ((double)(interval - (double)time_s)))));

I'm not sure what is happening, but NSSwapHostLongToBig is just not giving out the same results on iOS 10 vs iOS 9. As a result the bundle time is getting totally messed up. I think it's got to do with LONG_MAX being much higher on my x64 iOS 10 iPhone 6 test device.

Also of note, on line 218, (interval - time_s) should be (interval - floor(interval)).

mrRay commented 8 years ago

howdy-

thanks for letting me know about this. i don't have an iOS 10 SDK at my disposal right now, but i made some changes- if you could please let me know if they resolve your issue i'd appreciate it!

cheers : : ray

Enigma644 commented 8 years ago

Awesome, thank you. iOS9 and iOS10 are now behaving the same.

I am however noticing problems with the fraction microseconds (in any iOS). In the test utils that I'm using they are showing the microseconds not changing, but looking at the packet you are creating, it looks to me like the timetag is built correctly. Can I ask what test tool you're using? I'm testing with oscP5.

Enigma644 commented 8 years ago

FYI other libs have the second component as a fraction of 4294967296 eg: http://cim.mcgill.ca/sresvn/audioscape/audioscape_resources/PDa/extra/dumpOSC.c

Enigma644 commented 8 years ago

After a bunch of testing, I'm 99% sure you should have: uint32_t time_us = CFSwapInt32HostToBig((uint32_t)floor((double)4294967296.0 * ((double)(interval - floor(interval)))));

mrRay commented 8 years ago

you are, of course, correct- nice catch, thanks for the tip! just pushed some changes, please let me know if you have any more problems.