[beast: 8/11] BSE: move Source.clear_{in|out}puts into bseapi.idl



commit eb6ec3d479e16263932133ad6820e257af549744
Author: Tim Janik <timj gnu org>
Date:   Tue Sep 5 01:52:23 2017 +0200

    BSE: move Source.clear_{in|out}puts into bseapi.idl
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/Makefile.am    |    1 -
 bse/bseapi.idl     |    4 +-
 bse/bsesource.cc   |   57 ++++++++++++++++++++++++++++++++++++++++++++
 bse/bsesource.hh   |    2 +
 bse/bsesource.proc |   67 ----------------------------------------------------
 5 files changed, 61 insertions(+), 70 deletions(-)
---
diff --git a/bse/Makefile.am b/bse/Makefile.am
index fed5ad8..fcc51d2 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -114,7 +114,6 @@ idl_dummy_files = $(strip   \
 # BSE procedure sources
 bse_proc_sources = $(strip \
        bsejanitor.proc         \
-                                                                               bsesource.proc          \
                                bseitem.proc                                    \
 )
 bse_proc_gen_sources = $(bse_proc_sources:.proc=.genprc.cc)
diff --git a/bse/bseapi.idl b/bse/bseapi.idl
index dcd8def..0157e18 100644
--- a/bse/bseapi.idl
+++ b/bse/bseapi.idl
@@ -751,8 +751,8 @@ sequence PartSeq {
 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.
 
-  // void clear_inputs (); ///< Disconnect all module inputs.
-  // void clear_outputs (); ///< Disconnect all module outputs.
+  void clear_inputs ();  ///< Disconnect all module inputs.
+  void clear_outputs (); ///< Disconnect all module outputs.
   bool has_output (int32 ochannel); ///< Check whether a module's output channel is connected.
   bool has_outputs (); ///< Check whether a module has output channel connections.
   String ichannel_blurb (int32 input_channel); ///< Get input channel description.
diff --git a/bse/bsesource.cc b/bse/bsesource.cc
index 44b7dd1..7f9fabd 100644
--- a/bse/bsesource.cc
+++ b/bse/bsesource.cc
@@ -2379,4 +2379,61 @@ SourceImpl::set_automation (const String &property_name, int midi_channel, MidiC
   return error;
 }
 
+void
+SourceImpl::clear_inputs ()
+{
+  BseSource *self = as<BseSource*>();
+  g_object_ref (self);
+  BseUndoStack *ustack = bse_item_undo_open (self, "%s", __func__);
+  for (size_t i = 0; i < BSE_SOURCE_N_ICHANNELS (self); i++)
+    {
+      BseSourceInput *input = BSE_SOURCE_INPUT (self, i);
+      if (BSE_SOURCE_IS_JOINT_ICHANNEL (self, i))
+        while (input->jdata.n_joints)
+          {
+            BseSource *osource = input->jdata.joints[0].osource;
+            uint ochannel = input->jdata.joints[0].ochannel;
+            unset_input_by_id (i, *osource->as<SourceIfaceP>(), ochannel);
+          }
+      else if (input->idata.osource)
+       {
+         BseSource *osource = input->idata.osource;
+          unset_input_by_id (i, *osource->as<SourceIfaceP>(), input->idata.ochannel);
+       }
+    }
+  bse_item_undo_close (ustack);
+  g_object_unref (self);
+}
+
+void
+SourceImpl::clear_outputs ()
+{
+  BseSource *self = as<BseSource*>();
+  g_object_ref (self);
+  BseUndoStack *ustack = bse_item_undo_open (self, "%s", __func__);
+  while (self->outputs)
+    {
+      BseSource *isource = static_cast<BseSource*> (self->outputs->data);
+      g_object_ref (isource);
+      for (uint i = 0; i < BSE_SOURCE_N_ICHANNELS (isource); i++)
+       {
+         BseSourceInput *input = BSE_SOURCE_INPUT (isource, i);
+         if (BSE_SOURCE_IS_JOINT_ICHANNEL (isource, i))
+           {
+             uint j;
+             for (j = 0; j < input->jdata.n_joints; j++)
+               if (input->jdata.joints[j].osource == self)
+                 break;
+             if (j < input->jdata.n_joints)
+                isource->as<SourceIfaceP>()->unset_input_by_id (i, *this, input->jdata.joints[j].ochannel);
+           }
+         else if (input->idata.osource == self)
+            isource->as<SourceIfaceP>()->unset_input_by_id (i, *this, input->idata.ochannel);
+       }
+      g_object_unref (isource);
+    }
+  bse_item_undo_close (ustack);
+  g_object_unref (self);
+}
+
 } // Bse
diff --git a/bse/bsesource.hh b/bse/bsesource.hh
index 928076e..16f4d0e 100644
--- a/bse/bsesource.hh
+++ b/bse/bsesource.hh
@@ -277,6 +277,8 @@ protected:
 public:
   explicit             SourceImpl              (BseObject*);
   virtual SourceIfaceP ichannel_get_osource    (int input_channel, int input_joint) override;
+  virtual void         clear_inputs            () override;
+  virtual void         clear_outputs           () override;
   virtual bool         has_output              (int ochannel) override;
   virtual bool         has_outputs             () override;
   virtual std::string  ichannel_blurb          (int input_channel) override;


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