[alsa-devel] [PATCH] Sample generation on big endian platforms was broken.

Takashi Iwai tiwai at suse.de
Fri Jul 3 21:36:20 CEST 2009


At Fri, 03 Jul 2009 19:04:20 +0200,
Kenneth Johansson wrote:
> 
> On Fri, 2009-07-03 at 17:41 +0200, Takashi Iwai wrote:
> 
> > ... and the code doesn't handle the case of 3 byte format, too.
> > 
> > 
> > Takashi
> > 
> 
> Soo ? there is a lot of formats this code can't generate. It's a test
> program and I doubt anybody has ever tried to change the output format
> since it has never worked for most formats.

24bit 3byte format is very popular (e.g. used by USB audio), and the
commit that broke the big-endian was to support such formats.  It
works actually.

> but if you want to add support for 3 bytes then there is no way around
> having two different storage methods one for BIG and one for LITTLE
> endian machines.

3 byte format is just 24bit linear data packed into 3 bytes.  The
difference is only the length of the bytes.  So, the difference of
endian exists.

BTW, a simpler solution is to use memcpy() with a certain offset.
For example,

	int offset, size;
	size = snd_pcm_format_physical_width(fmt) / 8;
#ifdef BIG_ENDIAN
	offset = 4 - size;
#else
	offset = 0;
#endif

	for (...) {
		...
		memcpy(dest, src + offset, size);
		...
	}

memcpy() isn't so expensive with the recent gcc/glibc.

Could you rewrite the patch in that way and test it on big-endian
machines?


thanks,

Takashi


More information about the Alsa-devel mailing list