[beast: 2/8] BSE: use Rapicorn resources to compile and access BSE files
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 2/8] BSE: use Rapicorn resources to compile and access BSE files
- Date: Fri, 12 Jun 2015 21:26:20 +0000 (UTC)
commit 14ef791e8a27e37c66404bab6b3382de341b414c
Author: Tim Janik <timj gnu org>
Date: Fri Jan 30 05:31:33 2015 +0100
BSE: use Rapicorn resources to compile and access BSE files
bse/bsestandardsynths.cc | 69 ++++++---------------------------------------
bse/zintern/.gitignore | 2 +-
bse/zintern/Makefile.am | 26 ++++++----------
3 files changed, 21 insertions(+), 76 deletions(-)
---
diff --git a/bse/bsestandardsynths.cc b/bse/bsestandardsynths.cc
index 71631ba..8b2f106 100644
--- a/bse/bsestandardsynths.cc
+++ b/bse/bsestandardsynths.cc
@@ -3,10 +3,8 @@
#include "bsesnet.hh"
#include "bsestandardosc.hh"
-#include <zlib.h>
#include <string.h>
-
/* --- typedef & structures --- */
typedef struct {
const gchar *name;
@@ -15,75 +13,28 @@ typedef struct {
guint clength;
} BseZFile;
-
/* --- generated ZFiles --- */
-#include "bse/zintern/bse-zfile.cc" /* bse_zfiles */
-
+#include "bse/zintern/bse-resources.cc"
/* --- variables --- */
static GSList *zfile_names = NULL;
-
/* --- functions --- */
-static gchar*
-bse_zfile_uncompress (const BseZFile *zfile,
- guint *text_len)
-{
- uLongf dlen = zfile->text_size;
- guint len = dlen + 1;
- guint8 *text = (guint8*) g_malloc (len);
- gint result;
- const gchar *err;
-
- if (zfile->clength) /* indicates compresssion */
- result = uncompress (text, &dlen, zfile->cdata, zfile->clength);
- else
- {
- memcpy (text, zfile->cdata, dlen);
- result = Z_OK;
- }
- switch (result)
- {
- case Z_OK:
- if (dlen == zfile->text_size)
- {
- err = NULL;
- break;
- }
- /* fall through */
- case Z_DATA_ERROR:
- err = "internal data corruption";
- break;
- case Z_MEM_ERROR:
- err = "out of memory";
- break;
- case Z_BUF_ERROR:
- err = "insufficient buffer size";
- break;
- default:
- err = "unknown error";
- break;
- }
- if (err)
- g_error ("while decompressing \"%s\": %s", zfile->name, err);
-
- text[dlen] = 0;
- if (text_len)
- *text_len = dlen;
- return (char*) text;
-}
-
gchar*
bse_standard_synth_inflate (const gchar *synth_name,
guint *text_len)
{
- guint i;
-
g_return_val_if_fail (synth_name != NULL, NULL);
- for (i = 0; i < G_N_ELEMENTS (bse_zfiles); i++)
- if (strcmp (synth_name, bse_zfiles[i].name) == 0)
- return bse_zfile_uncompress (bse_zfiles + i, text_len);
+ const Rapicorn::String synth_res = Rapicorn::String ("@res ") + synth_name + ".bse";
+ Rapicorn::Blob blob = Rapicorn::Res (synth_res);
+ if (blob.size())
+ {
+ gchar *result = (gchar*) g_malloc (blob.size() + 1);
+ memcpy (result, blob.data(), blob.size());
+ result[blob.size()] = 0;
+ return result;
+ }
g_warning ("unknown standard synth: %s", synth_name);
return NULL;
}
diff --git a/bse/zintern/.gitignore b/bse/zintern/.gitignore
index 72f0150..9e3a50f 100644
--- a/bse/zintern/.gitignore
+++ b/bse/zintern/.gitignore
@@ -1 +1 @@
-bse-zfile.c
+bse-resources.cc
diff --git a/bse/zintern/Makefile.am b/bse/zintern/Makefile.am
index 7cd7251..8aaa878 100644
--- a/bse/zintern/Makefile.am
+++ b/bse/zintern/Makefile.am
@@ -3,23 +3,23 @@ include $(top_srcdir)/Makefile.decl
AM_CPPFLAGS += -I$(top_srcdir) -I$(top_builddir)
AM_CXXFLAGS += $(BSE_CFLAGS) -DG_DISABLE_DEPRECATED -DG_DISABLE_CONST_RETURNS
-ZINTERN = rapicorn-zintern
+RAPIDRES = rapidres
ZFILE_DEFS = $(strip \
- gus-patch $(srcdir)/gus-patch.bse \
- adsr-wave-1 $(srcdir)/adsr-wave-1.bse \
- adsr-wave-2 $(srcdir)/adsr-wave-2.bse \
- plain-wave-1 $(srcdir)/plain-wave-1.bse \
- plain-wave-2 $(srcdir)/plain-wave-2.bse \
+ $(srcdir)/gus-patch.bse \
+ $(srcdir)/adsr-wave-1.bse \
+ $(srcdir)/adsr-wave-2.bse \
+ $(srcdir)/plain-wave-1.bse \
+ $(srcdir)/plain-wave-2.bse \
)
gen_sources = xgen-bzc xgen-bzh
-CLEANFILES += $(gen_sources) bse-zfile.cc bse-zfile.h
-noinst_DATA = bse-zfile.cc # bse-zfile.h
+CLEANFILES += $(gen_sources) bse-resources.cc
+noinst_DATA = bse-resources.cc
EXTRA_DIST += $(filter %.bse, $(ZFILE_DEFS))
-bse-zfile.cc: $(srcdir)/*.bse # bse-zfile.h
- $(ZINTERN) -b -z $(ZFILE_DEFS) > xgen-bzc \
+bse-resources.cc: $(srcdir)/*.bse
+ $(RAPIDRES) $(ZFILE_DEFS) > xgen-bzc \
&& echo "static const BseZFile bse_zfiles[] = {" >> xgen-bzc \
&& for i in $(filter-out %.bse, $(ZFILE_DEFS)) ; do \
uname=$$(echo $$i | tr a-z- A-Z_); \
@@ -29,12 +29,6 @@ bse-zfile.cc: $(srcdir)/*.bse # bse-zfile.h
&& echo "};" >> xgen-bzc \
&& cp xgen-bzc $@ \
&& rm -f xgen-bzc
-#bse-zfile.h: zintern $(srcdir)/*.bse
-# for i in $(filter BSE_%, $(ZFILE_DEFS)) ; do \
-# echo "#define $$i \"BSE_$$i\"" >> xgen-bzh; \
-# done \
-# && cp xgen-bzh $@ \
-# && rm -f xgen-bzh
# need -I$(top_srcdir) for <gsl/gsldefs.h>
# need -I. for "../topconfig.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]