[SCM] zynaddsubfx/master.stable: Add patch to fix the loading of compressed banks file.
alessio at users.alioth.debian.org
alessio at users.alioth.debian.org
Wed Sep 5 16:21:19 UTC 2012
The following commit has been merged in the master.stable branch:
commit 1386f0669a6ba019b647c4d378f6bc90d224d2ca
Author: Alessio Treglia <alessio at debian.org>
Date: Wed Sep 5 18:18:41 2012 +0200
Add patch to fix the loading of compressed banks file.
Closes: #661887
Thanks: Lawrence D'Oliveiro for the patch.
diff --git a/debian/patches/10_load_compressed_banks.patch b/debian/patches/10_load_compressed_banks.patch
new file mode 100644
index 0000000..f276d40
--- /dev/null
+++ b/debian/patches/10_load_compressed_banks.patch
@@ -0,0 +1,121 @@
+Description: Replace gzseek/gzeof/gztell with incremental buffer allocation
+ and reading, in increments of 1 kiB.
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661887
+Author: Lawrence D'Oliveiro <ldo at geek-central.gen.nz>
+From: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661887#15
+---
+ src/Misc/XMLwrapper.cpp | 98 ++++++++++++++++++++++++++++--------------------
+ 1 file changed, 59 insertions(+), 39 deletions(-)
+
+--- zynaddsubfx.orig/src/Misc/XMLwrapper.cpp
++++ zynaddsubfx/src/Misc/XMLwrapper.cpp
+@@ -300,50 +300,70 @@ int XMLwrapper::loadXMLfile(const string
+ return(0);
+ };
+
++/* wrappers with more convenient and consistent signatures than direct gzread and fread calls */
++static ssize_t read_compressed
++ (
++ void * thefile,
++ char * buffer,
++ size_t bufsize
++ )
++ {
++ return
++ gzread((gzFile)thefile, buffer, bufsize);
++ } /*gz_read*/
++
++static ssize_t read_uncompressed
++ (
++ void * thefile,
++ char * buffer,
++ size_t bufsize
++ )
++ {
++ return
++ fread(buffer, bufsize, 1, (FILE *)thefile);
++ } /*read_uncompressed*/
+
+ char *XMLwrapper::doloadfile(const string &filename)
+ {
+ char *xmldata=NULL;
+- int filesize=-1;
++ size_t datasize = 0;
++ void * thefile;
++ ssize_t (*thefile_read)(void * thefile, char * buffer, size_t bufsize);
++ int (*thefile_close)(void * thefile);
++
++ thefile = gzopen(filename.c_str(),"rb");
++ if (thefile != NULL)
++ {
++ thefile_read = read_compressed;
++ thefile_close = (int (*)(void *))gzclose;
++ }
++ else
++ {
++ thefile = fopen(filename.c_str(),"rb");
++ if (thefile==NULL) return(NULL);
++ thefile_read = read_uncompressed;
++ thefile_close = (int (*)(void *))fclose;
++ } /*if*/
++ for (;;)
++ {
++ const size_t increment = 1024; /* something convenient */
++ const size_t prevdatasize = datasize;
++ datasize += increment;
++ xmldata = (char *)realloc(xmldata, datasize + 1);
++ if (xmldata == NULL) return(NULL);
++ const ssize_t bytesread = thefile_read(thefile, xmldata + prevdatasize, increment);
++ if (bytesread < 0) return(NULL);
++ if (bytesread < increment)
++ {
++ datasize = prevdatasize + bytesread;
++ xmldata = (char *)realloc(xmldata, datasize + 1); /* assume shrinking buffer won't fail! */
++ xmldata[datasize] = 0; /* terminating null */
++ break;
++ } /*if*/
++ } /*for*/
+
+- //try get filesize as gzip data (first)
+- gzFile gzfile=gzopen(filename.c_str(),"rb");
+- if (gzfile!=NULL) {//this is a gzip file
+- // first check it's size
+- while (!gzeof(gzfile)) {
+- gzseek (gzfile,1024*1024,SEEK_CUR);
+- if (gztell(gzfile)>10000000) {
+- gzclose(gzfile);
+- goto notgzip;//the file is too big
+- };
+- };
+- filesize=gztell(gzfile);
+-
+- //rewind the file and load the data
+- xmldata=new char[filesize+1];
+- ZERO(xmldata,filesize+1);
+-
+- gzrewind(gzfile);
+- gzread(gzfile,xmldata,filesize);
+-
+- gzclose(gzfile);
+- return (xmldata);
+- } else {//this is not a gzip file
+-notgzip:
+- FILE *file=fopen(filename.c_str(),"rb");
+- if (file==NULL) return(NULL);
+- fseek(file,0,SEEK_END);
+- filesize=ftell(file);
+-
+- xmldata=new char [filesize+1];
+- ZERO(xmldata,filesize+1);
+-
+- rewind(file);
+- fread(xmldata,filesize,1,file);
+-
+- fclose(file);
+- return(xmldata);
+- };
++ thefile_close(thefile);
++ return(xmldata);
+ };
+
+ bool XMLwrapper::putXMLdata(const char *xmldata)
diff --git a/debian/patches/series b/debian/patches/series
index 90eb2dd..c6a9a8e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,4 @@
07_ossaudiooutput.patch
08_jackaudiooutput.patch
09_fluid_1.3.patch
+10_load_compressed_banks.patch
--
zynaddsubfx packaging
More information about the pkg-multimedia-commits
mailing list