libaudiofile and endian-ness
- From: Steve Murphy <murf e-tools com>
- To: gnome-devel-list gnome org
- Subject: libaudiofile and endian-ness
- Date: Mon, 12 Apr 1999 14:12:34 -0600 (MDT)
I've been able to make libaudiofile, esd, and sound work on a few applications
for Solaris, 16 bit WAV's and etc.
The problem is as Moredhel@earthling.net points out, the endian-ness is hard-wired
everywhere to little-endian, or Intel. This is fine as long as you are trying to
run sound on a PC. But Sparcs, and probably powerPC's, etc. will have problems,
varying from total silence to white noise.
The problem is complexicated by the fact that most applications are unnecessarily setting
the endian-ness; so both libaudiofile and the application need to be modified to make
sound work on bigendian machines.
There was one other complication related to endian-ness in libaudiofile, with WAV
files; the header strings weren't comparing right and would cause a crash.
I've sent fixes in, but changes to esd, libaudiofile, etc. are still pending. What, in
my not-always-so-humble-opinion (IMNASHO), needs to be done is:
1. No application should call afSetVirtualByteOrder(); libaudiofile calls it when you do
an afOpenFile.
2. libaudiofile needs to calculate the byteorder at Configure time, and use macros in the
code to set up the endianness of the machine it's running on.
Here is a fix I included to avoid the crash on wave files in audiofile-0.1.6:
Only in audiofile-0.1.6.new: Makefile
Only in audiofile-0.1.6.new: audiofile-config
diff -ru audiofile-0.1.6/audiofile.spec audiofile-0.1.6.new/audiofile.spec
--- audiofile-0.1.6/audiofile.spec Thu Feb 25 07:59:39 1999
+++ audiofile-0.1.6.new/audiofile.spec Sat Mar 13 11:58:37 1999
@@ -51,7 +51,7 @@
%files
%defattr(-, root, root)
-%doc COPYING TODO README ChangeLog LICENSE docs
+%doc COPYING TODO README ChangeLog docs
%{prefix}/bin/*
%{prefix}/lib/lib*.so.*
Only in audiofile-0.1.6.new: config.cache
Only in audiofile-0.1.6.new: config.h
Only in audiofile-0.1.6.new: config.log
Only in audiofile-0.1.6.new: config.status
Only in audiofile-0.1.6.new/docs: Makefile
Only in audiofile-0.1.6.new/libaudiofile: .libs
Only in audiofile-0.1.6.new/libaudiofile: Makefile
Only in audiofile-0.1.6.new/libaudiofile: aes.lo
Only in audiofile-0.1.6.new/libaudiofile: aes.o
Only in audiofile-0.1.6.new/libaudiofile: aiff.lo
Only in audiofile-0.1.6.new/libaudiofile: aiff.o
Only in audiofile-0.1.6.new/libaudiofile: aiffwrite.lo
Only in audiofile-0.1.6.new/libaudiofile: aiffwrite.o
Only in audiofile-0.1.6.new/libaudiofile: au.lo
Only in audiofile-0.1.6.new/libaudiofile: au.o
Only in audiofile-0.1.6.new/libaudiofile: audiofile.lo
Only in audiofile-0.1.6.new/libaudiofile: audiofile.o
Only in audiofile-0.1.6.new/libaudiofile: aupv.lo
Only in audiofile-0.1.6.new/libaudiofile: aupv.o
Only in audiofile-0.1.6.new/libaudiofile: auwrite.lo
Only in audiofile-0.1.6.new/libaudiofile: auwrite.o
Only in audiofile-0.1.6.new/libaudiofile: bread.lo
Only in audiofile-0.1.6.new/libaudiofile: bread.o
Only in audiofile-0.1.6.new/libaudiofile: bwrite.lo
Only in audiofile-0.1.6.new/libaudiofile: bwrite.o
Only in audiofile-0.1.6.new/libaudiofile: byteorder.lo
Only in audiofile-0.1.6.new/libaudiofile: byteorder.o
Only in audiofile-0.1.6.new/libaudiofile: error.lo
Only in audiofile-0.1.6.new/libaudiofile: error.o
Only in audiofile-0.1.6.new/libaudiofile: extended.lo
Only in audiofile-0.1.6.new/libaudiofile: extended.o
Only in audiofile-0.1.6.new/libaudiofile: instrument.lo
Only in audiofile-0.1.6.new/libaudiofile: instrument.o
Only in audiofile-0.1.6.new/libaudiofile: libaudiofile.la
Only in audiofile-0.1.6.new/libaudiofile: loop.lo
Only in audiofile-0.1.6.new/libaudiofile: loop.o
Only in audiofile-0.1.6.new/libaudiofile: marker.lo
Only in audiofile-0.1.6.new/libaudiofile: marker.o
Only in audiofile-0.1.6.new/libaudiofile: misc.lo
Only in audiofile-0.1.6.new/libaudiofile: misc.o
Only in audiofile-0.1.6.new/libaudiofile: swapblock.lo
Only in audiofile-0.1.6.new/libaudiofile: swapblock.o
Only in audiofile-0.1.6.new/libaudiofile: track.lo
Only in audiofile-0.1.6.new/libaudiofile: track.o
Only in audiofile-0.1.6.new/libaudiofile: ulaw.lo
Only in audiofile-0.1.6.new/libaudiofile: ulaw.o
Only in audiofile-0.1.6.new/libaudiofile: util.lo
Only in audiofile-0.1.6.new/libaudiofile: util.o
diff -ru audiofile-0.1.6/libaudiofile/wave.c audiofile-0.1.6.new/libaudiofile/wave.c
--- audiofile-0.1.6/libaudiofile/wave.c Mon Feb 22 11:06:08 1999
+++ audiofile-0.1.6.new/libaudiofile/wave.c Sat Mar 13 13:21:58 1999
@@ -118,13 +118,13 @@
/* include the offset of the form type */
while (index < size)
{
- u_int32_t chunkid, chunksize;
+ u_int32_t chunkid1, chunkid2, chunksize;
#ifdef DEBUG
printf("index: %d\n", index);
#endif
- fread(&chunkid, 4, 1, file->fp);
- chunkid = LENDIAN_TO_HOST_INT32(chunkid);
+ fread(&chunkid1, 4, 1, file->fp);
+ chunkid2 = LENDIAN_TO_HOST_INT32(chunkid1);
fread(&chunksize, 4, 1, file->fp);
chunksize = LENDIAN_TO_HOST_INT32(chunksize);
@@ -134,10 +134,14 @@
printf(" size: %d\n", chunksize);
#endif
- if (memcmp (&chunkid, "data", 4) == 0)
- ParseData(file, file->fp, chunkid, chunksize);
- else if (memcmp (&chunkid, "fmt ", 4) == 0)
- ParseFormat(file, file->fp, chunkid, chunksize);
+ if (memcmp (&chunkid1, "data", 4) == 0)
+ ParseData(file, file->fp, chunkid1, chunksize);
+ else if ( memcmp (&chunkid2, "data", 4) == 0)
+ ParseData(file, file->fp, chunkid2, chunksize);
+ else if (memcmp (&chunkid1, "fmt ", 4) == 0)
+ ParseFormat(file, file->fp, chunkid1, chunksize);
+ else if(memcmp (&chunkid2, "fmt ", 4) == 0)
+ ParseFormat(file, file->fp, chunkid2, chunksize);
index += chunksize + 8;
Only in audiofile-0.1.6.new/libaudiofile: wave.c~
Only in audiofile-0.1.6.new/libaudiofile: wave.lo
Only in audiofile-0.1.6.new/libaudiofile: wave.o
Only in audiofile-0.1.6.new/libaudiofile: wavewrite.lo
Only in audiofile-0.1.6.new/libaudiofile: wavewrite.o
Only in audiofile-0.1.6.new/libaudiofile: write.lo
Only in audiofile-0.1.6.new/libaudiofile: write.o
Only in audiofile-0.1.6.new: libtool
Only in audiofile-0.1.6.new/sfcommands: Makefile
Only in audiofile-0.1.6.new/sfcommands: printinfo.o
Only in audiofile-0.1.6.new/sfcommands: sfconvert
Only in audiofile-0.1.6.new/sfcommands: sfconvert.o
Only in audiofile-0.1.6.new/sfcommands: sfinfo
Only in audiofile-0.1.6.new/sfcommands: sfinfo.o
Only in audiofile-0.1.6.new: stamp-h
Only in audiofile-0.1.6.new/test: Makefile
Only in audiofile-0.1.6.new/test: addcoffset
Only in audiofile-0.1.6.new/test: adddcoffset.o
Only in audiofile-0.1.6.new/test: copy
Only in audiofile-0.1.6.new/test: copy.o
Only in audiofile-0.1.6.new/test: miscread
Only in audiofile-0.1.6.new/test: miscread.o
Only in audiofile-0.1.6.new/test: miscwrite
Only in audiofile-0.1.6.new/test: miscwrite.o
Only in audiofile-0.1.6.new/test: results
Only in audiofile-0.1.6.new/test: results.o
Only in audiofile-0.1.6.new/test: testaupv
Only in audiofile-0.1.6.new/test: testaupv.o
Only in audiofile-0.1.6.new/test: transparency
Only in audiofile-0.1.6.new/test: transparency.o
Oops, on #1 above, I said "libaudiofile **calls** it" but I really should have said, "libaudiofile
**sets*** it", as the code really just sets the VirtualByteOrder in the file structure to
LITTLE endian or BIG endian.
Then, just make sure that you examine all sets of
code that set the value of ->virtualByteOrder in libaudiofile/audiofile.c.
For enlightenment, check "sound.c", if my memory is correct.
In esd, I made and sent in a chunk of changes; I'm not sure they got included in
0.2.8... I just double check new releases to see if they are still needed.
I don't know how many applications need to be changed to remove calls to afSetVirtualByteOrder();
it could end up being quite a few if they support sound.
murf
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]