[SCM] calf/master: Remove unnecessary parts of OSC implementation.

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:40:45 UTC 2013


The following commit has been merged in the master branch:
commit c8d7fc316b5040ea8f80ff07a6c60f6ad896822b
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Fri Dec 16 23:04:48 2011 +0000

    Remove unnecessary parts of OSC implementation.
    
    I'm still using some of the OSC code to serialize maps for session storage.

diff --git a/src/Makefile.am b/src/Makefile.am
index 319d8c4..ee26062 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,7 +37,7 @@ calfmakerdf_LDADD = calf.la
 calfbenchmark_SOURCES = benchmark.cpp
 calfbenchmark_LDADD = $(GLIB_DEPS_LIBS) calf.la
 
-calf_la_SOURCES = audio_fx.cpp metadata.cpp modules.cpp modules_comp.cpp modules_limit.cpp modules_dist.cpp modules_eq.cpp modules_mod.cpp fluidsynth.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp osctlnet.cpp plugin.cpp preset.cpp synth.cpp utils.cpp wavetable.cpp modmatrix.cpp 
+calf_la_SOURCES = audio_fx.cpp metadata.cpp modules.cpp modules_comp.cpp modules_limit.cpp modules_dist.cpp modules_eq.cpp modules_mod.cpp fluidsynth.cpp giface.cpp monosynth.cpp organ.cpp osctl.cpp plugin.cpp preset.cpp synth.cpp utils.cpp wavetable.cpp modmatrix.cpp 
 calf_la_LIBADD ?= $(FLUIDSYNTH_DEPS_LIBS)
 if USE_DEBUG
 calf_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat -disable-static $(FLUIDSYNTH_DEPS_LIBS)
@@ -51,7 +51,7 @@ if USE_LV2_GUI
 
 noinst_LTLIBRARIES += calflv2gui.la
 
-calflv2gui_la_SOURCES = gui.cpp gui_config.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp ctl_vumeter.cpp custom_ctl.cpp metadata.cpp giface.cpp preset.cpp preset_gui.cpp lv2gui.cpp osctl.cpp osctlnet.cpp utils.cpp
+calflv2gui_la_SOURCES = gui.cpp gui_config.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp ctl_vumeter.cpp custom_ctl.cpp metadata.cpp giface.cpp preset.cpp preset_gui.cpp lv2gui.cpp osctl.cpp utils.cpp
 
 if USE_DEBUG
 calflv2gui_la_LDFLAGS = -rpath $(lv2dir) -avoid-version -module -lexpat $(GUI_DEPS_LIBS) -disable-static
@@ -62,7 +62,7 @@ endif
 endif
 
 if USE_GUI
-libcalfgui_la_SOURCES = gui.cpp gui_config.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp ctl_vumeter.cpp preset_gui.cpp custom_ctl.cpp osctl.cpp osctlnet.cpp osctl_glib.cpp utils.cpp
+libcalfgui_la_SOURCES = gui.cpp gui_config.cpp gui_controls.cpp ctl_curve.cpp ctl_keyboard.cpp ctl_led.cpp ctl_vumeter.cpp preset_gui.cpp custom_ctl.cpp osctl.cpp utils.cpp
 libcalfgui_la_LDFLAGS = -static -disable-shared -lexpat
 endif
 
diff --git a/src/calf/Makefile.am b/src/calf/Makefile.am
index cc77109..b2bc234 100644
--- a/src/calf/Makefile.am
+++ b/src/calf/Makefile.am
@@ -8,5 +8,5 @@ noinst_HEADERS = audio_fx.h benchmark.h biquad.h buffer.h custom_ctl.h \
     metadata.h modmatrix.h \
     modules.h modules_comp.h modules_dev.h modules_dist.h modules_eq.h modules_mod.h modules_synths.h \
     modulelist.h \
-    multichorus.h onepole.h organ.h osc.h osctl.h osctlnet.h osctl_glib.h plugin_tools.h preset.h \
+    multichorus.h onepole.h organ.h osc.h osctl.h plugin_tools.h preset.h \
     preset_gui.h primitives.h session_mgr.h synth.h utils.h vumeter.h wave.h waveshaping.h
diff --git a/src/calf/osctl_glib.h b/src/calf/osctl_glib.h
deleted file mode 100644
index 3242602..0000000
--- a/src/calf/osctl_glib.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Calf DSP Library
- * Open Sound Control UDP server support
- *
- * Copyright (C) 2007-2009 Krzysztof Foltman
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-
-#ifndef __CALF_OSCTLGLIB_H
-#define __CALF_OSCTLGLIB_H
-
-#include <glib.h>
-#include "osctlnet.h"
-
-namespace osctl
-{
-    
-/// Glib main loop based implementation of OSC server.
-struct osc_glib_server: public osc_server
-{
-    GIOChannel *ioch;
-    
-    osc_glib_server() : ioch(NULL) {}
-    
-    virtual void on_bind();
-    
-    static gboolean on_data(GIOChannel *channel, GIOCondition cond, void *obj);
-    ~osc_glib_server();
-};
-
-};
-
-#endif
diff --git a/src/calf/osctlnet.h b/src/calf/osctlnet.h
deleted file mode 100644
index c619cf7..0000000
--- a/src/calf/osctlnet.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Calf DSP Library
- * Open Sound Control UDP support
- *
- * Copyright (C) 2007 Krzysztof Foltman
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __CALF_OSCTLNET_H
-#define __CALF_OSCTLNET_H
-
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <calf/osctl.h>
-
-namespace osctl
-{
-    
-struct osc_socket
-{
-    int socket, srcid;
-    std::string prefix;
-
-    osc_socket() : socket(-1), srcid(0) {}
-    void bind(const char *hostaddr = "0.0.0.0", int port = 0);
-    std::string get_url() const;
-    virtual void on_bind() {}
-    virtual ~osc_socket();
-};
-
-struct osc_client: public osc_socket
-{
-    sockaddr_in addr;
-    
-    void set_addr(const char *hostaddr, int port);
-    void set_url(const char *url);
-    bool send(const std::string &address, osctl::osc_typed_strstream &stream);
-    bool send(const std::string &address);
-};
-
-/// Base implementation for OSC server - requires the interfacing code
-/// to poll periodically for messages. Alternatively, one can use
-/// osc_glib_server that hooks into glib main loop.
-struct osc_server: public osc_socket
-{
-    osc_message_dump<osc_strstream, std::ostream> dump;
-    osc_message_sink<osc_strstream> *sink;
-    
-    osc_server() : dump(std::cout), sink(&dump) {}
-    
-    void read_from_socket();
-    void parse_message(const char *buffer, int len);    
-    ~osc_server();
-};
-
-};
-
-#endif
diff --git a/src/giface.cpp b/src/giface.cpp
index 9e31668..4bd5f83 100644
--- a/src/giface.cpp
+++ b/src/giface.cpp
@@ -21,7 +21,6 @@
 #include <config.h>
 #include <limits.h>
 #include <calf/giface.h>
-#include <calf/osctlnet.h>
 #include <calf/utils.h>
 
 using namespace std;
@@ -383,106 +382,6 @@ uint32_t mod_matrix_metadata::get_table_rows() const
 ///////////////////////////////////////////////////////////////////////////////////////
 
 #if USE_EXEC_GUI
-struct osc_cairo_control: public cairo_iface
-{
-    osctl::osc_inline_typed_strstream &os;
-    
-    osc_cairo_control(osctl::osc_inline_typed_strstream &_os) : os(_os) {}
-    virtual void set_source_rgba(float r, float g, float b, float a = 1.f)
-    {
-        os << (uint32_t)LGI_SET_RGBA << r << g << b << a;
-    }
-    virtual void set_line_width(float width)
-    {
-        os << (uint32_t)LGI_SET_WIDTH << width;
-    }
-};
-
-static void serialize_graphs(osctl::osc_inline_typed_strstream &os, const line_graph_iface *graph, std::vector<int> &params)
-{
-    osc_cairo_control cairoctl(os);
-    for (size_t i = 0; i < params.size(); i++)
-    {
-        int index = params[i];
-        os << (uint32_t)LGI_GRAPH;
-        os << (uint32_t)index;
-        for (int j = 0; ; j++)
-        {
-            float data[128];
-            if (graph->get_graph(index, j, data, 128, &cairoctl))
-            {
-                os << (uint32_t)LGI_SUBGRAPH;
-                os << (uint32_t)128;
-                for (int p = 0; p < 128; p++)
-                    os << data[p];
-            }
-            else
-                break;
-        }
-        for (int j = 0; ; j++)
-        {
-            float x, y;
-            int size = 3;
-            if (graph->get_dot(index, j, x, y, size, &cairoctl))
-                os << (uint32_t)LGI_DOT << x << y << (uint32_t)size;
-            else
-                break;
-        }
-        for (int j = 0; ; j++)
-        {
-            float pos = 0;
-            bool vertical = false;
-            string legend;
-            if (graph->get_gridline(index, j, pos, vertical, legend, &cairoctl))
-                os << (uint32_t)LGI_LEGEND << pos << (uint32_t)(vertical ? 1 : 0) << legend;
-            else
-                break;
-        }
-        os << (uint32_t)LGI_END_ITEM;
-    }
-    os << (uint32_t)LGI_END;
-}
-
-calf_plugins::dssi_feedback_sender::dssi_feedback_sender(const char *URI, const line_graph_iface *_graph)
-{
-    graph = _graph;
-    is_client_shared = false;
-    client = new osctl::osc_client;
-    client->bind("0.0.0.0", 0);
-    client->set_url(URI);
-}
-
-calf_plugins::dssi_feedback_sender::dssi_feedback_sender(osctl::osc_client *_client, const line_graph_iface *_graph)
-{
-    graph = _graph;
-    client = _client;
-    is_client_shared = true;
-}
-
-void calf_plugins::dssi_feedback_sender::add_graphs(const calf_plugins::parameter_properties *props, int num_params)
-{
-    for (int i = 0; i < num_params; i++)
-    {
-        if (props[i].flags & PF_PROP_GRAPH)
-            indices.push_back(i);
-    }
-}
-
-void calf_plugins::dssi_feedback_sender::update()
-{
-    if (graph)
-    {
-        osctl::osc_inline_typed_strstream os;
-        serialize_graphs(os, graph, indices);
-        client->send("/lineGraph", os);
-    }
-}
-
-calf_plugins::dssi_feedback_sender::~dssi_feedback_sender()
-{
-    if (!is_client_shared)
-        delete client;
-}
 
 table_via_configure::table_via_configure()
 {
diff --git a/src/lv2gui.cpp b/src/lv2gui.cpp
index f1584d1..9c55d7e 100644
--- a/src/lv2gui.cpp
+++ b/src/lv2gui.cpp
@@ -26,14 +26,12 @@
 #include <calf/lv2_uri_map.h>
 #include <calf/lv2_external_ui.h>
 #include <calf/lv2helpers.h>
-#include <calf/osctlnet.h>
 #include <calf/utils.h>
 #include <glib.h>
 
 using namespace std;
 using namespace calf_plugins;
 using namespace calf_utils;
-using namespace osctl;
 
 struct LV2_Calf_Descriptor {
     plugin_ctl_iface *(*get_pci)(LV2_Handle Instance);
diff --git a/src/osctl_glib.cpp b/src/osctl_glib.cpp
deleted file mode 100644
index b4763d1..0000000
--- a/src/osctl_glib.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Calf DSP Library
- * Open Sound Control UDP server support
- *
- * Copyright (C) 2007-2009 Krzysztof Foltman
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-
-#include <calf/osctl_glib.h>
-
-using namespace osctl;
-using namespace std;
-
-void osc_glib_server::on_bind()
-{    
-    ioch = g_io_channel_unix_new(socket);
-    srcid = g_io_add_watch(ioch, G_IO_IN, on_data, this);
-}
-
-gboolean osc_glib_server::on_data(GIOChannel *channel, GIOCondition cond, void *obj)
-{
-    osc_server *self = (osc_server *)obj;
-    self->read_from_socket();
-    return TRUE;
-}
-
-osc_glib_server::~osc_glib_server()
-{
-    if (ioch)
-        g_source_remove(srcid);
-}
diff --git a/src/osctlnet.cpp b/src/osctlnet.cpp
deleted file mode 100644
index 09c7c0f..0000000
--- a/src/osctlnet.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/* Calf DSP Library
- * Open Sound Control UDP support
- *
- * Copyright (C) 2007-2009 Krzysztof Foltman
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General
- * Public License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-#include <calf/osctl.h>
-#include <calf/osctlnet.h>
-#include <assert.h>
-#include <arpa/inet.h>
-#include <sys/socket.h>
-#include <stdlib.h>
-#include <sstream>
-#include <stdio.h>
-using namespace osctl;
-using namespace std;
-
-void osc_socket::bind(const char *hostaddr, int port)
-{
-    socket = ::socket(PF_INET, SOCK_DGRAM, 0);
-    if (socket < 0)
-        throw osc_net_exception("socket");
-    
-    sockaddr_in sadr;
-    memset(&sadr, 0, sizeof(sadr));
-    sadr.sin_family = AF_INET;
-    sadr.sin_port = htons(port);
-    inet_aton(hostaddr, &sadr.sin_addr);
-    if (::bind(socket, (sockaddr *)&sadr, sizeof(sadr)) < 0)
-        throw osc_net_exception("bind");
-    on_bind();
-}
-
-std::string osc_socket::get_url() const
-{
-    sockaddr_in sadr;
-    socklen_t len = sizeof(sadr);
-    if (getsockname(socket, (sockaddr *)&sadr, &len) < 0)
-        throw osc_net_exception("getsockname");
-    
-    char name[INET_ADDRSTRLEN], buf[32];
-    
-    inet_ntop(AF_INET, &sadr.sin_addr, name, INET_ADDRSTRLEN);
-    sprintf(buf, "%d", ntohs(sadr.sin_port));
-    
-    return string("osc.udp://") + name + ":" + buf + prefix;
-}
-
-osc_socket::~osc_socket()
-{
-    close(socket);
-}
-
-//////////////////////////////////////////////////////////////
-
-void osc_client::set_addr(const char *hostaddr, int port)
-{
-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
-    inet_aton(hostaddr, &addr.sin_addr);
-}
-
-void osc_client::set_url(const char *url)
-{
-    const char *orig_url = url;
-    if (strncmp(url, "osc.udp://", 10))
-        throw osc_net_bad_address(url);
-    url += 10;
-    
-    const char *pos = strchr(url, ':');
-    const char *pos2 = strchr(url, '/');
-    if (!pos || !pos2)
-        throw osc_net_bad_address(orig_url);
-    
-    // XXXKF perhaps there is a default port for osc.udp?
-    if (pos2 - pos < 0)
-        throw osc_net_bad_address(orig_url);
-    
-    string hostname = string(url, pos - url);
-    int port = atoi(pos + 1);
-    prefix = string(pos2);
-    printf("hostname %s port %d\n", hostname.c_str(), port);
-
-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
-
-    hostent *he = gethostbyname(hostname.c_str());
-    if (!he)
-        throw osc_net_dns_exception("gethostbyname");
-    
-    addr.sin_addr = *(struct in_addr *)he->h_addr;
-}
-
-bool osc_client::send(const std::string &address, osctl::osc_typed_strstream &stream)
-{
-    std::string type_tag = "," + stream.type_buffer->data;
-    osc_inline_strstream hdr;
-    hdr << prefix + address << "," + stream.type_buffer->data;
-    string str = hdr.data + stream.buffer.data;
-    
-    // printf("sending %s\n", str.buffer.c_str());
-
-    return ::sendto(socket, str.data(), str.length(), 0, (sockaddr *)&addr, sizeof(addr)) == (int)str.length();
-}
-
-bool osc_client::send(const std::string &address)
-{
-    osc_inline_strstream hdr;
-    hdr << prefix + address << ",";
-    
-    return ::sendto(socket, hdr.data.data(), hdr.data.length(), 0, (sockaddr *)&addr, sizeof(addr)) == (int)hdr.data.length();
-}
-
-void osc_server::parse_message(const char *buffer, int len)
-{
-    osctl::string_buffer buf(string(buffer, len));
-    osc_strstream str(buf);
-    string address, type_tag;
-    str >> address;
-    str >> type_tag;
-    // cout << "Address " << address << " type tag " << type_tag << endl << flush;
-    if (!address.empty() && address[0] == '/'
-      &&!type_tag.empty() && type_tag[0] == ',')
-    {
-        sink->receive_osc_message(address, type_tag.substr(1), str);
-    }
-}
-
-void osc_server::read_from_socket()
-{
-    do {
-        char buf[65536];
-        int len = recv(socket, buf, 65536, MSG_DONTWAIT);
-        if (len > 0)
-        {
-            if (buf[0] == '/')
-            {
-                parse_message(buf, len);
-            }
-            if (buf[0] == '#')
-            {
-                // XXXKF bundles are not supported yet
-            }
-        }
-        else
-            break;
-    } while(1);
-}
-
-osc_server::~osc_server()
-{
-}
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 326809a..b530019 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -29,10 +29,8 @@
 #include <calf/modules_mod.h>
 #include <calf/modules_synths.h>
 #include <calf/organ.h>
-#include <calf/osctlnet.h>
 
 using namespace calf_plugins;
-using namespace osctl;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list