From: Takashi Iwai Subject: Re: [PATCH] Sample generation on big endian platforms was broken. Date: Fri, 03 Jul 2009 21:36:20 +0200 Message-ID: References: <1246630771.7922.25.camel@localhost.localdomain> <1246632695.7922.34.camel@localhost.localdomain> <1246633897.7922.39.camel@localhost.localdomain> <1246640660.31770.18.camel@localhost.localdomain> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 1C8AA103956 for ; Fri, 3 Jul 2009 21:36:21 +0200 (CEST) In-Reply-To: <1246640660.31770.18.camel@localhost.localdomain> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Kenneth Johansson Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org 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