mmdevapi: Correctly convert UINT32 to INT64

2012-01-30 Thread Joerg-Cyril . Hoehle
Andrew,

thank you very much for finding a bug in my code.

I'll have to meditate signed/unsigned conversions for the next months.

Perhaps it's my lack of familiarity with the MS-Windows API that had
me not find a signed equivalent of UINT32. Indeed there's none in
windef.h. So I choose 'long'. But now I see basestd.h defines LONG32.

INT64 is not appropriate. getbuf_last should be of the same size than
the other frame holding types.  I once wrote a patch to turn all
#frame holding entities from UINT64 into 32.  Please rewrite the patch
to use the LONG32 type, then you'll need no surprising cast.

If the loss of 1 bit worries you, the solution IMHO is not to go to
INT64 rather than prevent a duration that large in Initialize.  In
shared mode, there's no 2s limit. My tests opened a 10s buffer. I've
not tested anything larger.
LONG32 leaves enough room for 1 seconds at 20fps.

Regards,
Jörg Höhle



Re: mmdevapi: Correctly convert UINT32 to INT64

2012-01-30 Thread Michael Stefaniuc

Hello Joerg,

On 01/30/2012 09:46 AM, joerg-cyril.hoe...@t-systems.com wrote:

thank you very much for finding a bug in my code.

I'll have to meditate signed/unsigned conversions for the next months.

Perhaps it's my lack of familiarity with the MS-Windows API that had
me not find a signed equivalent of UINT32. Indeed there's none in
windef.h. So I choose 'long'. But now I see basestd.h defines LONG32.
LONG32 is kinda redundant. LONG is 32bit on all Windows versions on 
16bit, 32bit and 64bit Windows.




INT64 is not appropriate. getbuf_last should be of the same size than
the other frame holding types.  I once wrote a patch to turn all
#frame holding entities from UINT64 into 32.  Please rewrite the patch
to use the LONG32 type, then you'll need no surprising cast.

If the loss of 1 bit worries you, the solution IMHO is not to go to
INT64 rather than prevent a duration that large in Initialize.  In
shared mode, there's no 2s limit. My tests opened a 10s buffer. I've
not tested anything larger.
LONG32 leaves enough room for 1 seconds at 20fps.


bye
michael




mmdevapi: Correctly convert UINT32 to INT64

2012-01-30 Thread Joerg-Cyril . Hoehle
Michael Stefaniuc wrote:
But now I see basestd.h defines LONG32.
LONG32 is kinda redundant. LONG is 32bit on all Windows
versions on 16bit, 32bit and 64bit Windows.
Ah, thank you.  However in our particular case, the value that
getbuf_last is derived from is UINT32, not UINT, so for symmetry,
I still recommend the explicit LONG32.

Regards,
Jörg Höhle



Re: mmdevapi: Correctly convert UINT32 to INT64

2012-01-30 Thread Vitaliy Margolen

On 01/30/2012 03:08 AM, joerg-cyril.hoe...@t-systems.com wrote:

Michael Stefaniuc wrote:

But now I see basestd.h defines LONG32.

LONG32 is kinda redundant. LONG is 32bit on all Windows
versions on 16bit, 32bit and 64bit Windows.

Ah, thank you.  However in our particular case, the value that
getbuf_last is derived from is UINT32, not UINT, so for symmetry,
I still recommend the explicit LONG32.


UINT is the same as UNIT32:

basetsd.h:84 typedef unsigned int UINT32, *PUINT32;
windef.h:213 typedef unsigned intUINT,   *PUINT;

Vitaliy.