Sheldon fu wrote:
sizeof() can not be used in the pre-compiling constant expression. e.g.
you can not do:

#if sizeof(int) == 4

did you mean '#if' or 'if' here?

This is not just for debug build. I checked the assembly code compiled
for Android with original logic, even in release build setting, the
compiler (gcc 4.2 arm-eabi) doesn't optimize away that if with constant
expression.

It seems that:

  const unsigned int NBITS_PER_AUDIOSAMPLE=sizeof(tAudioSample)<<3;
  ...
  if( NBITS_PER_AUDIOSAMPLE==16 )
  {memcpy}
  else
  {for-loop}

should work right? I don't see how the compiler could
not evaluate NBITS_PER_AUDIOSAMPLE at compile time and
be left with:

  if( 16 == 16 )

Does that work on your compiler? If that is broken as
well, then we don't have much choice. How big of a hit
is the 'if(  sizeof()==16 )' comparison?


--greg.




fxd

On Wed, 2009-04-29 at 08:14 -0700, Greg Wright wrote:
Sheldon fu wrote:
Overview:

This is a small effort to improve the efficiency of sampler converter. A
direct memcpy bypass is added for 16bit to 16bit converting case,
similar to what we already have for 32bit to 32bit conversion. Also
memcpy bypass is turned on by conditional pre-compiling macro now,
instead of 'if' statement. This enables memcpy bypass on compilers that
don't do aggressive constant expression optimization and debug build.

Head and Atlas310

fxd
-#define NBITS_PER_AUDIOSAMPLE (sizeof(tAudioSample)<<3)

Why exactly does that not work?  I like it better that
way since it it less prone to future bugs if/when the
datatypes for audio samples are added or changed, especially
if this is only needed for DEBUG builds. Does not using
a const int, or something besides a #define let you use a
'if'?

--greg.









_______________________________________________
Audio-dev mailing list
[email protected]
http://lists.helixcommunity.org/mailman/listinfo/audio-dev

Reply via email to