summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2010-03-13 22:25:21 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2010-03-13 22:25:21 +0000
commit1e67a28cffaf7ca53755d361a8f7962bf4de0601 (patch)
treefc35a8fe796a734f021003d4e5a122122a2d11de /tools
parent9c2baa6b17cbeb0facbbdfafefab965d7bdabb6f (diff)
downloadrockbox-1e67a28cffaf7ca53755d361a8f7962bf4de0601.tar.gz
rockbox-1e67a28cffaf7ca53755d361a8f7962bf4de0601.tar.bz2
rockbox-1e67a28cffaf7ca53755d361a8f7962bf4de0601.zip
Fix wavtrim not working correctly on PPC.
Don't rely on the host being little endian -- PPC Macs are not, resulting in wavtrim not trimming files at all. Also fix a printf warning while at it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25158 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r--tools/wavtrim.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/wavtrim.c b/tools/wavtrim.c
index b82f270c8d..8517b4677e 100644
--- a/tools/wavtrim.c
+++ b/tools/wavtrim.c
@@ -167,7 +167,9 @@ int wavtrim(char * filename, int maxsilence ,char* errstring,int errsize)
/* clip the start */
for (i=0; i<datalen; i+=2)
{
- sample16 = *(short *)(databuf + i);
+ /* samples are little endian */
+ sample16 = (*(databuf + i + 1) << 8) | *(databuf + i);
+
if (abs(sample16) > max_silence)
break;
}
@@ -178,7 +180,8 @@ int wavtrim(char * filename, int maxsilence ,char* errstring,int errsize)
/* clip the end */
for (i=datalen-2; i>skip_head; i-=2)
{
- sample16 = *(short *)(databuf + i);
+ /* samples are little endian */
+ sample16 = (*(databuf + i + 1) << 8) | *(databuf + i);
if (abs(sample16) > max_silence)
break;
}
@@ -231,7 +234,7 @@ int main (int argc, char** argv)
ret = wavtrim(argv[1],max_silence,errbuffer,255 );
if( ret< 0)
{
- printf(errbuffer);
+ printf("%s", errbuffer);
}
return ret;
}