diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2017-04-26 09:10:20 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2017-04-26 09:10:20 +0200 |
commit | 7bf6ced01ee71aafd0ecad50d26b110c99a50b7f (patch) | |
tree | 6a12421e2fdc68371a12ab9529e2c8ec35b64646 /package/libaudiofile/patches/patch-sfcommands_sfconvert_c | |
parent | 9ae4a9a777cb248a47b4a52942df4e0723691af6 (diff) |
libaudiofile: disable sfcommands, add buildroot patches
Diffstat (limited to 'package/libaudiofile/patches/patch-sfcommands_sfconvert_c')
-rw-r--r-- | package/libaudiofile/patches/patch-sfcommands_sfconvert_c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/package/libaudiofile/patches/patch-sfcommands_sfconvert_c b/package/libaudiofile/patches/patch-sfcommands_sfconvert_c new file mode 100644 index 000000000..cdf0e8dc3 --- /dev/null +++ b/package/libaudiofile/patches/patch-sfcommands_sfconvert_c @@ -0,0 +1,50 @@ +--- audiofile-0.3.6.orig/sfcommands/sfconvert.c 2013-03-06 06:30:03.000000000 +0100 ++++ audiofile-0.3.6/sfcommands/sfconvert.c 2017-04-26 02:15:11.864252147 +0200 +@@ -45,6 +45,33 @@ void printusage (void); + void usageerror (void); + bool copyaudiodata (AFfilehandle infile, AFfilehandle outfile, int trackid); + ++int firstBitSet(int x) ++{ ++ int position=0; ++ while (x!=0) ++ { ++ x>>=1; ++ ++position; ++ } ++ return position; ++} ++ ++#ifndef __has_builtin ++#define __has_builtin(x) 0 ++#endif ++ ++int multiplyCheckOverflow(int a, int b, int *result) ++{ ++#if (defined __GNUC__ && __GNUC__ >= 5) || ( __clang__ && __has_builtin(__builtin_mul_overflow)) ++ return __builtin_mul_overflow(a, b, result); ++#else ++ if (firstBitSet(a)+firstBitSet(b)>31) // int is signed, so we can't use 32 bits ++ return true; ++ *result = a * b; ++ return false; ++#endif ++} ++ + int main (int argc, char **argv) + { + if (argc == 2) +@@ -323,8 +350,11 @@ bool copyaudiodata (AFfilehandle infile, + { + int frameSize = afGetVirtualFrameSize(infile, trackid, 1); + +- const int kBufferFrameCount = 65536; +- void *buffer = malloc(kBufferFrameCount * frameSize); ++ int kBufferFrameCount = 65536; ++ int bufferSize; ++ while (multiplyCheckOverflow(kBufferFrameCount, frameSize, &bufferSize)) ++ kBufferFrameCount /= 2; ++ void *buffer = malloc(bufferSize); + + AFframecount totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK); + AFframecount totalFramesWritten = 0; |