projects
/
supertux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e676ae5
)
Byteswapping code for sound engine on big-endian systems
author
Ondřej Hošek
<ondra.hosek@gmail.com>
Tue, 11 Apr 2006 19:11:51 +0000
(19:11 +0000)
committer
Ondřej Hošek
<ondra.hosek@gmail.com>
Tue, 11 Apr 2006 19:11:51 +0000
(19:11 +0000)
SVN-Revision: 3303
src/audio/sound_file.cpp
patch
|
blob
|
history
diff --git
a/src/audio/sound_file.cpp
b/src/audio/sound_file.cpp
index
42548ac
..
bcd6e3e
100644
(file)
--- a/
src/audio/sound_file.cpp
+++ b/
src/audio/sound_file.cpp
@@
-151,6
+151,23
@@
WavSoundFile::read(void* buffer, size_t buffer_size)
if(PHYSFS_read(file, buffer, readsize, 1) != 1)
throw std::runtime_error("read error while reading samples");
if(PHYSFS_read(file, buffer, readsize, 1) != 1)
throw std::runtime_error("read error while reading samples");
+#ifdef WORDS_BIGENDIAN
+ if (bits_per_sample != 16)
+ return readsize;
+ char *tmp = (char*)buffer;
+
+ size_t i;
+ char c;
+ for (i = 0; i < readsize / 2; i++)
+ {
+ c = tmp[2*i];
+ tmp[2*i] = tmp[2*i+1];
+ tmp[2*i+1] = c;
+ }
+
+ buffer = tmp;
+#endif
+
return readsize;
}
return readsize;
}
@@
-203,8
+220,13
@@
OggSoundFile::read(void* _buffer, size_t buffer_size)
while(buffer_size>0){
long bytesRead
while(buffer_size>0){
long bytesRead
- = ov_read(&vorbis_file, buffer, static_cast<int> (buffer_size), 0, 2, 1,
- §ion);
+ = ov_read(&vorbis_file, buffer, static_cast<int> (buffer_size),
+#ifdef WORDS_BIGENDIAN
+1,
+#else
+0,
+#endif
+ 2, 1, §ion);
if(bytesRead==0){
break;
}
if(bytesRead==0){
break;
}