[beast: 59/73] BSE: SF2: move more data members from BseSoundFont to Bse::SoundFontImpl
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 59/73] BSE: SF2: move more data members from BseSoundFont to Bse::SoundFontImpl
- Date: Thu, 23 Mar 2017 21:46:38 +0000 (UTC)
commit 5a819d48958b2eb733abc63cab0ecd69acfa70e2
Author: Stefan Westerfeld <stefan space twc de>
Date: Mon Feb 13 11:36:53 2017 +0100
BSE: SF2: move more data members from BseSoundFont to Bse::SoundFontImpl
Signed-off-by: Stefan Westerfeld <stefan space twc de>
bse/bsesoundfont.cc | 76 +++++++++++++++++++++++++++---------------------
bse/bsesoundfont.hh | 5 ++-
bse/bsesoundfontosc.cc | 2 +-
3 files changed, 47 insertions(+), 36 deletions(-)
---
diff --git a/bse/bsesoundfont.cc b/bse/bsesoundfont.cc
index 2442687..81c7e51 100644
--- a/bse/bsesoundfont.cc
+++ b/bse/bsesoundfont.cc
@@ -30,8 +30,6 @@ static GQuark quark_load_sound_font = 0;
static void
bse_sound_font_init (BseSoundFont *sound_font)
{
- sound_font->sfont_id = -1;
- sound_font->sfrepo = NULL;
}
static void
@@ -73,14 +71,6 @@ bse_sound_font_get_property (GObject *object,
static void
bse_sound_font_dispose (GObject *object)
{
- BseSoundFont *sound_font = BSE_SOUND_FONT (object);
- if (sound_font->sfont_id != -1)
- bse_sound_font_unload (sound_font);
- if (sound_font->sfrepo)
- {
- g_object_unref (sound_font->sfrepo);
- sound_font->sfrepo = NULL;
- }
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -88,11 +78,6 @@ bse_sound_font_dispose (GObject *object)
static void
bse_sound_font_finalize (GObject *object)
{
- BseSoundFont *sound_font = BSE_SOUND_FONT (object);
-
- if (sound_font->sfrepo != NULL || sound_font->sfont_id != -1)
- g_warning (G_STRLOC ": some resources could not be freed.");
-
/* chain parent class' handler */
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -104,18 +89,18 @@ bse_sound_font_load_blob (BseSoundFont *self,
{
Bse::SoundFontImpl *sound_font_impl = self->as<Bse::SoundFontImpl *>();
- if (self->sfrepo == NULL)
+ if (sound_font_impl->sfrepo == NULL)
{
- self->sfrepo = BSE_SOUND_FONT_REPO (BSE_ITEM (self)->parent);
- g_object_ref (self->sfrepo);
+ sound_font_impl->sfrepo = BSE_SOUND_FONT_REPO (BSE_ITEM (self)->parent);
+ g_object_ref (sound_font_impl->sfrepo);
}
g_return_val_if_fail (blob != NULL, Bse::Error::INTERNAL);
- g_return_val_if_fail (self->sfrepo != NULL, Bse::Error::INTERNAL);
- g_return_val_if_fail (self->sfont_id == -1, Bse::Error::INTERNAL);
+ g_return_val_if_fail (sound_font_impl->sfrepo != NULL, Bse::Error::INTERNAL);
+ g_return_val_if_fail (sound_font_impl->sfont_id == -1, Bse::Error::INTERNAL);
- std::lock_guard<Bse::Mutex> guard (bse_sound_font_repo_mutex (self->sfrepo));
- fluid_synth_t *fluid_synth = bse_sound_font_repo_fluid_synth (self->sfrepo);
+ std::lock_guard<Bse::Mutex> guard (bse_sound_font_repo_mutex (sound_font_impl->sfrepo));
+ fluid_synth_t *fluid_synth = bse_sound_font_repo_fluid_synth (sound_font_impl->sfrepo);
int sfont_id = fluid_synth_sfload (fluid_synth, blob->file_name().c_str(), 0);
Bse::Error error;
if (sfont_id != -1)
@@ -136,7 +121,7 @@ bse_sound_font_load_blob (BseSoundFont *self,
bse_sound_font_preset_init_preset (sound_font_preset, &fluid_preset);
}
}
- self->sfont_id = sfont_id;
+ sound_font_impl->sfont_id = sfont_id;
sound_font_impl->blob = blob;
error = Bse::Error::NONE;
}
@@ -151,16 +136,18 @@ bse_sound_font_load_blob (BseSoundFont *self,
void
bse_sound_font_unload (BseSoundFont *sound_font)
{
- g_return_if_fail (sound_font->sfrepo != NULL);
+ Bse::SoundFontImpl *sound_font_impl = sound_font->as<Bse::SoundFontImpl *>();
- if (sound_font->sfont_id != -1)
+ g_return_if_fail (sound_font_impl->sfrepo != NULL);
+
+ if (sound_font_impl->sfont_id != -1)
{
- std::lock_guard<Bse::Mutex> guard (bse_sound_font_repo_mutex (sound_font->sfrepo));
- fluid_synth_t *fluid_synth = bse_sound_font_repo_fluid_synth (sound_font->sfrepo);
+ std::lock_guard<Bse::Mutex> guard (bse_sound_font_repo_mutex (sound_font_impl->sfrepo));
+ fluid_synth_t *fluid_synth = bse_sound_font_repo_fluid_synth (sound_font_impl->sfrepo);
- fluid_synth_sfunload (fluid_synth, sound_font->sfont_id, 1 /* reset presets */);
+ fluid_synth_sfunload (fluid_synth, sound_font_impl->sfont_id, 1 /* reset presets */);
}
- sound_font->sfont_id = -1;
+ sound_font_impl->sfont_id = -1;
}
Bse::Error
@@ -168,11 +155,19 @@ bse_sound_font_reload (BseSoundFont *sound_font)
{
Bse::SoundFontImpl *sound_font_impl = sound_font->as<Bse::SoundFontImpl *>();
- g_return_val_if_fail (sound_font->sfont_id == -1, Bse::Error::INTERNAL);
+ g_return_val_if_fail (sound_font_impl->sfont_id == -1, Bse::Error::INTERNAL);
return bse_sound_font_load_blob (sound_font, sound_font_impl->blob, FALSE);
}
+int
+bse_sound_font_get_id (BseSoundFont *sound_font)
+{
+ Bse::SoundFontImpl *sound_font_impl = sound_font->as<Bse::SoundFontImpl *>();
+
+ return sound_font_impl->sfont_id;
+}
+
static void
bse_sound_font_store_private (BseObject *object,
BseStorage *storage)
@@ -310,7 +305,6 @@ bse_sound_font_release_children (BseContainer *container)
BSE_CONTAINER_CLASS (parent_class)->release_children (container);
}
-
static void
bse_sound_font_class_init (BseSoundFontClass *klass)
{
@@ -367,10 +361,26 @@ BSE_BUILTIN_TYPE (BseSoundFont)
namespace Bse {
SoundFontImpl::SoundFontImpl (BseObject *bobj) :
- ContainerImpl (bobj)
+ ContainerImpl (bobj),
+ sfrepo (nullptr),
+ sfont_id (-1)
{}
SoundFontImpl::~SoundFontImpl ()
-{}
+{
+ BseSoundFont *sound_font = as<BseSoundFont *>();
+
+ if (sfont_id != -1)
+ bse_sound_font_unload (sound_font);
+
+ if (sfrepo)
+ {
+ g_object_unref (sfrepo);
+ sfrepo = nullptr;
+ }
+
+ if (sfrepo != NULL || sfont_id != -1)
+ g_warning (G_STRLOC ": some resources could not be freed.");
+}
} // Bse
diff --git a/bse/bsesoundfont.hh b/bse/bsesoundfont.hh
index 23c34a8..8038a9f 100644
--- a/bse/bsesoundfont.hh
+++ b/bse/bsesoundfont.hh
@@ -14,8 +14,6 @@
#define BSE_SOUND_FONT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), BSE_TYPE_SOUND_FONT,
BseSoundFontClass))
struct BseSoundFont : BseContainer {
- int sfont_id;
- BseSoundFontRepo *sfrepo;
GList *presets;
};
struct BseSoundFontClass : BseContainerClass
@@ -26,11 +24,14 @@ Bse::Error bse_sound_font_load_blob (BseSoundFont *sound_font,
gboolean init_presets);
void bse_sound_font_unload (BseSoundFont *sound_font);
Bse::Error bse_sound_font_reload (BseSoundFont *sound_font);
+int bse_sound_font_get_id (BseSoundFont *sound_font);
namespace Bse {
class SoundFontImpl : public ContainerImpl, public virtual SoundFontIface {
public:
+ BseSoundFontRepo *sfrepo;
+ int sfont_id;
BseStorage::BlobP blob;
protected:
virtual ~SoundFontImpl ();
diff --git a/bse/bsesoundfontosc.cc b/bse/bsesoundfontosc.cc
index 6bada07..06a41d4 100644
--- a/bse/bsesoundfontosc.cc
+++ b/bse/bsesoundfontosc.cc
@@ -264,7 +264,7 @@ bse_sound_font_osc_set_property (GObject *object,
{
bse_item_cross_link (BSE_ITEM (self), BSE_ITEM (self->preset),
bse_sound_font_osc_uncross_preset);
bse_object_proxy_notifies (self->preset, self, "notify::preset");
- self->config.sfont_id = BSE_SOUND_FONT (BSE_ITEM (self->preset)->parent)->sfont_id;
+ self->config.sfont_id = bse_sound_font_get_id (BSE_SOUND_FONT (BSE_ITEM
(self->preset)->parent));
self->config.bank = self->preset->bank;
self->config.program = self->preset->program;
self->config.update_preset++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]