Subject: Re: [linux-audio-dev] Re: streaming from disk to terminatorX added (via mmap)
From: Jaroslav Kysela (perex_AT_suse.cz)
Date: ti loka 26 1999 - 08:31:06 EDT
On Mon, 25 Oct 1999, Paul Barton-Davis wrote:
> In message <38151885.7A650570_AT_42.fht-esslingen.de>you write:
> >Paul Barton-Davis wrote:
> >> just FYI: my C++ libsoundfile uses mmap(), but still requires
> >> applications to "read" the data. it is significantly faster than using
> >> read(2) internally, however, so there might be an argument for using
> >> mmap regardless of the endianness, and then using arch-dependent
> >> macros to fetch the data from the mmapped area. for example, on a
> >> little endian machine reading from a little endian RIFF/WAV file, the
> >> macros are essentially no-ops.
> >
> >No-ops? Do you mean you don't generate ANY code for this? If so: HOW?
>
> sorry, not very accurate. for example:
>
> int16 foo;
> unsigned char *p;
>
> foo = get_little_endian_int16 (p)
>
> on an LE machine, this is just:
>
> foo = *((int16 *) p);
>
> on a BE machine, its a bit more complex.
Not very much:
#include <byteswap.h>
foo = bswap_16(*((int16 *)p));
The defined macros from GLIBC already does byte swapping in the best way
for given architecture.
Jaroslav
-----
Jaroslav Kysela <perex_AT_suse.cz>
SuSE Linux http://www.suse.com
ALSA project http://www.alsa-project.org
This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:27:59 EST