[beast: 16/49] BSE: bseapi.idl: introduce Source



commit 4cca6472bae8989edfa2f1347c48512646fc095f
Author: Tim Janik <timj gnu org>
Date:   Mon Jun 22 15:27:16 2015 +0200

    BSE: bseapi.idl: introduce Source

 beast-gtk/bstcanvassource.cc |    6 +++++-
 beast-gtk/bstsnetrouter.cc   |    6 +++++-
 bse/bseapi.idl               |    7 ++++++-
 bse/bsecontainer.cc          |    2 +-
 bse/bsecontainer.hh          |    2 +-
 bse/bseobject.cc             |    2 ++
 bse/bsesource.cc             |   30 ++++++++++++++++++++++++++++--
 bse/bsesource.hh             |   12 ++++++++++++
 bse/bsesource.proc           |   37 -------------------------------------
 9 files changed, 60 insertions(+), 44 deletions(-)
---
diff --git a/beast-gtk/bstcanvassource.cc b/beast-gtk/bstcanvassource.cc
index e4fb96d..baa3ad1 100644
--- a/beast-gtk/bstcanvassource.cc
+++ b/beast-gtk/bstcanvassource.cc
@@ -493,7 +493,11 @@ bst_canvas_source_ichannel_free (BstCanvasSource *csource,
   if (bse_source_is_joint_ichannel_by_id (csource->source, ichannel))
     return TRUE;
   else
-    return bse_source_ichannel_get_osource (csource->source, ichannel, 0) == 0;
+    {
+      Bse::SourceH isource = Bse::SourceH::down_cast (bse_server.from_proxy (csource->source));
+      Bse::SourceH osource = isource.ichannel_get_osource (ichannel, 0);
+      return osource == NULL;
+    }
 }
 
 void
diff --git a/beast-gtk/bstsnetrouter.cc b/beast-gtk/bstsnetrouter.cc
index 3c231da..0f68125 100644
--- a/beast-gtk/bstsnetrouter.cc
+++ b/beast-gtk/bstsnetrouter.cc
@@ -160,7 +160,11 @@ bst_snet_router_update_links (BstSNetRouter   *self,
       guint j, n_joints = bse_source_ichannel_get_n_joints (csource->source, i);
       for (j = 0; j < n_joints; j++)
         {
-          SfiProxy osource = bse_source_ichannel_get_osource (csource->source, i, j);
+          Bse::ObjectH obj = bse_server.from_proxy (csource->source);
+          assert (obj != NULL);
+          Bse::SourceH isource = Bse::SourceH::down_cast (bse_server.from_proxy (csource->source));
+          assert (isource != NULL);
+          SfiProxy osource = isource.ichannel_get_osource (i, j).proxy_id();
           if (!osource)
             continue;
           guint ochannel = bse_source_ichannel_get_ochannel (csource->source, i, j);
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index b2c4295..624b234 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -119,8 +119,13 @@ interface Item : Object {
   Item common_ancestor (Item other);    ///< Find a common container (parent or grand-parent) of two items 
if any.
 };
 
+/// Base type for synthesis objects with input or output streams.
+interface Source : Item {
+  Source ichannel_get_osource (int32 input_channel, int32 input_joint); ///< Retrieve output module 
connected to a specific joint of an input channel.
+};
+
 /// Base type for objects that can be added to a container.
-interface Container : Item {
+interface Container : Source {
   Item lookup_item (String uname); ///< Find an immediate child of a container by name (unique per container 
child).
 };
 
diff --git a/bse/bsecontainer.cc b/bse/bsecontainer.cc
index 701ec4f..3be9ba5 100644
--- a/bse/bsecontainer.cc
+++ b/bse/bsecontainer.cc
@@ -1352,7 +1352,7 @@ bse_container_debug_tree (BseContainer *container)
 namespace Bse {
 
 ContainerImpl::ContainerImpl (BseObject *bobj) :
-  ItemImpl (bobj)
+  SourceImpl (bobj)
 {}
 
 ContainerImpl::~ContainerImpl ()
diff --git a/bse/bsecontainer.hh b/bse/bsecontainer.hh
index 9e9063e..aae97a5 100644
--- a/bse/bsecontainer.hh
+++ b/bse/bsecontainer.hh
@@ -105,7 +105,7 @@ G_END_DECLS
 
 namespace Bse {
 
-class ContainerImpl : public ItemImpl, public virtual ContainerIface {
+class ContainerImpl : public SourceImpl, public virtual ContainerIface {
 protected:
   virtual           ~ContainerImpl         ();
 public:
diff --git a/bse/bseobject.cc b/bse/bseobject.cc
index b8df6ed..6353ca3 100644
--- a/bse/bseobject.cc
+++ b/bse/bseobject.cc
@@ -938,6 +938,8 @@ bse_object_new_valist (GType object_type, const gchar *first_property_name, va_l
     cxxo = new Bse::SuperImpl (object);
   else if (g_type_is_a (object_type, BSE_TYPE_CONTAINER))
     cxxo = new Bse::ContainerImpl (object);
+  else if (g_type_is_a (object_type, BSE_TYPE_SOURCE))
+    cxxo = new Bse::SourceImpl (object);
   else if (g_type_is_a (object_type, BSE_TYPE_ITEM))
     cxxo = new Bse::ItemImpl (object);
   else if (g_type_is_a (object_type, BSE_TYPE_OBJECT))
diff --git a/bse/bsesource.cc b/bse/bsesource.cc
index a269947..f4a1e39 100644
--- a/bse/bsesource.cc
+++ b/bse/bsesource.cc
@@ -606,8 +606,8 @@ bse_source_context_ids (BseSource *source,
 {
   guint *cids, i;
 
-  g_return_val_if_fail (BSE_IS_SOURCE (source), FALSE);
-  g_return_val_if_fail (n_ids != NULL, FALSE);
+  g_return_val_if_fail (BSE_IS_SOURCE (source), NULL);
+  g_return_val_if_fail (n_ids != NULL, NULL);
 
   cids = g_new (guint, BSE_SOURCE_N_CONTEXTS (source));
   for (i = 0; i < BSE_SOURCE_N_CONTEXTS (source); i++)
@@ -2061,3 +2061,29 @@ BSE_BUILTIN_TYPE (BseSource)
                                      __FILE__, __LINE__,
                                      &source_info);
 }
+
+namespace Bse {
+
+SourceImpl::SourceImpl (BseObject *bobj) :
+  ItemImpl (bobj)
+{}
+
+SourceImpl::~SourceImpl ()
+{}
+
+SourceIfaceP
+SourceImpl::ichannel_get_osource (int input_channel, int input_joint)
+{
+  BseSource *self = as<BseSource*>();
+  BseSourceInput *input = BSE_SOURCE_INPUT (self, input_channel);
+  BseSource *osource;
+  if (BSE_SOURCE_IS_JOINT_ICHANNEL (self, input_channel) && uint (input_joint) < input->jdata.n_joints)
+    osource = input->jdata.joints[input_joint].osource;
+  else if (input_joint < 1)
+    osource = input->idata.osource;
+  else
+    osource = NULL;
+  return osource ? shared_ptr_cast<SourceIface> (osource->as<SourceIface*>()) : SourceIfaceP();
+}
+
+} // Bse
diff --git a/bse/bsesource.hh b/bse/bsesource.hh
index a5d7936..1d6d016 100644
--- a/bse/bsesource.hh
+++ b/bse/bsesource.hh
@@ -273,4 +273,16 @@ void    bse_source_probes_modules_changed       (BseSource      *source);
 
 G_END_DECLS
 
+namespace Bse {
+
+class SourceImpl : public ItemImpl, public virtual SourceIface {
+protected:
+  virtual             ~SourceImpl           ();
+public:
+  explicit             SourceImpl           (BseObject*);
+  virtual SourceIfaceP ichannel_get_osource (int input_channel, int input_joint) override;
+};
+
+} // Bse
+
 #endif /* __BSE_SOURCE_H__ */
diff --git a/bse/bsesource.proc b/bse/bsesource.proc
index d04841e..8e88ce6 100644
--- a/bse/bsesource.proc
+++ b/bse/bsesource.proc
@@ -489,43 +489,6 @@ BODY (BseProcedureClass *proc,
   return BSE_ERROR_NONE;
 }
 
-METHOD (BseSource, ichannel-get-osource) {
-  HELP = "Retrieve output module connected to a specific joint of an input channel";
-  IN   = bse_param_spec_object ("module", "Module", NULL,
-                                BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
-  IN   = sfi_pspec_int ("input-channel", "Input Channel", NULL,
-                        0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
-  IN   = sfi_pspec_int ("input-joint", "Input Joint", NULL,
-                        0, 0, G_MAXINT, 1, SFI_PARAM_STANDARD);
-  OUT   = bse_param_spec_object ("osource", "Output Source", NULL,
-                                BSE_TYPE_SOURCE, SFI_PARAM_STANDARD);
-}
-BODY (BseProcedureClass *proc,
-      const GValue      *in_values,
-      GValue            *out_values)
-{
-  /* extract parameter values */
-  BseSource *source = (BseSource*) bse_value_get_object (in_values++);
-  guint ichannel    = sfi_value_get_int (in_values++);
-  guint joint       = sfi_value_get_int (in_values++);
-  BseSourceInput *input;
-
-  /* check parameters */
-  if (!BSE_IS_SOURCE (source) || ichannel >= BSE_SOURCE_N_ICHANNELS (source))
-    return BSE_ERROR_PROC_PARAM_INVAL;
-
-  /* set output parameters */
-  input = BSE_SOURCE_INPUT (source, ichannel);
-  if (BSE_SOURCE_IS_JOINT_ICHANNEL (source, ichannel) && joint < input->jdata.n_joints)
-    bse_value_set_object (out_values++, input->jdata.joints[joint].osource);
-  else if (joint < 1)
-    bse_value_set_object (out_values++, input->idata.osource);
-  else
-    bse_value_set_object (out_values++, NULL);
-
-  return BSE_ERROR_NONE;
-}
-
 METHOD (BseSource, ichannel-get-ochannel) {
   HELP = "Retrieve output channel of the module connected to a specific joint of an input channel.";
   IN   = bse_param_spec_object ("module", "Module", NULL,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]