mmdevapi: Prevent 64 bit overflow within a few days of audio device use. (try 2)

2013-03-05 Thread Joerg-Cyril.Hoehle
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)

2013-03-01 Thread Joerg-Cyril.Hoehle
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)

2013-03-01 Thread Michael Stefaniuc
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