Re: mmdevapi: Prevent 64 bit overflow within a few days of audio device use. (try 3)
writes: > The only comments about v2 were Michael Stefaniuc > suggesting a refactoring and me explaining why > in this particular case, that would not be a good idea. > http://www.winehq.org/pipermail/wine-devel/2013-March/099068.html It's still a good idea, even if the function is ultimately used only in one place. > For v3, I've renamed MulDiv64 to UMulDiv64. Unlike QueryPerformanceCounter, > mmdevapi GetPosition operates on unsigned values. That's a bad name. Don't make internal functions look like Win32 APIs. -- Alexandre Julliard julli...@winehq.org
mmdevapi: Prevent 64 bit overflow within a few days of audio device use. (try 2)
Hi, Michael Stefaniuc wrote: >But I see that even the whole functionality can move to a helper. That's not a good idea: While the code currently contains two identical pieces of code, it is actually bogus because the capture part should *not* store current time rather than get *recorded* time. Thus the code looks like there's something that could be refactored, but that would be the wrong refactoring. Regards, Jörg Höhle
mmdevapi: Prevent 64 bit overflow within a few days of audio device use. (try 2)
Michael Stefaniuc wrote: >My idea was to have the whole if else in an inline function. That's understandable. However in this particular case, we know that in Wine QueryPerfFrequency now yields 1000, thus Muldiv64 is dead code actually. So I decided to keep the if (freq == 1000) return idem; in the main code and delegate the unused MulDiv to an auxiliary. In winmm:waveform, things are a little different, and I was indeed considering integrating the if (num==den) /* typically num = den = samples per second */ into the MulDiv64, should I add one there too. A general purpose MulDiv however, should not waste cycles performing this particular check. Regards, Jörg Höhle
Re: mmdevapi: Prevent 64 bit overflow within a few days of audio device use. (try 2)
Hello Joerg, On 03/01/2013 10:22 AM, joerg-cyril.hoe...@t-systems.com wrote: > The idea to replace X * numerator / denominator > by X / den * mul + remainder from euclidian division > came from > http://blog.airsource.co.uk/index.php/2010/03/15/quelle-heure-est-il/ > > M. Stefaniuc suggested an inline function. The MulDiv64 inline has the benefit > of ensuring unsigned arithmetic, matching GetPosition UINT64 output. My idea was to have the whole if else in an inline function. But I see that even the whole functionality can move to a helper. Something like this: static inline ULONGLONG get_qpctime(void) { LARGE_INTEGER stamp, freq; QueryPerformanceCounter(&stamp); QueryPerformanceFrequency(&freq); if(freq.QuadPart == 1000) return stamp.QuadPart; else return stamp.QuadPart / freq.QuadPart * 1000 + stamp.QuadPart % freq.QuadPart * 1000 / freq.QuadPart; } bye michael
Re: mmdevapi: Prevent 64 bit overflow within a few days of audio device use.
Hello Joerg, On 02/27/2013 02:46 PM, joerg-cyril.hoe...@t-systems.com wrote: The idea to replace X * numerator / denominator by X / den * mul + remainder from euclidian division came from can you please use an inline function for that? http://blog.airsource.co.uk/index.php/2010/03/15/quelle-heure-est-il/ thanks bye michael